From: Max Kellermann <max.kellermann@ionos.com>
To: David Howells <dhowells@redhat.com>, Paulo Alcantara <pc@manguebit.org>
Cc: Max Kellermann <max.kellermann@ionos.com>,
netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] fscache: make the procfs cookie listing optional
Date: Wed, 11 Nov 2026 16:45:00 +0100 [thread overview]
Message-ID: <20261111154504.1314170-1-max.kellermann@ionos.com> (raw)
Add FSCACHE_COOKIE_PROC, enabled by default, to omit the diagnostic
cookie list and its maintenance when not needed. Caching and counters
are unaffected. Disabling it reduces the size of the struct by 16
bytes.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/netfs/Kconfig | 10 ++++++++++
fs/netfs/fscache_cookie.c | 8 +++++++-
fs/netfs/fscache_proc.c | 2 ++
fs/netfs/internal.h | 2 ++
include/linux/fscache.h | 2 ++
5 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/fs/netfs/Kconfig b/fs/netfs/Kconfig
index d0e7b0971fa3..881b081e3a52 100644
--- a/fs/netfs/Kconfig
+++ b/fs/netfs/Kconfig
@@ -44,6 +44,16 @@ config FSCACHE
See Documentation/filesystems/caching/fscache.rst for more information.
+config FSCACHE_COOKIE_PROC
+ bool "List FS-Cache cookies in procfs"
+ depends on FSCACHE && PROC_FS
+ default y
+ help
+ Provide the diagnostic /proc/fs/netfs/cookies listing (also
+ available through /proc/fs/fscache/cookies). Disabling this saves
+ two pointers per cookie and avoids maintaining the global list.
+ Caching and statistics remain available.
+
config FSCACHE_STATS
bool "Gather statistical information on local caching"
depends on FSCACHE && PROC_FS
diff --git a/fs/netfs/fscache_cookie.c b/fs/netfs/fscache_cookie.c
index 5a226f9cbdea..fe0832ec2056 100644
--- a/fs/netfs/fscache_cookie.c
+++ b/fs/netfs/fscache_cookie.c
@@ -23,8 +23,10 @@ static void fscache_perform_invalidation(struct fscache_cookie *cookie);
#define fscache_cookie_hash_shift 15
static struct hlist_bl_head fscache_cookie_hash[1 << fscache_cookie_hash_shift];
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
static LIST_HEAD(fscache_cookies);
static DEFINE_RWLOCK(fscache_cookies_lock);
+#endif
static LIST_HEAD(fscache_cookie_lru);
static DEFINE_SPINLOCK(fscache_cookie_lru_lock);
DEFINE_TIMER(fscache_cookie_lru_timer, fscache_cookie_lru_timed_out);
@@ -68,9 +70,11 @@ static void fscache_free_cookie(struct fscache_cookie *cookie)
return;
}
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
write_lock(&fscache_cookies_lock);
list_del(&cookie->proc_link);
write_unlock(&fscache_cookies_lock);
+#endif
if (cookie->aux_len > sizeof(cookie->inline_aux))
kfree(cookie->aux);
if (cookie->key_len > sizeof(cookie->inline_key))
@@ -363,9 +367,11 @@ static struct fscache_cookie *fscache_alloc_cookie(
INIT_WORK(&cookie->work, fscache_cookie_worker);
__fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_QUIESCENT);
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
write_lock(&fscache_cookies_lock);
list_add_tail(&cookie->proc_link, &fscache_cookies);
write_unlock(&fscache_cookies_lock);
+#endif
fscache_see_cookie(cookie, fscache_cookie_new_acquire);
return cookie;
@@ -1104,7 +1110,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie,
}
EXPORT_SYMBOL(__fscache_invalidate);
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
/*
* Generate a list of extant cookies in /proc/fs/fscache/cookies
*/
diff --git a/fs/netfs/fscache_proc.c b/fs/netfs/fscache_proc.c
index 874d951bc390..6ab23083cf01 100644
--- a/fs/netfs/fscache_proc.c
+++ b/fs/netfs/fscache_proc.c
@@ -27,9 +27,11 @@ int __init fscache_proc_init(void)
&fscache_volumes_seq_ops))
goto error;
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
if (!proc_create_seq("fs/netfs/cookies", S_IFREG | 0444, NULL,
&fscache_cookies_seq_ops))
goto error;
+#endif
return 0;
error:
diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h
index 6b583152132f..855fc47fbe6d 100644
--- a/fs/netfs/internal.h
+++ b/fs/netfs/internal.h
@@ -406,8 +406,10 @@ static inline bool fscache_set_cache_state_maybe(struct fscache_cache *cache,
*/
extern struct kmem_cache *fscache_cookie_jar;
#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
extern const struct seq_operations fscache_cookies_seq_ops;
#endif
+#endif
extern struct timer_list fscache_cookie_lru_timer;
extern void fscache_print_cookie(struct fscache_cookie *cookie, char prefix);
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index ecd14d645690..b4aedcfb5945 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -109,7 +109,9 @@ struct fscache_cookie {
struct fscache_volume *volume; /* Parent volume of this file. */
void *cache_priv; /* Cache-side representation */
struct hlist_bl_node hash_link; /* Link in hash table */
+#ifdef CONFIG_FSCACHE_COOKIE_PROC
struct list_head proc_link; /* Link in proc list */
+#endif
struct list_head commit_link; /* Link in commit queue */
struct work_struct work; /* Commit/relinq/withdraw work */
uoff_t object_size; /* Size of the netfs object */
--
2.53.0
reply other threads:[~2026-11-11 15:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111154504.1314170-1-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=pc@manguebit.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®