public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: NeilBrown <neilb@suse.de>, Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Subject: Re: [PATCH] nfsd: add scheduling point in nfsd_file_gc()
Date: Sun, 5 Jan 2025 20:55:08 -0500	[thread overview]
Message-ID: <de100fd1-b741-4386-ac9c-21f3957d342e@oracle.com> (raw)
In-Reply-To: <20250105234022.2361576-2-neilb@suse.de>

On 1/5/25 6:11 PM, NeilBrown wrote:
> Under a high NFSv3 load with lots of different file being accessed The
> list_lru of garbage-collectable files can become quite long.
> 
> Asking lisT_lru_scan() to scan the whole list can result in a long
> period during which a spinlock is held and no scheduling is possible.
> This is impolite.
> 
> So only ask list_lru_scan() to scan 1024 entries at a time, and repeat
> if necessary - calling cond_resched() each time.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>   fs/nfsd/filecache.c | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> index a1cdba42c4fa..e99a86798e86 100644
> --- a/fs/nfsd/filecache.c
> +++ b/fs/nfsd/filecache.c
> @@ -543,11 +543,18 @@ nfsd_file_gc(void)
>   {
>   	LIST_HEAD(dispose);
>   	unsigned long ret;
> -
> -	ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
> -			    &dispose, list_lru_count(&nfsd_file_lru));
> -	trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru));
> -	nfsd_file_dispose_list_delayed(&dispose);
> +	unsigned long cnt = list_lru_count(&nfsd_file_lru);
> +
> +	while (cnt > 0) {

Since @cnt is unsigned, it should be safe to use "while (cnt) {"

(I might use "total" and "remaining" here -- "cnt", when said aloud,
leaves me snickering).


> +		unsigned long num_to_scan = min(cnt, 1024UL);

I see long delays with fewer than 1024 items on the list. I might
drop this number by one or two orders of magnitude. And make it a
symbolic constant.

There's another naked integer (8) in nfsd_file_net_dispose() -- how does
that relate to this new cap? Should that also be a symbolic constant?


> +		ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
> +				    &dispose, num_to_scan);
> +		trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru));
> +		nfsd_file_dispose_list_delayed(&dispose);

I need to go back and review the function traces to see where the
delays add up -- to make sure rescheduling here, rather than at some
other point, is appropriate. It probably is, but my memory fails me
these days.


> +		cnt -= num_to_scan;
> +		if (cnt)
> +			cond_resched();

Another approach might be to poke the laundrette again and simply
exit here, but I don't feel strongly about that.


> +	}
>   }
>   
>   static void


-- 
Chuck Lever

  reply	other threads:[~2025-01-06  1:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-05 23:11 [PATCH intro] nfsd: add scheduling point in nfsd_file_gc() NeilBrown
2025-01-05 23:11 ` [PATCH] " NeilBrown
2025-01-06  1:55   ` Chuck Lever [this message]
2025-01-06  3:02     ` NeilBrown
2025-01-06 13:57       ` Chuck Lever
2025-01-07 23:01         ` NeilBrown
2025-01-08 13:39           ` Chuck Lever
2025-01-08 20:41             ` NeilBrown
2025-01-08 22:27               ` 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=de100fd1-b741-4386-ac9c-21f3957d342e@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --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