Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3088279pxb; Mon, 18 Oct 2021 08:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwobuT5HSVVptzhfbCPuq8FxZH1ZZt6NjtDwzovChoFu3CfSnMzWPyJXdc6jSUu+g45DAQx X-Received: by 2002:a17:90b:1c02:: with SMTP id oc2mr34345488pjb.52.1634569319572; Mon, 18 Oct 2021 08:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569319; cv=none; d=google.com; s=arc-20160816; b=CjL9IDizJJan9JHtysJUyLPW57aQCWgVcE6RV1eWqRRWF1bByGIwA3iU0C2Rey/qiy ecDKW3NntGQCeTI6ghtcrmV9D7UeQM5dcc4dZtFdYXfgWx1+Si4kcQDagn2AMetsuD+J fv4ZYib2yOAwFcmqQMFbvPsQvWCyyVZg6Ro9GtAQxQWZkfWf6GSfU4mnAg9zxUPjnsUu kL4kmqoXgl65ocGra3n9XTAP6c3JUVVSWgSuDtj7cwRDYZ0KQDpZ+5l75+gA4saJwQoI 6S5sVoFjBJG11XBvf0o6Q8Sw1oQNgRKUNnt6VP9NgcTdbQc6B3DMUjMGSKWWz2si2FBP F4Hg== 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:organization:dkim-signature; bh=G0Z0o/WV3mIg+DEa6x5tVtljedfdYDVPKK/rSOm0vTU=; b=aex3ETKnker4+GqYbJ8t5/uu3K6JwQD9frTgc4edl0GHjgIfG3O+R/KWqsgN0bsEOs XypqJo27qtXUAxtSu0+twz4T0d/If5gDgLxaucMdgRyln1Cpv8X6aioiOuNlSKtSPARU Dwy6dWz9SevUCqhSAeTbXW/c6XhzVcqAx4yw8FGXaPO73mm5Gt0JPSry3PXNFQQ7HWYN mpz+buUn6g7HEAuo6DohlYkV+79+Y2s09NZMOQAdlzPzgf1njgjdWfdLPXnuaVHGaERc GTA+ENCDF0mijshgIQH9t8MAnl0WasvEsruXejU9Y6CSd1v24+0/O9D1zPXGWdIeL1A5 7hiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R3iuuL71; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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. [23.128.96.18]) by mx.google.com with ESMTP id u3si20340128plq.96.2021.10.18.08.01.21; Mon, 18 Oct 2021 08:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R3iuuL71; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 S233041AbhJRPCf (ORCPT + 99 others); Mon, 18 Oct 2021 11:02:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21926 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbhJRPCb (ORCPT ); Mon, 18 Oct 2021 11:02:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634569219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G0Z0o/WV3mIg+DEa6x5tVtljedfdYDVPKK/rSOm0vTU=; b=R3iuuL71S6ECQBK/yPIWbRxHnGC9RpY67m1NiOEP1EBUjlayH9gClnpEkgW7ICgMhID9yn n7RwjGhOxbu9fDqzErwSiioLcgzkzoczI6g8askhosCl+k3OznqyBHefeNDhiJpiEkknt9 ts8NgBPtd+0UoAs3CPuK0e1Mu9mOcRE= 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-476-OVp8rcT5NZiDCc86yQYTJQ-1; Mon, 18 Oct 2021 11:00:16 -0400 X-MC-Unique: OVp8rcT5NZiDCc86yQYTJQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D19A802682; Mon, 18 Oct 2021 15:00:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 511675D6D7; Mon, 18 Oct 2021 15:00:08 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 36/67] fscache: Add stats for the cookie commit LRU From: David Howells To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 18 Oct 2021 16:00:07 +0100 Message-ID: <163456920740.2614702.10833323576114946075.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add some stats to indicate the state of the cookie commit LRU, including an indication of how many are currently on it, how many have been expired, removed (withdrawn/reused) or dropped (relinquished) from it and how long till the next reap happens. Signed-off-by: David Howells --- fs/fscache/cookie.c | 10 +++++++++- fs/fscache/internal.h | 5 +++++ fs/fscache/stats.c | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c index dfc61b2e105d..c6b553609f33 100644 --- a/fs/fscache/cookie.c +++ b/fs/fscache/cookie.c @@ -28,7 +28,7 @@ static LIST_HEAD(fscache_cookies); static DEFINE_RWLOCK(fscache_cookies_lock); static LIST_HEAD(fscache_cookie_lru); static DEFINE_SPINLOCK(fscache_cookie_lru_lock); -static DEFINE_TIMER(fscache_cookie_lru_timer, fscache_cookie_lru_timed_out); +DEFINE_TIMER(fscache_cookie_lru_timer, fscache_cookie_lru_timed_out); static DECLARE_WORK(fscache_cookie_lru_work, fscache_cookie_lru_worker); static const char fscache_cookie_stages[FSCACHE_COOKIE_STAGE__NR] = "-LCAIFMWRD"; unsigned int fscache_lru_cookie_timeout = 10 * HZ; @@ -60,6 +60,8 @@ static void fscache_free_cookie(struct fscache_cookie *cookie) spin_lock(&fscache_cookie_lru_lock); list_del_init(&cookie->commit_link); spin_unlock(&fscache_cookie_lru_lock); + fscache_stat_d(&fscache_n_cookies_lru); + fscache_stat(&fscache_n_cookies_lru_removed); } write_lock(&fscache_cookies_lock); list_del(&cookie->proc_link); @@ -525,6 +527,7 @@ void __fscache_unuse_cookie(struct fscache_cookie *cookie, if (list_empty(&cookie->commit_link)) { fscache_get_cookie(cookie, fscache_cookie_get_lru); list_move_tail(&cookie->commit_link, &fscache_cookie_lru); + fscache_stat(&fscache_n_cookies_lru); } spin_unlock(&fscache_cookie_lru_lock); timer_reduce(&fscache_cookie_lru_timer, @@ -624,10 +627,12 @@ static void fscache_cookie_lru_do_one(struct fscache_cookie *cookie) time_before(jiffies, cookie->unused_at + fscache_lru_cookie_timeout) || atomic_read(&cookie->n_active) > 0) { spin_unlock(&cookie->lock); + fscache_stat(&fscache_n_cookies_lru_removed); } else { __fscache_set_cookie_stage(cookie, FSCACHE_COOKIE_STAGE_COMMITTING); set_bit(FSCACHE_COOKIE_DO_COMMIT, &cookie->flags); spin_unlock(&cookie->lock); + fscache_stat(&fscache_n_cookies_lru_expired); _debug("lru c=%x", cookie->debug_id); __fscache_withdraw_cookie(cookie); } @@ -652,6 +657,7 @@ static void fscache_cookie_lru_worker(struct work_struct *work) } list_del_init(&cookie->commit_link); + fscache_stat_d(&fscache_n_cookies_lru); spin_unlock(&fscache_cookie_lru_lock); fscache_cookie_lru_do_one(cookie); spin_lock(&fscache_cookie_lru_lock); @@ -673,6 +679,8 @@ static void fscache_cookie_drop_from_lru(struct fscache_cookie *cookie) spin_lock(&fscache_cookie_lru_lock); if (!list_empty(&cookie->commit_link)) { list_del_init(&cookie->commit_link); + fscache_stat_d(&fscache_n_cookies_lru); + fscache_stat(&fscache_n_cookies_lru_dropped); need_put = true; } spin_unlock(&fscache_cookie_lru_lock); diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h index f74f7bdea633..62e6a5bbef8e 100644 --- a/fs/fscache/internal.h +++ b/fs/fscache/internal.h @@ -32,6 +32,7 @@ struct fscache_cache *fscache_lookup_cache(const char *name, bool is_cache); */ extern struct kmem_cache *fscache_cookie_jar; extern const struct seq_operations fscache_cookies_seq_ops; +extern struct timer_list fscache_cookie_lru_timer; extern void fscache_print_cookie(struct fscache_cookie *cookie, char prefix); extern bool fscache_begin_cookie_access(struct fscache_cookie *cookie, @@ -70,6 +71,10 @@ extern atomic_t fscache_n_volumes; extern atomic_t fscache_n_volumes_collision; extern atomic_t fscache_n_volumes_nomem; extern atomic_t fscache_n_cookies; +extern atomic_t fscache_n_cookies_lru; +extern atomic_t fscache_n_cookies_lru_expired; +extern atomic_t fscache_n_cookies_lru_removed; +extern atomic_t fscache_n_cookies_lru_dropped; extern atomic_t fscache_n_retrievals; extern atomic_t fscache_n_retrievals_ok; diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c index 13e90b940bd2..5700e5712018 100644 --- a/fs/fscache/stats.c +++ b/fs/fscache/stats.c @@ -18,6 +18,10 @@ atomic_t fscache_n_volumes; atomic_t fscache_n_volumes_collision; atomic_t fscache_n_volumes_nomem; atomic_t fscache_n_cookies; +atomic_t fscache_n_cookies_lru; +atomic_t fscache_n_cookies_lru_expired; +atomic_t fscache_n_cookies_lru_removed; +atomic_t fscache_n_cookies_lru_dropped; atomic_t fscache_n_retrievals; atomic_t fscache_n_retrievals_ok; @@ -89,6 +93,14 @@ int fscache_stats_show(struct seq_file *m, void *v) atomic_read(&fscache_n_acquires_nobufs), atomic_read(&fscache_n_acquires_oom)); + seq_printf(m, "LRU : n=%u exp=%u rmv=%u drp=%u at=%ld\n", + atomic_read(&fscache_n_cookies_lru), + atomic_read(&fscache_n_cookies_lru_expired), + atomic_read(&fscache_n_cookies_lru_removed), + atomic_read(&fscache_n_cookies_lru_dropped), + timer_pending(&fscache_cookie_lru_timer) ? + fscache_cookie_lru_timer.expires - jiffies : 0); + seq_printf(m, "Invals : n=%u run=%u\n", atomic_read(&fscache_n_invalidates), atomic_read(&fscache_n_invalidates_run));