From: NeilBrown <neilb@suse.de>
To: Chuck Lever <chuck.lever@oracle.com>, 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: [PATCH] nfsd: add scheduling point in nfsd_file_gc()
Date: Mon, 6 Jan 2025 10:11:59 +1100 [thread overview]
Message-ID: <20250105234022.2361576-2-neilb@suse.de> (raw)
In-Reply-To: <20250105234022.2361576-1-neilb@suse.de>
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) {
+ unsigned long num_to_scan = min(cnt, 1024UL);
+ 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);
+ cnt -= num_to_scan;
+ if (cnt)
+ cond_resched();
+ }
}
static void
--
2.47.1
next prev parent reply other threads:[~2025-01-05 23:40 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 ` NeilBrown [this message]
2025-01-06 1:55 ` [PATCH] " Chuck Lever
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=20250105234022.2361576-2-neilb@suse.de \
--to=neilb@suse.de \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--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