From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D895C433F5 for ; Fri, 22 Apr 2022 14:58:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75A136B0082; Fri, 22 Apr 2022 10:58:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E1006B0083; Fri, 22 Apr 2022 10:58:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 583F66B0085; Fri, 22 Apr 2022 10:58:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 469F86B0082 for ; Fri, 22 Apr 2022 10:58:02 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1CC121205C8 for ; Fri, 22 Apr 2022 14:58:02 +0000 (UTC) X-FDA: 79384820004.01.21B88D4 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf02.hostedemail.com (Postfix) with ESMTP id EA07280037 for ; Fri, 22 Apr 2022 14:57:59 +0000 (UTC) Date: Fri, 22 Apr 2022 07:57:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1650639479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yEZOup7wIqy02BcMRZRLp0SLmo1/PuUKmg3Pv5TLqWU=; b=WHkWfFnH+LeK7AefEWpgMiNUthZIEAVwi34pOhXpZgLAsfbAUshBOSjW44ktWjfgmr9qlb m77QNLA+d3VxusEPkU6lzywI0GM71VIkGFiya+S7NV5AO6qD5qRQHOAUukHg7ZTjLXo80G SCRsdEQctQ2UbwtbKCi5CCF/15liqhE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Andrew Morton , linux-mm@kvack.org Cc: Dave Chinner , linux-kernel@vger.kernel.org, Yang Shi , Kent Overstreet , Hillf Danton Subject: Re: [PATCH v1 0/5] mm: introduce shrinker debugfs interface Message-ID: References: <20220422015853.748291-1-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220422015853.748291-1-roman.gushchin@linux.dev> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EA07280037 X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WHkWfFnH; spf=pass (imf02.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Stat-Signature: 7kcassx94pxqsdxqacxwsifbpqj9hwck X-HE-Tag: 1650639479-503172 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 21, 2022 at 06:58:48PM -0700, Roman Gushchin wrote: > There are 50+ different shrinkers in the kernel, many with their own bells and > whistles. Under the memory pressure the kernel applies some pressure on each of > them in the order of which they were created/registered in the system. Some > of them can contain only few objects, some can be quite large. Some can be > effective at reclaiming memory, some not. > > The only existing debugging mechanism is a couple of tracepoints in > do_shrink_slab(): mm_shrink_slab_start and mm_shrink_slab_end. They aren't > covering everything though: shrinkers which report 0 objects will never show up, > there is no support for memcg-aware shrinkers. Shrinkers are identified by their > scan function, which is not always enough (e.g. hard to guess which super > block's shrinker it is having only "super_cache_scan"). They are a passive > mechanism: there is no way to call into counting and scanning of an individual > shrinker and profile it. > > To provide a better visibility and debug options for memory shrinkers > this patchset introduces a /sys/kernel/debug/shrinker interface, to some extent > similar to /sys/kernel/slab. > > For each shrinker registered in the system a directory is created. The directory > contains "count" and "scan" files, which allow to trigger count_objects() > and scan_objects() callbacks. For memcg-aware and numa-aware shrinkers > count_memcg, scan_memcg, count_node, scan_node, count_memcg_node > and scan_memcg_node are additionally provided. They allow to get per-memcg > and/or per-node object count and shrink only a specific memcg/node. > > To make debugging more pleasant, the patchset also names all shrinkers, > so that debugfs entries can have more meaningful names. > > v1: > 1) switched to debugfs, suggested by Mike, Andrew, Greg and others > 2) switched to seq_file API for output, no PAGE_SIZE limit anymore, by Andrew > 3) switched to down_read_killable(), suggested by Hillf > 4) dropped stateful filtering and "freed" returning, by Kent > 5) added docs, by Andrew Not quite true, gonna add it and also a cgroup tree inspection tool and send out v2. Thanks!