]> www.infradead.org Git - users/jedix/linux-maple.git/commit
nfsd: add shrinker to reduce number of slots allocated per session
authorNeilBrown <neilb@suse.de>
Wed, 11 Dec 2024 21:47:09 +0000 (08:47 +1100)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 6 Jan 2025 14:37:39 +0000 (09:37 -0500)
commit35e34642b5996df91e2879d59f726df6072c82f9
treeb9e860e9b4c5597ca7db3eb25f36f1d3471db7ae
parentfc8738c68d0bbf5033dd98b4f63d277ecbd49fd7
nfsd: add shrinker to reduce number of slots allocated per session

Add a shrinker which frees unused slots and may ask the clients to use
fewer slots on each session.

We keep a global count of the number of freeable slots, which is the sum
of one less than the current "target" slots in all sessions in all
clients in all net-namespaces. This number is reported by the shrinker.

When the shrinker is asked to free some, we call xxx on each session in
a round-robin asking each to reduce the slot count by 1.  This will
reduce the "target" so the number reported by the shrinker will reduce
immediately.  The memory will only be freed later when the client
confirmed that it is no longer needed.

We use a global list of sessions and move the "head" to after the last
session that we asked to reduce, so the next callback from the shrinker
will move on to the next session.  This pressure should be applied
"evenly" across all sessions over time.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c
fs/nfsd/state.h