From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neilb@suse.de>
Cc: Chuck Lever <chuck.lever@oracle.com>,
linux-nfs@vger.kernel.org,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Subject: Re: [PATCH 3/4] nfsd: filecache: change garbage collection list management.
Date: Wed, 22 Jan 2025 16:33:05 -0500 [thread overview]
Message-ID: <b960f2754bac340d76beb56590873171ee097150.camel@kernel.org> (raw)
In-Reply-To: <173758048419.22054.7069906473728685831@noble.neil.brown.name>
On Thu, 2025-01-23 at 08:14 +1100, NeilBrown wrote:
> On Thu, 23 Jan 2025, Jeff Layton wrote:
> > On Wed, 2025-01-22 at 14:54 +1100, NeilBrown wrote:
> > > @@ -487,88 +512,32 @@ void nfsd_file_net_dispose(struct nfsd_net *nn)
> > > int i;
> > >
> > > spin_lock(&l->lock);
> > > - for (i = 0; i < 8 && !list_empty(&l->freeme); i++)
> > > - list_move(l->freeme.next, &dispose);
> >
> > While you're in here, could you document why we only take 8 at a time?
> > Maybe even consider turning it into a named constant?
>
> I've added a patch to do that.
>
> > > @@ -577,9 +546,20 @@ nfsd_file_gc_worker(struct work_struct *work)
> > > {
> > > struct nfsd_fcache_disposal *l = container_of(
> > > work, struct nfsd_fcache_disposal, filecache_laundrette.work);
> > > - nfsd_file_gc(l);
> > > - if (list_lru_count(&l->file_lru))
> > > +
> > > + spin_lock(&l->lock);
> > > + list_splice_init(&l->older, &l->freeme);
> > > + list_splice_init(&l->recent, &l->older);
> > > + /* We don't know how many were moved to 'freeme' and don't want
> > > + * to waste time counting - guess a half.
> > > + */
> > > + l->num_gc /= 2;
> >
> > Given that you have to manipulate the lists under a spinlock, it
> > wouldn't be difficult or expensive to keep accurate counts. nfsd
> > workloads can be "spiky", so it seems like this method may be wildly
> > inaccurate at times.
>
> The only way I can think of to get an accurate count is to iterate the
> list under the spin lock, and the cost of iterating long lists under a
> spinlock is what started this whole exercise.
>
> I could keep an accurate count of recent+older+freeme but giving that to
> the shrinker could cause it to shrink too much as the objects on
> "freeme" cannot be freed any faster.
>
> Maybe when freeme is not empty I could give zero to the shrinker...
>
> Any ideas?
I was thinking we could just increment a counter when adding it to the
list and transplant those counts as needed, but removals are a problem
since you don't necessarily know what list each entry resides on at any
given time, and you can't decrement the right one. It's probably
doable, but you're right that it's complex.
I'm OK with your estimate for now. If it turns out to be a problem
later, we can deal with it then.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-01-22 21:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 3:54 [PATCH 0/4] nfsd: filecache: change garbage collect lists NeilBrown
2025-01-22 3:54 ` [PATCH 1/4] nfsd: filecache: use nfsd_file_dispose_list() in nfsd_file_close_inode_sync() NeilBrown
2025-01-22 18:58 ` Jeff Layton
2025-01-22 3:54 ` [PATCH 2/4] nfsd: filecache: move globals nfsd_file_lru and nfsd_file_shrinker to be per-net NeilBrown
2025-01-22 18:58 ` Jeff Layton
2025-01-22 21:41 ` Chuck Lever
2025-01-22 22:10 ` NeilBrown
2025-01-23 14:30 ` Chuck Lever
2025-01-26 22:33 ` NeilBrown
2025-01-27 13:35 ` Chuck Lever
2025-01-27 22:21 ` NeilBrown
2025-01-22 3:54 ` [PATCH 3/4] nfsd: filecache: change garbage collection list management NeilBrown
2025-01-22 18:58 ` Jeff Layton
2025-01-22 21:14 ` NeilBrown
2025-01-22 21:33 ` Jeff Layton [this message]
2025-01-22 3:54 ` [PATCH 4/4] nfsd: filecache: change garbage collection to a timer NeilBrown
2025-01-22 19:08 ` Jeff Layton
2025-01-22 20:39 ` NeilBrown
2025-01-22 20:46 ` Jeff Layton
2025-01-22 21:07 ` NeilBrown
2025-01-22 19:22 ` [PATCH 0/4] nfsd: filecache: change garbage collect lists Chuck Lever
2025-01-22 22:16 ` NeilBrown
2025-01-23 14:29 ` Chuck Lever
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=b960f2754bac340d76beb56590873171ee097150.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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