Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp773010imw; Fri, 8 Jul 2022 11:24:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uz87UBC3qVhZ7r9+zPyL0Cv++Ef3r/gjfLwfv/8xHgV8yXLke8wTUZoawY/CggS6fyR7Kr X-Received: by 2002:a17:902:e844:b0:16c:3024:69a5 with SMTP id t4-20020a170902e84400b0016c302469a5mr124259plg.125.1657304686023; Fri, 08 Jul 2022 11:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657304686; cv=none; d=google.com; s=arc-20160816; b=X5j+LdniEo54v3w5cN5hZ48aZBnPEZVXhUwiri+sZbiGrcITJFn5BHVWGR4/TZZaZl 2ssi6JYPlqBH9tkxBokXTgczu7xBozYttfNjJf6yKC8VWgnbzNNwRMtLeA2tTCgB4MnY pQSmoog0JImAWRuvJQR/dLAraxk+fosn26ec1rUYAe7tAlKu5a5GiFsU7wbdFVepmi0n c/YXY3wLTgTkrg8i0FG6mXZeMfl4AbWlBhJvl63BI9jPI50lCKjzH2mnte8lnRjcYVUz Or9x8x2OS/TegmvAyWa+EECoxBHFclEFK58ukIxPWT/kkV6qtQ99mRyE+CIKhHFvJZKJ mg0Q== 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=fGXNQ6eBftp8VGzEJyI5XqlIAoKLtI5YVzJKBnzNIxY=; b=AIuKxPy/zt9OO3dtIqWUBKXIFS2drP+FR/f89qdO1KEdq1obMkY1+N3Dz06/cmYJpc sxbLtrMYq1QTyWt6bowCBC1AWfOUH+cVpisc9GyrSaXf+U2RBX0FZMs6UXzHwjHRF+yV w2VkTgdRcWH2hV5CooBec9Y6FJopb3IiQNBCFfblS+filbr8DINhaIiKgG9Ke6AKJWDb 2L3ieJp9uQku383erPWrKgnem6RdtoB1K+SvxQ2+nEot+Du1nBXk9bRvmdQ/XkQFJuBH a52QaZTs70Ysuht05qsicX0v9xnSpdCvQ3L8CaOvUsjS7f7sXC6JHUmvjwhd7DJTr00R G9VQ== 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 x4-20020a1709028ec400b0016bd9a8f03csi22225457plo.147.2022.07.08.11.24.33; Fri, 08 Jul 2022 11:24:46 -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 S239211AbiGHSYI (ORCPT + 99 others); Fri, 8 Jul 2022 14:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239493AbiGHSYC (ORCPT ); Fri, 8 Jul 2022 14:24:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845FA5596; Fri, 8 Jul 2022 11:24: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 15E6962474; Fri, 8 Jul 2022 18:24:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19A18C341C0; Fri, 8 Jul 2022 18:24:00 +0000 (UTC) Subject: [PATCH v3 03/32] 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, jlayton@redhat.com, tgraf@suug.ch Date: Fri, 08 Jul 2022 14:23:59 -0400 Message-ID: <165730463905.28142.7461176455073261110.stgit@klimt.1015granger.net> In-Reply-To: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> References: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index a0234d194ec1..3359df6c7ac0 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,9 @@ 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 lru = 0, hits = 0; + unsigned long lru = 0; /* * No need for spinlocks here since we're not terribly interested in @@ -1085,13 +1089,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", lru); seq_printf(m, "cache hits: %lu\n", hits); + seq_printf(m, "acquisitions: %lu\n", acquisitions); return 0; }