Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1353998pxf; Fri, 12 Mar 2021 07:45:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2GzuI87cqlKAsp3z0GcDjqUHioST9KDLsDCPob2CHKJX8hmLV6UN/v1dei2jdEwXLi8wM X-Received: by 2002:a05:6402:1d39:: with SMTP id dh25mr15116797edb.282.1615563933089; Fri, 12 Mar 2021 07:45:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615563933; cv=none; d=google.com; s=arc-20160816; b=m5mGeRbmGc9HFEanB6mMFAXEEi+w9IiEiO8Isdlrj6EbrxS/NaALFF1go8Z7U+DNvg iXGp8lNg93gP6kykjntRCClHXn0zJPwayYd+NpnbMYUOn7e2UiIFDGdsaXeWHR9Swk+E vGUQGiRO8HTU/1I+9RLG9Xj6Y/+T358leNz3/uyvhxreLRsmErotI9mXlDwcj/rodnuL t1VmtPRk0A1yJ5yspeJFmhlcJs7sRECEP3IgQWKCszB1J4lRpksO/iJvMOaisuhWcn6X tvYDyFRLIK1UZWZAtIEAOdvKqTm9NqZjcW8pjZxWBDmAG1tc90wI9Ml4nVD46BQxiC7L XFBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NSFz2p37zTAJwAfOMzfGOeH6oiEDGuPfWAel6KaYDjE=; b=a+SBqTABuJv9CpkYmS6+BAEC+8hgPsHuaBm/uAwtn5gN+Qem67yqnZc3b/wRHxkdsC cl4hATLCUMN16GBufL8k1bIuyAGUAQpBhyGid4riawpp2wbDo/voxoReyFbQyu3CmVJN JmL7t8Rz57F4xHizKujnMCO+S4bQAMBzyVh3/QfA63bnaZPQNAY4drqgVZgEF8Sytjwz XWfnP2eWaxFHuisMd1BZ02pt1d9rzmnD50l36cYviYBLRqa6rNSAaL+oc3yvKLcAKCAd zDCyLGk+pMcP3BxB3rieeqh/MZMVSrWdxcpda527aBPQzcrrkM/VP4EkjcgMUdfl/qfK MMEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si4243022ejv.268.2021.03.12.07.45.09; Fri, 12 Mar 2021 07:45:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbhCLPoE (ORCPT + 99 others); Fri, 12 Mar 2021 10:44:04 -0500 Received: from outbound-smtp47.blacknight.com ([46.22.136.64]:35539 "EHLO outbound-smtp47.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbhCLPng (ORCPT ); Fri, 12 Mar 2021 10:43:36 -0500 Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp47.blacknight.com (Postfix) with ESMTPS id E23B8FB0C6 for ; Fri, 12 Mar 2021 15:43:32 +0000 (GMT) Received: (qmail 19870 invoked from network); 12 Mar 2021 15:43:32 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPA; 12 Mar 2021 15:43:32 -0000 From: Mel Gorman To: Andrew Morton Cc: Chuck Lever , Jesper Dangaard Brouer , Christoph Hellwig , Alexander Duyck , Matthew Wilcox , LKML , Linux-Net , Linux-MM , Linux-NFS , Mel Gorman Subject: [PATCH 5/7] SUNRPC: Refresh rq_pages using a bulk page allocator Date: Fri, 12 Mar 2021 15:43:29 +0000 Message-Id: <20210312154331.32229-6-mgorman@techsingularity.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210312154331.32229-1-mgorman@techsingularity.net> References: <20210312154331.32229-1-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Chuck Lever Reduce the rate at which nfsd threads hammer on the page allocator. This improves 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 = rqstp->rq_server; + unsigned long needed; struct xdr_buf *arg; + struct page *page; int pages; int i; - /* now allocate needed pages. If we get a failure, sleep briefly */ pages = (serv->sv_max_mesg + 2 * PAGE_SIZE) >> PAGE_SHIFT; if (pages > RPCSVC_MAXPAGES) { pr_warn_once("svc: warning: pages=%u > RPCSVC_MAXPAGES=%lu\n", @@ -654,19 +655,28 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) /* use as many pages as possible */ pages = RPCSVC_MAXPAGES; } - for (i = 0; i < pages ; i++) - while (rqstp->rq_pages[i] == NULL) { - struct page *p = 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 = 0, i = 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 = 0; i < pages; i++) { + if (!rqstp->rq_pages[i]) { + page = list_first_entry_or_null(&list, + struct page, + lru); + if (unlikely(!page)) + goto empty_list; + list_del(&page->lru); + rqstp->rq_pages[i] = page; + needed--; } - rqstp->rq_pages[i] = p; } + } rqstp->rq_page_end = &rqstp->rq_pages[pages]; rqstp->rq_pages[pages] = NULL; /* this might be seen in nfsd_splice_actor() */ @@ -681,6 +691,15 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) arg->len = (pages-1)*PAGE_SIZE; arg->tail[0].iov_len = 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; } static bool -- 2.26.2