Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp299641pxb; Wed, 24 Feb 2021 02:27:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYzhlfHIXpBuJrYaRYZd/1UAuXjxYN8tvuhdavKkWvFn+cexcoSMjonlB29z/hNTs00TTF X-Received: by 2002:a05:6402:40c1:: with SMTP id z1mr8759467edb.322.1614162454574; Wed, 24 Feb 2021 02:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614162454; cv=none; d=google.com; s=arc-20160816; b=YXTVdOV7CjZvclp64CY5Su6r0JRsjDyg2wUIQywG3tAIGyxaFwu4OCmV5jFvi8Hjex 3xgJ1opbw2FAvubViILRBZb6wQsjtGDNrcjE4PkbeSYXN3GX/DGtcZyisw5LQ6f/DnFB kPU1QCeP28ZdTeiPWlIUOg6ReY5r2VvNTnpQBaDUoeLWUoU1pEbasxxwTFsGoeGD+WvZ C12QfnBdDzB/QVxbwVVhUPIgHOSH39Tx+cQx4yQx3luxHPqjIqiZf1vV0r35vC+XT/wn b405loEybkPAV9PcvOPxXX0HEXiXO8rKyp2VYAUyBUYAaM9luQ2mB0lqEET/ZYzvXVtP kBdQ== 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=VSfqacrDb0ih9DlEoSAZd+PJv7hVTqMqhtEj0cqw9lE=; b=D9z1VE+9k4KSqzb0UXVftg0oyML9raeYIWXwuZI4bUHbkLf8jEwbMHVARpb9CqzdCa d+4Fn7vemEmfEP7qn4Zt7qUJ6zTwrAZXAwbltgHERXDLQaAWY5/x1+8EfwgIUEcC6C9I klXnUpuh6UzkhSQ/b+P/OTEdXD2dal/Vk5aTu1ctg9FnYNf16uMQGhxdpHdbjH+FdR1g SpYHz40IOu5a7/fNgT5L5p8+tJaS10bwl6U9ZbmwyMUXvEeFgWzBX80cC6DsOXJY6wwr d6wm94WYnm2I9lrSDQh01vPjo1Uw5aVaQ12TNxFE3SMuPxSv+vVnGZklLoweuTPMJ630 n6qA== 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 dj3si959998edb.206.2021.02.24.02.27.11; Wed, 24 Feb 2021 02:27:34 -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 S234276AbhBXK06 (ORCPT + 99 others); Wed, 24 Feb 2021 05:26:58 -0500 Received: from outbound-smtp02.blacknight.com ([81.17.249.8]:56930 "EHLO outbound-smtp02.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234715AbhBXK04 (ORCPT ); Wed, 24 Feb 2021 05:26:56 -0500 Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp02.blacknight.com (Postfix) with ESMTPS id 95519BAAD2 for ; Wed, 24 Feb 2021 10:26:04 +0000 (GMT) Received: (qmail 23478 invoked from network); 24 Feb 2021 10:26:04 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPA; 24 Feb 2021 10:26:04 -0000 From: Mel Gorman To: Chuck Lever , Jesper Dangaard Brouer Cc: LKML , Linux-Net , Linux-MM , Linux-NFS , Mel Gorman Subject: [PATCH 3/3] SUNRPC: Refresh rq_pages using a bulk page allocator Date: Wed, 24 Feb 2021 10:26:03 +0000 Message-Id: <20210224102603.19524-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210224102603.19524-1-mgorman@techsingularity.net> References: <20210224102603.19524-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 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 = 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