Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp773160imw; Fri, 8 Jul 2022 11:24:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjcTVuBf9T0rnlpYJ9Wur2sPxLdixvNiKDJQo4y7p6JBYlRybdH6eSqmjJsqQU+xwBF6ug X-Received: by 2002:a17:903:11d2:b0:167:8a0f:8d4b with SMTP id q18-20020a17090311d200b001678a0f8d4bmr4876278plh.78.1657304695759; Fri, 08 Jul 2022 11:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657304695; cv=none; d=google.com; s=arc-20160816; b=FH95d208AjhrJ3sXyewol4XyDoA/Xd1F5Q1EMRu9A5kpkHOkVsH0F6/ehAfwspf5wa bM0hsHD/uswLfPIHH7zq4fsSybqepUGAHfTX1bR6Qy45n6144eKCRurX3up7hCJ9mYlZ zI6uGLSfR6+/8kwcUopHg1vgUz90PqN5pDS1mxHWi1IXwlciHY+GKvLXCu0+znJZHuHV eNkIxGKfg+XKMd5nmIEOnZe/xAtN8yl+l9Ywf+dk/fHa75/18NQt1fKEWNyFpEy8sFPp Gn9q5mANOCZMGzvEbDZH4WSkFvwwnIY6ayjMYB+FqO0b4ujWPuLuFD9wxGuBRcAvsd6J mpTQ== 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=rklvVuxFFZxbKtZtPsjAqgKundDs5Ayma6MUIbryPnI=; b=Bvt/k2ozqiSoQnEPi6loNeZWCVexVGdk8Jze5qIrQLCi1YtdocA6BZTfp3MAAwnzV7 ZqtZ8L5ctH4uVbTMP38VqFWHFPxv67U26Ce03pdS04CZeGRNvCF/NyX1hweMFQYT6Jx8 4eANxyDam8cp4Pogx/MssrjGHfxFGroU+Yg+PI0FhF4ItEqwZNdHs6+jcYGQjltlyzO5 BltH7vwznAfLrpjQPwLCAlvyUTdGvcWBkG19GM3RmAY7/wO3Nxj/OTsITBVo9SVvbA14 nVJ+xKIvetD5sF8eHvO/Tnp8xmsTXVzcdjqyl4cCt0g1Ve6ZOXarLTYsf+ecP9ZPVi4Q jhYg== 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 s11-20020a170902ea0b00b00163fe7e3925si43042279plg.290.2022.07.08.11.24.44; Fri, 08 Jul 2022 11:24:55 -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 S238719AbiGHSYQ (ORCPT + 99 others); Fri, 8 Jul 2022 14:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239396AbiGHSYP (ORCPT ); Fri, 8 Jul 2022 14:24:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787656599; Fri, 8 Jul 2022 11:24:14 -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 0F34E62474; Fri, 8 Jul 2022 18:24:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27214C341C0; Fri, 8 Jul 2022 18:24:13 +0000 (UTC) Subject: [PATCH v3 05/32] NFSD: Report average age of filecache items 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:24:12 -0400 Message-ID: <165730465222.28142.1251665158880105631.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 This is a measure of how long items stay in the filecache, to help assess how efficient the cache is. Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 11 ++++++++++- fs/nfsd/filecache.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index c28e9577837d..da48c51a2bf0 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -45,6 +45,7 @@ struct nfsd_fcache_bucket { static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits); static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions); static DEFINE_PER_CPU(unsigned long, nfsd_file_releases); +static DEFINE_PER_CPU(unsigned long, nfsd_file_total_age); struct nfsd_fcache_disposal { struct work_struct work; @@ -178,6 +179,7 @@ nfsd_file_alloc(struct inode *inode, unsigned int may, unsigned int hashval, if (nf) { INIT_HLIST_NODE(&nf->nf_node); INIT_LIST_HEAD(&nf->nf_lru); + nf->nf_birthtime = ktime_get(); nf->nf_file = NULL; nf->nf_cred = get_current_cred(); nf->nf_net = net; @@ -201,9 +203,11 @@ nfsd_file_alloc(struct inode *inode, unsigned int may, unsigned int hashval, static bool nfsd_file_free(struct nfsd_file *nf) { + s64 age = ktime_to_ms(ktime_sub(ktime_get(), nf->nf_birthtime)); bool flush = false; this_cpu_inc(nfsd_file_releases); + this_cpu_add(nfsd_file_total_age, age); trace_nfsd_file_put_final(nf); if (nf->nf_mark) @@ -1075,7 +1079,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) { unsigned long hits = 0, acquisitions = 0, releases = 0; unsigned int i, count = 0, longest = 0; - unsigned long lru = 0; + unsigned long lru = 0, total_age = 0; /* * No need for spinlocks here since we're not terribly interested in @@ -1096,6 +1100,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) hits += per_cpu(nfsd_file_cache_hits, i); acquisitions += per_cpu(nfsd_file_acquisitions, i); releases += per_cpu(nfsd_file_releases, i); + total_age += per_cpu(nfsd_file_total_age, i); } seq_printf(m, "total entries: %u\n", count); @@ -1104,6 +1109,10 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) seq_printf(m, "cache hits: %lu\n", hits); seq_printf(m, "acquisitions: %lu\n", acquisitions); seq_printf(m, "releases: %lu\n", releases); + if (releases) + seq_printf(m, "mean age (ms): %ld\n", total_age / releases); + else + seq_printf(m, "mean age (ms): -\n"); return 0; } diff --git a/fs/nfsd/filecache.h b/fs/nfsd/filecache.h index 1da0c79a5580..d0c42619dc10 100644 --- a/fs/nfsd/filecache.h +++ b/fs/nfsd/filecache.h @@ -46,6 +46,7 @@ struct nfsd_file { refcount_t nf_ref; unsigned char nf_may; struct nfsd_file_mark *nf_mark; + ktime_t nf_birthtime; }; int nfsd_file_cache_init(void);