Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp33159ybf; Wed, 26 Feb 2020 08:20:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxwtREPlFv1tqDvbnJaD/TUZRhj7NUZFmW82CkNtMbVK7pQ/7VZf1zraAm9V00QVp/I3XBA X-Received: by 2002:a05:6808:4cc:: with SMTP id a12mr4008144oie.115.1582734008513; Wed, 26 Feb 2020 08:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582734008; cv=none; d=google.com; s=arc-20160816; b=fFfzb5NiDeNjypp0QvFtXQY396+E2cJVyxjyW1VR2myyJGp8qq0zTtM4H4trUb67EM D7jCKOwz9qXUL8ZQAn1SLFzg/lmWL7zx/NNw/v/sUmoS0cBO9S/QaKSXoPWrijFECmvq oPJ5HEzNHlZ0ILjQARf5SIpzDlG13tLLP/c6xrJRRbnbHPHQbne0LoNhlr//XVOEmtU9 gKgNSAKlLiA5hvAwfJ7e7udPTZi8PY4eptvmnsGrkCaqJQ5niGA/Dw0th8hpLYezvFGz ipndHDKbukxHFCVwbAA5aYFLs8qexEsMdTbI+HO8cebuRQRjTQphkKB0p45a1Kfrkl58 1aoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ywx1qIVqpeFVyk5FdbSzu1McnsKdZIvwvf+WZMVi7Zs=; b=cDCT1hADBpP3doac2X6ZrdcZGkfSHQPb8bWMC6QkAWYhNsoOeGR76fkuW1SaEja8Qf JXbXR2GbFRwm9Pe8w3d4y6cfNKKcjVNYKfJWuFI8WbHur52vLjFHN87DbErB60AO9VEN YbjvI5Zc+iG9S8Kgg5HL7CSbMmNCxjLlhmJUxeAqucQUrOS9xjDWLEL+ahH1mIjEmNmQ Qdxwv+GDiZrwnSBzrHKMCIz1GdkdbtPMKgTheXexswzIlYiwtYs1X/wibRvhLwgq2qOB 7lyZcJbGiPaMJ6i7URlG8bKQcmthnhr4Mv/8pqIVLf3vK+E4ZnXntKSXUqvD/9V4X5Ne +fzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gpYsbsRZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si45152otn.12.2020.02.26.08.19.56; Wed, 26 Feb 2020 08:20:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gpYsbsRZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbgBZQP7 (ORCPT + 99 others); Wed, 26 Feb 2020 11:15:59 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50341 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728736AbgBZQP5 (ORCPT ); Wed, 26 Feb 2020 11:15:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582733757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=ywx1qIVqpeFVyk5FdbSzu1McnsKdZIvwvf+WZMVi7Zs=; b=gpYsbsRZEKnhyGP3Xfsrec2yH0Iw2PhJcJTqje4Hh2WLV1W0g15YJsIN3AowKCLeoJK3tg cVIq7ksyGbvvdjDuuua5QJEbp6/Nm9PlNtIFt06nLc8kpjXZuohblmW8Hqe3YcPFNG8JN7 aj7vnIrokk1aLSIpKy06afTFiqpCMPA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-K7C2TJKJPyaLBrctJLBKxQ-1; Wed, 26 Feb 2020 11:15:53 -0500 X-MC-Unique: K7C2TJKJPyaLBrctJLBKxQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3873F800D6C; Wed, 26 Feb 2020 16:15:51 +0000 (UTC) Received: from llong.com (dhcp-17-59.bos.redhat.com [10.18.17.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFD6F60BE1; Wed, 26 Feb 2020 16:15:47 +0000 (UTC) From: Waiman Long To: Alexander Viro , Jonathan Corbet , Luis Chamberlain , Kees Cook , Iurii Zaikin Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Mauro Carvalho Chehab , Eric Biggers , Dave Chinner , Eric Sandeen , Waiman Long Subject: [PATCH 11/11] fs/dcache: Track # of negative dentries reclaimed & killed Date: Wed, 26 Feb 2020 11:14:04 -0500 Message-Id: <20200226161404.14136-12-longman@redhat.com> In-Reply-To: <20200226161404.14136-1-longman@redhat.com> References: <20200226161404.14136-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The negative dentry reclaim process gave no visible indication that it was being activated. In order to allow system administrator to see if it is being activated as expected, two new debugfs variables "negative_dentry_reclaimed" and "negative_dentry_killed" are now added to report the total number of negative dentries that have been reclaimed and killed. These debugfs variables are only added after the negative dentry reclaim mechanism is activated for the first time. In reality, the actual number may be slightly less than the reported number as not all the negative dentries passed to shrink_dentry_list() and __dentry_kill() can be successfully reclaimed. Signed-off-by: Waiman Long --- fs/dcache.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index fe48e00349c9..471b51316506 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "internal.h" #include "mount.h" @@ -136,6 +137,8 @@ static DEFINE_PER_CPU(long, nr_dentry_negative); int dcache_dentry_dir_max_sysctl; EXPORT_SYMBOL_GPL(dcache_dentry_dir_max_sysctl); static int negative_dentry_dir_max __read_mostly; +static unsigned long negative_dentry_reclaim_count; +static atomic_t negative_dentry_kill_count; #define DENTRY_DIR_MAX_MIN 0x100 static LLIST_HEAD(negative_reclaim_list); @@ -204,6 +207,7 @@ int proc_dcache_dentry_dir_max(struct ctl_table *ctl, int write, { int old = dcache_dentry_dir_max_sysctl; int ret; + static bool debugfs_file_created; ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); @@ -219,6 +223,14 @@ int proc_dcache_dentry_dir_max(struct ctl_table *ctl, int write, return -EINVAL; } + if (!debugfs_file_created) { + debugfs_create_ulong("negative_dentry_reclaimed", 0400, NULL, + &negative_dentry_reclaim_count); + debugfs_create_u32("negative_dentry_killed", 0400, NULL, + (u32 *)&negative_dentry_kill_count.counter); + debugfs_file_created = true; + } + negative_dentry_dir_max = dcache_dentry_dir_max_sysctl; if (!old && dcache_dentry_dir_max_sysctl) static_branch_enable(&negative_reclaim_enable); @@ -1542,6 +1554,8 @@ static void negative_reclaim_workfn(struct work_struct *work) kfree(dentry_node); cond_resched(); } + if (quota < MAX_DENTRY_RECLAIM) + negative_dentry_reclaim_count += MAX_DENTRY_RECLAIM - quota; } /* @@ -1609,6 +1623,7 @@ static void negative_reclaim_check(struct dentry *parent, struct dentry *child) rcu_read_unlock(); __dentry_kill(child); dput(parent); + atomic_inc(&negative_dentry_kill_count); return; } spin_unlock(&child->d_lock); -- 2.18.1