From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BC5EC433DB for ; Thu, 11 Mar 2021 11:49:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8395464FBA for ; Thu, 11 Mar 2021 11:49:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8395464FBA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 720748D02B1; Thu, 11 Mar 2021 06:49:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61B408D02B2; Thu, 11 Mar 2021 06:49:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C0758D02B1; Thu, 11 Mar 2021 06:49:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 11F6D8D02AF for ; Thu, 11 Mar 2021 06:49:39 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CEA7D3630 for ; Thu, 11 Mar 2021 11:49:38 +0000 (UTC) X-FDA: 77907423636.08.7587A6C Received: from outbound-smtp11.blacknight.com (outbound-smtp11.blacknight.com [46.22.139.106]) by imf20.hostedemail.com (Postfix) with ESMTP id 6939DFA for ; Thu, 11 Mar 2021 11:49:34 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp11.blacknight.com (Postfix) with ESMTPS id 3235C1C4167 for ; Thu, 11 Mar 2021 11:49:36 +0000 (GMT) Received: (qmail 21560 invoked from network); 11 Mar 2021 11:49:36 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPA; 11 Mar 2021 11:49:36 -0000 From: Mel Gorman To: Andrew Morton Cc: Chuck Lever , Jesper Dangaard Brouer , Christoph Hellwig , LKML , Linux-Net , Linux-MM , Linux-NFS , Mel Gorman Subject: [PATCH 3/5] SUNRPC: Refresh rq_pages using a bulk page allocator Date: Thu, 11 Mar 2021 11:49:33 +0000 Message-Id: <20210311114935.11379-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210311114935.11379-1-mgorman@techsingularity.net> References: <20210311114935.11379-1-mgorman@techsingularity.net> MIME-Version: 1.0 X-Stat-Signature: 36u3z7tqx8iouhzptmuhsp3o6msjbirc X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6939DFA Received-SPF: none (techsingularity.net>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=outbound-smtp11.blacknight.com; client-ip=46.22.139.106 X-HE-DKIM-Result: none/none X-HE-Tag: 1615463374-901979 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Chuck Lever Reduce the rate at which nfsd threads hammer on the page allocator. This improve throughput scalability by enabling the threads to run more independently of each other. Signed-off-by: Chuck Lever Signed-off-by: Mel Gorman --- net/sunrpc/svc_xprt.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index cfa7e4776d0e..38a8d6283801 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -642,11 +642,12 @@ static void svc_check_conn_limits(struct svc_serv *= serv) static int svc_alloc_arg(struct svc_rqst *rqstp) { struct svc_serv *serv =3D rqstp->rq_server; + unsigned long needed; struct xdr_buf *arg; + struct page *page; int pages; int i; =20 - /* now allocate needed pages. If we get a failure, sleep briefly */ pages =3D (serv->sv_max_mesg + 2 * PAGE_SIZE) >> PAGE_SHIFT; if (pages > RPCSVC_MAXPAGES) { pr_warn_once("svc: warning: pages=3D%u > RPCSVC_MAXPAGES=3D%lu\n", @@ -654,19 +655,28 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) /* use as many pages as possible */ pages =3D RPCSVC_MAXPAGES; } - for (i =3D 0; i < pages ; i++) - while (rqstp->rq_pages[i] =3D=3D NULL) { - struct page *p =3D alloc_page(GFP_KERNEL); - if (!p) { - set_current_state(TASK_INTERRUPTIBLE); - if (signalled() || kthread_should_stop()) { - set_current_state(TASK_RUNNING); - return -EINTR; - } - schedule_timeout(msecs_to_jiffies(500)); + + for (needed =3D 0, i =3D 0; i < pages ; i++) + if (!rqstp->rq_pages[i]) + needed++; + if (needed) { + LIST_HEAD(list); + +retry: + alloc_pages_bulk(GFP_KERNEL, needed, &list); + for (i =3D 0; i < pages; i++) { + if (!rqstp->rq_pages[i]) { + page =3D list_first_entry_or_null(&list, + struct page, + lru); + if (unlikely(!page)) + goto empty_list; + list_del(&page->lru); + rqstp->rq_pages[i] =3D page; + needed--; } - rqstp->rq_pages[i] =3D p; } + } rqstp->rq_page_end =3D &rqstp->rq_pages[pages]; rqstp->rq_pages[pages] =3D NULL; /* this might be seen in nfsd_splice_a= ctor() */ =20 @@ -681,6 +691,15 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) arg->len =3D (pages-1)*PAGE_SIZE; arg->tail[0].iov_len =3D 0; return 0; + +empty_list: + set_current_state(TASK_INTERRUPTIBLE); + if (signalled() || kthread_should_stop()) { + set_current_state(TASK_RUNNING); + return -EINTR; + } + schedule_timeout(msecs_to_jiffies(500)); + goto retry; } =20 static bool --=20 2.26.2