Message ID | 20250127012257.1803314-6-neilb@suse.de (mailing list archive) |
---|---|
State | New |
Delegated to: | Chuck Lever |
Headers | show |
Series | nfsd: filecache: change garbage collection lists | expand |
On Mon, 2025-01-27 at 12:20 +1100, NeilBrown wrote: > Rather than having the bare number "8" use a named constant and explain > the tradeoffs that lead to the choice. > > Signed-off-by: NeilBrown <neilb@suse.de> > --- > fs/nfsd/filecache.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c > index 1e90da507152..7264faa57280 100644 > --- a/fs/nfsd/filecache.c > +++ b/fs/nfsd/filecache.c > @@ -493,6 +493,21 @@ nfsd_file_dispose_list_delayed(struct list_head *dispose) > } > } > > +/* > + * Disposing of files can involve non-trivial work, and they > + * can appear in batches. So we don't want to try handling them > + * all in one thread - if there are lots it would be better to allow > + * several nfsd threads to handle them in parallel. > + * On average one RPC request can create at most 1 file to be disposed > + * so handling one each time around the nfsd loop should keep the list > + * under control. However there are often benefits of batching so > + * 2 at a time will likely be more efficient than 1. 4 more so. > + * We need to choose a number which will often handle all the files, > + * but will allow other threads to help when the list gets long. > + * The current choice is: > + */ > +#define NFSD_FILE_DISPOSE_BATCH 8 > + > /** > * nfsd_file_net_dispose - deal with nfsd_files waiting to be disposed. > * @nn: nfsd_net in which to find files to be disposed. > @@ -511,7 +526,8 @@ 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++) { > + for (i = 0; i < NFSD_FILE_DISPOSE_BATCH && > + !list_empty(&l->freeme); i++) { > struct nfsd_file *nf = list_first_entry( > &l->freeme, struct nfsd_file, nf_lru); > Thanks for doing this. Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 1e90da507152..7264faa57280 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -493,6 +493,21 @@ nfsd_file_dispose_list_delayed(struct list_head *dispose) } } +/* + * Disposing of files can involve non-trivial work, and they + * can appear in batches. So we don't want to try handling them + * all in one thread - if there are lots it would be better to allow + * several nfsd threads to handle them in parallel. + * On average one RPC request can create at most 1 file to be disposed + * so handling one each time around the nfsd loop should keep the list + * under control. However there are often benefits of batching so + * 2 at a time will likely be more efficient than 1. 4 more so. + * We need to choose a number which will often handle all the files, + * but will allow other threads to help when the list gets long. + * The current choice is: + */ +#define NFSD_FILE_DISPOSE_BATCH 8 + /** * nfsd_file_net_dispose - deal with nfsd_files waiting to be disposed. * @nn: nfsd_net in which to find files to be disposed. @@ -511,7 +526,8 @@ 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++) { + for (i = 0; i < NFSD_FILE_DISPOSE_BATCH && + !list_empty(&l->freeme); i++) { struct nfsd_file *nf = list_first_entry( &l->freeme, struct nfsd_file, nf_lru);
Rather than having the bare number "8" use a named constant and explain the tradeoffs that lead to the choice. Signed-off-by: NeilBrown <neilb@suse.de> --- fs/nfsd/filecache.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)