From patchwork Fri Jul 28 18:34:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 9869223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 327E66038F for ; Fri, 28 Jul 2017 18:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F296288BC for ; Fri, 28 Jul 2017 18:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 224C7288E2; Fri, 28 Jul 2017 18:35:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF0CF288BC for ; Fri, 28 Jul 2017 18:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623AbdG1Sf0 (ORCPT ); Fri, 28 Jul 2017 14:35:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752229AbdG1SfJ (ORCPT ); Fri, 28 Jul 2017 14:35:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE13AC034D02; Fri, 28 Jul 2017 18:35:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE13AC034D02 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=longman@redhat.com Received: from llong.com (dhcp-17-6.bos.redhat.com [10.18.17.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F05960317; Fri, 28 Jul 2017 18:35:07 +0000 (UTC) From: Waiman Long To: Alexander Viro , Jonathan Corbet Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Paul E. McKenney" , Andrew Morton , Ingo Molnar , Miklos Szeredi , Matthew Wilcox , Larry Woodman , James Bottomley , Waiman Long Subject: [PATCH v3 5/5] fs/dcache: Track count of negative dentries forcibly killed Date: Fri, 28 Jul 2017 14:34:40 -0400 Message-Id: <1501266880-26288-6-git-send-email-longman@redhat.com> In-Reply-To: <1501266880-26288-1-git-send-email-longman@redhat.com> References: <1501266880-26288-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Jul 2017 18:35:08 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is performance concern about killing recently created negative dentries. This should rarely happen under normal working condition. To understand the extent of how often this negative dentry killing is happening, the /proc/sys/fs/denty-state file is extended to track this number. This allows us to see if additional measures will be needed to reduce the chance of negative dentries killing. One possible measure is to increase the percentage of system memory allowed for negative dentries by adding or adjusting the "neg_dentry_pc=" parameter in the kernel boot command line. Signed-off-by: Waiman Long --- fs/dcache.c | 4 ++++ include/linux/dcache.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/dcache.c b/fs/dcache.c index 360185e..3796c3f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -145,6 +145,7 @@ struct dentry_stat_t dentry_stat = { long nfree; /* Negative dentry free pool */ struct super_block *prune_sb; /* Super_block for pruning */ int neg_count, prune_count; /* Pruning counts */ + atomic_long_t nr_neg_killed; /* # of negative entries killed */ } ndblk ____cacheline_aligned_in_smp; static void clear_prune_sb_for_umount(struct super_block *sb); @@ -204,6 +205,7 @@ int proc_nr_dentry(struct ctl_table *table, int write, void __user *buffer, dentry_stat.nr_dentry = get_nr_dentry(); dentry_stat.nr_unused = get_nr_dentry_unused(); dentry_stat.nr_negative = get_nr_dentry_neg(); + dentry_stat.nr_killed = atomic_long_read(&ndblk.nr_neg_killed); return proc_doulongvec_minmax(table, write, buffer, lenp, ppos); } #endif @@ -802,6 +804,7 @@ static struct dentry *dentry_kill(struct dentry *dentry) spin_unlock(&parent->d_lock); goto failed; } + atomic_long_inc(&ndblk.nr_neg_killed); } else if (unlikely(!spin_trylock(&parent->d_lock))) { if (inode) @@ -3932,6 +3935,7 @@ static void __init neg_dentry_init(void) raw_spin_lock_init(&ndblk.nfree_lock); spin_lock_init(&ndblk.prune_lock); + atomic_long_set(&ndblk.nr_neg_killed, 0); /* 20% in global pool & 80% in percpu free */ ndblk.nfree = neg_dentry_nfree_init diff --git a/include/linux/dcache.h b/include/linux/dcache.h index e42c8fc..227ed83 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -66,7 +66,7 @@ struct dentry_stat_t { long age_limit; /* age in seconds */ long want_pages; /* pages requested by system */ long nr_negative; /* # of negative dentries */ - long dummy; + long nr_killed; /* # of negative dentries killed */ }; extern struct dentry_stat_t dentry_stat;