From patchwork Sat Aug 24 19:10:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13776500 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 17AF9C52D6F for ; Sat, 24 Aug 2024 19:10:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65FCC800F3; Sat, 24 Aug 2024 15:10:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC74800F0; Sat, 24 Aug 2024 15:10:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43C72800F3; Sat, 24 Aug 2024 15:10:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1AF92800F0 for ; Sat, 24 Aug 2024 15:10:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C1055C082E for ; Sat, 24 Aug 2024 19:10:39 +0000 (UTC) X-FDA: 82488080598.22.54B2568 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) by imf16.hostedemail.com (Postfix) with ESMTP id 14678180004 for ; Sat, 24 Aug 2024 19:10:37 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="HCl/LWmJ"; spf=pass (imf16.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724526596; a=rsa-sha256; cv=none; b=dfALT4woa6M61mgKphMN4Q+pb91n93slHvPZpV7jFE7jp6fe8UQ8wBlT+ehDYodxpJVytX Gh/wOc6XxGqC4Uqi2n5alDsSiSt/2XwWZsaFipO+d6YZghbhkrZau2AtW+fOXSyT7rZwHT N2x+dAmBqdKa1mvudly57rZCrGib3Ec= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="HCl/LWmJ"; spf=pass (imf16.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724526596; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lIF02eH9k6dm0NzZMiixaw+oq+xhVtrthbaRSnodZvc=; b=HyVnJRq4hkJG9SgjXPQf99hzQ0l6R4StxYDcSHGyiNN2r430QBmoVOufKNEsEQWmRrNusC TV/vgElnDbzhhfciGok+8a/x1qK/+f0CDmykmhoiPwJbKyyxLvef9T6L7aBdcpsva42LQG 2OtRm/t73LqnMlXUZyTpXM8Bebpadns= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724526636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lIF02eH9k6dm0NzZMiixaw+oq+xhVtrthbaRSnodZvc=; b=HCl/LWmJbPvVzwn/ZY3aUrgi1pxURTXeresHi0kDKfH12r0Dn81Qxcx3IsFaNWZka7CS+a 4lRwMz2Qw5uIGa50IsWt9GUBstO5XMK+fyTy8fJ936oYKvxsHAuvebZUw7S4f0ovBdErkx loDj/C2bOYdsxcPpgzTpsvnBl5Mn7rQ= From: Kent Overstreet To: david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Kent Overstreet , Alexander Viro , Christian Brauner Subject: [PATCH 09/10] fs/dcache: Add per-sb accounting for nr dentries Date: Sat, 24 Aug 2024 15:10:16 -0400 Message-ID: <20240824191020.3170516-10-kent.overstreet@linux.dev> In-Reply-To: <20240824191020.3170516-1-kent.overstreet@linux.dev> References: <20240824191020.3170516-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: zfxacbu7mytoyyog6c7bz7qdf6ghbrsx X-Rspamd-Queue-Id: 14678180004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724526637-671858 X-HE-Meta: U2FsdGVkX18/z4/2iBlaPdIw8kChmcRFQsolWC0kUKkIfWTZHH+pEQLz4X3Gqe1V4W9BSh+VY+ycuRB6ch2Hc14gWFM5wzCMYN1ef08h9IYxkQoVxhw25S36RdGoAmj27m5QXv+4R/JhMGhGzBDGp5edYeLC4PbXpi5r/jD7/4UPs1O2IRinqEtuEskEe+lIJTyntJ8dRo/c+ka0KwRv/RYD1GYnxd6EFOmqbFjTBQXGhifnN31BcICpxfmcLrKSEWb8CqElCEGKTz/blmFoXCZ3bqd+/DQgSum90ilk8QeDQYfceJra6GJUjXGf9IfYAEz4nwKJKWfHWaUfduMeW3Amkh5f30VgQyTNN2gFEZAM+01M7Iaqh1uO9K/oFOq5xz3d9PrTTUzNrG3xMXb40vt2a+L7PXSLH23OS4Q1E89ukCg11szgHD/fbMLIxGeTOCcFUmskS/TUrp1yn+CPgPlHLZG//4uds10SlZHop4T+dj1lRjvN918u8lA1chCu5P3CCiQ5UHStFY7WnL157cuH+0EhfnxxftBhyuUn9kTVeGzALtN31Pg9bSt1CL0hocioRD+/OSUb5Ca1PY3QXYp7vqGzGeVPvq0KDct8kd2CQzWLlCjDTHOw9YP3L0m+KbBR0lXluXUcOD0aVIUH2/l92iDP7ydUiWl1MhM+HdpLMhuZWKabphs1cqlWnE57Gkzrjh1FXGgZ6plRdI0w3UTnYJOyZriF89ueKgHi8B4pokTdpOZPvcJsVDR4u0iszcz1f1oZJJBSE9EhmYfXK8Vk0yulT8CbdQ4K2s/sTPB1OPB4mJT2/gkKNmcth0U1Xqx37hiLdaLTjvblM7/Yg3PeGnIXxEkCN7m3uVxdugtRQ+yskALedlDrXFnXxQN+P0U9S56ih8ey7Y31WTypdqMx5X6CwmWtrdsaZUn7Zku6X2rPONlS6hdZy62sKf6hzyTcsd59+jGH9uPwLdn BMOjWx9k vTZF2Rmns5N/9NTlzjEUswO7gB9pUvacW406vqLVHwCfpX1VQWJxnKZfbE0NVpXLms+wiO08Q4YweKVDYmf4EzZQqaCaQYUhiU2BlEecsw+t+iXi7TQmcmRtkDDyHvanrrQSDp7HdTWdj5eUxe0aSWr6DlG/13CF1HxcvBonSt6qeAJ5UguMgE9NGcihRHGLZSdKDrAyjgObykupQTN7sra9bG0Xe2X0kf/5QoFfxKOfczbjWn79Jgx6QzHESezbAgG3mTI7+urMqe87li/P/ks1joQ== 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: List-Subscribe: List-Unsubscribe: Like the previous patch, add a counter for total dentries, so we can print total vs. reclaimable. Cc: Alexander Viro Cc: Christian Brauner Cc: Dave Chinner Signed-off-by: Kent Overstreet --- fs/dcache.c | 2 ++ fs/super.c | 6 ++++++ include/linux/fs.h | 1 + 3 files changed, 9 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 64108cbd52f6..4bbb2c87f824 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -601,6 +601,7 @@ static struct dentry *__dentry_kill(struct dentry *dentry) else spin_unlock(&dentry->d_lock); this_cpu_dec(nr_dentry); + this_cpu_dec(*dentry->d_sb->s_dentry_nr); if (dentry->d_op && dentry->d_op->d_release) dentry->d_op->d_release(dentry); @@ -1683,6 +1684,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) } this_cpu_inc(nr_dentry); + this_cpu_inc(*sb->s_dentry_nr); return dentry; } diff --git a/fs/super.c b/fs/super.c index b1b6ae491b6c..5b0fea6ff1cd 100644 --- a/fs/super.c +++ b/fs/super.c @@ -278,6 +278,7 @@ static void destroy_super_work(struct work_struct *work) security_sb_free(s); put_user_ns(s->s_user_ns); kfree(s->s_subtype); + free_percpu(s->s_dentry_nr); free_percpu(s->s_inodes_nr); for (int i = 0; i < SB_FREEZE_LEVELS; i++) percpu_free_rwsem(&s->s_writers.rw_sem[i]); @@ -299,6 +300,7 @@ static void destroy_unused_super(struct super_block *s) super_unlock_excl(s); list_lru_destroy(&s->s_dentry_lru); list_lru_destroy(&s->s_inode_lru); + free_percpu(s->s_dentry_nr); free_percpu(s->s_inodes_nr); shrinker_free(s->s_shrink); /* no delays needed */ @@ -381,6 +383,10 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, if (!s->s_inodes_nr) goto fail; + s->s_dentry_nr = alloc_percpu(size_t); + if (!s->s_dentry_nr) + goto fail; + s->s_shrink = shrinker_alloc(SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, "sb-%s", type->name); if (!s->s_shrink) diff --git a/include/linux/fs.h b/include/linux/fs.h index 86636831b9d0..493fb8e72bf0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1332,6 +1332,7 @@ struct super_block { * There is no need to put them into separate cachelines. */ struct list_lru s_dentry_lru; + size_t __percpu *s_dentry_nr; struct list_lru s_inode_lru; struct rcu_head rcu; struct work_struct destroy_work;