1 From kuniyu@amazon.com Tue Aug 27 14:47:41 2024
2 From: Kuniyuki Iwashima <kuniyu@amazon.com>
3 Date: Mon, 19 Aug 2024 10:05:51 -0700
4 Subject: nfsd: Don't call freezable_schedule_timeout() after each successful page allocation in svc_alloc_arg().
5 To: <stable@vger.kernel.org>
6 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, Jeff Layton <jlayton@kernel.org>, NeilBrown <neilb@suse.de>, Chuck Lever <chuck.lever@oracle.com>, Kuniyuki Iwashima <kuniyu@amazon.com>, Kuniyuki Iwashima <kuni1840@gmail.com>, Hughdan Liu <hughliu@amazon.com>
7 Message-ID: <20240819170551.10764-1-kuniyu@amazon.com>
9 From: Kuniyuki Iwashima <kuniyu@amazon.com>
11 When commit 390390240145 ("nfsd: don't allow nfsd threads to be
12 signalled.") is backported to 5.10, it was adjusted considering commit
13 3feac2b55293 ("sunrpc: exclude from freezer when waiting for requests:").
15 However, 3feac2b55293 is based on commit f6e70aab9dfe ("SUNRPC: refresh
16 rq_pages using a bulk page allocator"), which converted page-by-page
17 allocation to a batch allocation, so schedule_timeout() is placed
20 As a result, the backported commit 7229200f6866 ("nfsd: don't allow nfsd
21 threads to be signalled.") placed freezable_schedule_timeout() in the wrong
24 Now, freezable_schedule_timeout() is called after every successful page
25 allocation, and we see 30%+ performance regression on 5.10.220 in our
28 Let's move it to the correct place so that freezable_schedule_timeout()
29 is called only when page allocation fails.
31 Fixes: 7229200f6866 ("nfsd: don't allow nfsd threads to be signalled.")
32 Reported-by: Hughdan Liu <hughliu@amazon.com>
33 Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
34 Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37 net/sunrpc/svc_xprt.c | 2 +-
38 1 file changed, 1 insertion(+), 1 deletion(-)
40 --- a/net/sunrpc/svc_xprt.c
41 +++ b/net/sunrpc/svc_xprt.c
42 @@ -679,8 +679,8 @@ static int svc_alloc_arg(struct svc_rqst
43 set_current_state(TASK_RUNNING);
46 + freezable_schedule_timeout(msecs_to_jiffies(500));
48 - freezable_schedule_timeout(msecs_to_jiffies(500));
49 rqstp->rq_pages[i] = p;
51 rqstp->rq_page_end = &rqstp->rq_pages[i];