Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4861291iog; Wed, 22 Jun 2022 07:14:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vQIKUeCGl387ixwBsQcYSrVjcOYDkzOpUpHlhgz8bMZUV8Jsrqo5MjX564gd+k2CuSRjtB X-Received: by 2002:a17:906:6a1a:b0:711:ec13:b7bc with SMTP id qw26-20020a1709066a1a00b00711ec13b7bcmr3354060ejc.688.1655907277390; Wed, 22 Jun 2022 07:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655907277; cv=none; d=google.com; s=arc-20160816; b=OfYQNHV9FWebvtLiyMEMWKbAEP1oLaJdMvWviLnVfkHCtM+iQi8tP7YezpErtoA02h YscPL4e7kzVek6fnfxYI7/+dDKpYXRX0qDgC43kmzedKIeqdahZ1yD9p/yLlAO52bzRZ bUWMuqmCY82D3/VYY9aYGgtKaVXjqD/B8eW45FEbtPX+xOlrvpBHvafORp+LSfvP/1KH W4zTXVokzKOgOd2OATaYPsAvSIv26ssaHK8dkRfbvGPqh307DOzZCJ9SZeszVuEF5LJ3 i0stQWF0zPiTP3Ek/p4bEZPV0f24BJ6SjGwOSgzo70owHKjCtprA+osfT+qMqtYvltz4 I4eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=fAoGTeNvmkHIazyk7k6+IUs9kBx+Yl8qkAsehqjlcSs=; b=CWaJGlklE2dYUaT+0zLEYb0RY7mZbx7aNpf8kSQQAbDFruXF1YgwYHDj1kLPWDrGXJ hU7WFp4iCcKHIj0t7kzGcbRGH9JCBg3fMkxBFCQRUfX+AFXkRCL6yV8JT4ME8EoscJ9h XI23zDjAahEMBDBGkCzTwmBYZ0o5j25JDs16Yjg2SXRk2c2IkUIflWbLGyBmKgCcTBoO PnY+AHty7iw4hBdMiL/E9TzFw9U13IrRNpSkFfOhEX+fRQbgZ4qDuIoqSIwiA5jObaWc yzHM2iM61bSf65xTmI6HVSvPC6GGcpK6lnzNwtlEx8qjFTva510NYzFk4EspfHu2gm2u 7h0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dx26-20020a170906a85a00b00711cdee84a5si1885917ejb.570.2022.06.22.07.14.11; Wed, 22 Jun 2022 07:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358058AbiFVONS (ORCPT + 99 others); Wed, 22 Jun 2022 10:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358049AbiFVONK (ORCPT ); Wed, 22 Jun 2022 10:13:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA448559C; Wed, 22 Jun 2022 07:13:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46F0F61BC2; Wed, 22 Jun 2022 14:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B246C341C0; Wed, 22 Jun 2022 14:13:00 +0000 (UTC) Subject: [PATCH RFC 02/30] NFSD: Report count of calls to nfsd_file_acquire() From: Chuck Lever To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: david@fromorbit.com, tgraf@suug.ch, jlayton@redhat.com Date: Wed, 22 Jun 2022 10:12:59 -0400 Message-ID: <165590717916.75778.4135678773284445735.stgit@manet.1015granger.net> In-Reply-To: <165590626293.75778.9843437418112335153.stgit@manet.1015granger.net> References: <165590626293.75778.9843437418112335153.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Count the number of successful acquisitions that did not create a file (ie, acquisitions that do not result in a compulsory cache miss). This count can be compared directly with the reported hit count to compute a hit ratio. Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 932db96f854a..128e8934f12a 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -43,6 +43,7 @@ struct nfsd_fcache_bucket { }; static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits); +static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions); struct nfsd_fcache_disposal { struct work_struct work; @@ -975,6 +976,8 @@ nfsd_do_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, } out: if (status == nfs_ok) { + if (open) + this_cpu_inc(nfsd_file_acquisitions); *pnf = nf; } else { nfsd_file_put(nf); @@ -1067,8 +1070,8 @@ nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp, */ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) { + unsigned long hits = 0, acquisitions = 0; unsigned int i, count = 0, longest = 0; - unsigned long hits = 0; /* * No need for spinlocks here since we're not terribly interested in @@ -1084,13 +1087,16 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) } mutex_unlock(&nfsd_mutex); - for_each_possible_cpu(i) + for_each_possible_cpu(i) { hits += per_cpu(nfsd_file_cache_hits, i); + acquisitions += per_cpu(nfsd_file_acquisitions, i); + } seq_printf(m, "total entries: %u\n", count); seq_printf(m, "longest chain: %u\n", longest); seq_printf(m, "lru entries: %lu\n", list_lru_count(&nfsd_file_lru)); seq_printf(m, "cache hits: %lu\n", hits); + seq_printf(m, "acquisitions: %lu\n", acquisitions); return 0; }