From patchwork Sat Apr 15 00:17:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13212216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6D0BC77B72 for ; Sat, 15 Apr 2023 00:18:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4877D900004; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43796900002; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 326F9900004; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 260D2900002 for ; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D9AEAABB9B for ; Sat, 15 Apr 2023 00:18:00 +0000 (UTC) X-FDA: 80681712720.19.000FAE0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 386AE4000D for ; Sat, 15 Apr 2023 00:17:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hXfE/aAz"; spf=pass (imf07.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681517879; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DU+K9sMszFdIIwO7wrAMkgVApC9slAiX2drMJII2Ya8=; b=PQtyTOv+OLn9qKXaTZPhWd2qdjuSzH464izVtDUAaf+U2BRfdB9AXhCu9OT1wVFIiiqGDb yiXALTHHUoOuvtbkhtcnTG4EF/aljiPrwVASX9Z7G2XWC0Xg/6WvVAfkevCg45o1rPP98J pGLzlFnn3/txvPCOYKLLq2/w2DI9mq0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hXfE/aAz"; spf=pass (imf07.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681517879; a=rsa-sha256; cv=none; b=OpUsalFOb2ZDHbW+4xRYH3FyJqkNBIaZqovuJfiaYL+3LCLhLeJ3m9Rr0eScgLutjI+Hlj nxQ3Dulfsvt81ItLK8MnYZGjlIGNMRNO754OfxOCridN32qJjtiFjjmOawN6aewIEN76Bn KQqESDNbX0wPsDAqzaH+lZinQpfgwWM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4473E645C6 for ; Sat, 15 Apr 2023 00:17:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A180C433A0; Sat, 15 Apr 2023 00:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681517877; bh=w0AGIKncJ+aMWbYsTzdaumoT4rTj66CdiASkX6lZ4UU=; h=Subject:From:To:Date:In-Reply-To:References:From; b=hXfE/aAz5R89eQvCA4gEJ1LT2dArTmazeb+qhr8Mtd66M5OTM+PGTvU9rdnSeR6Vg 074TTlq2rc4bDFuQK7AqzwnV8Zl5ifmGeJe/TPUUWrotsP4PD2QuLYXTI9saUYiYjt wSjljvZ3yk5NpYqS1z4iRE7Ks4rnxK0Myvax2Zh380qVjPqBqyQTxOKU7xP8Ur2zrs IWBmKDIXIWAZJAqA3pmiSo13JBhPGxHGHZoCnjGeg2uV4skBFbMuw6BLbB13t1iNlV ja9fRCsIDDXwBVt+1usSOEjYbiY9VX328hIVzOHLo7/PIxsJYooPL/nGq1s8tpQkr0 ip9uTDQcWasOA== Subject: [PATCH v1 1/4] SUNRPC: Relocate svc_free_res_pages() From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Fri, 14 Apr 2023 20:17:56 -0400 Message-ID: <168151787655.1588.13024575588334839763.stgit@klimt.1015granger.net> In-Reply-To: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> References: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 386AE4000D X-Stat-Signature: azu754yez1t8ei91djuteiurr8wrksr1 X-Rspam-User: X-HE-Tag: 1681517879-680692 X-HE-Meta: U2FsdGVkX1/O7+/D7xCdikg4bn0TAyERH4wpcVyo/mJo3JC4RB6SOxHbFfXYjAYbUF137dy/HJcG2AgsQtO+uldYCg5CQHoQAW8FHipG+1pbywU8Xr0W35D5cjd1xfPIhU8nuKIon8ANkUk+WtSyn6wVeadTZPBQzHf3/4uyoG2SKS2l8qfNmHc4k1XwfzqCac4S0Qr6eADCDlXFzmyoj60nDbv03XFDOhrRfVDy24ua/ng8MTuY4AafCF2RdeZ/fODT+bOoCexNYhUAojyWfPSabIU1DvrdimYLHCtXiuR4wckC0owqVomgp/JeOTi7Ll+w2Qz/soLz0et9/KhURAGA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ogofilter, 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 Clean-up: There doesn't seem to be a reason why this function is stuck in a header. One thing it prevents is the convenient addition of tracing. Moving it to a source file also makes the rq_respages clean-up logic easier to find. Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 12 +----------- net/sunrpc/svc.c | 19 +++++++++++++++++++ net/sunrpc/svc_xprt.c | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 2d31121fc2e6..762d7231e574 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -309,17 +309,6 @@ static inline struct sockaddr *svc_daddr(const struct svc_rqst *rqst) return (struct sockaddr *) &rqst->rq_daddr; } -static inline void svc_free_res_pages(struct svc_rqst *rqstp) -{ - while (rqstp->rq_next_page != rqstp->rq_respages) { - struct page **pp = --rqstp->rq_next_page; - if (*pp) { - put_page(*pp); - *pp = NULL; - } - } -} - struct svc_deferred_req { u32 prot; /* protocol (UDP or TCP) */ struct svc_xprt *xprt; @@ -424,6 +413,7 @@ struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node); bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page); +void svc_rqst_release_pages(struct svc_rqst *rqstp); void svc_rqst_free(struct svc_rqst *); void svc_exit_thread(struct svc_rqst *); struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 0aa8892fad63..0fc70cc405b2 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -869,6 +869,25 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page) } EXPORT_SYMBOL_GPL(svc_rqst_replace_page); +/** + * svc_rqst_release_pages - Release Reply buffer pages + * @rqstp: RPC transaction context + * + * Release response pages that might still be in flight after + * svc_send, and any spliced filesystem-owned pages. + */ +void svc_rqst_release_pages(struct svc_rqst *rqstp) +{ + while (rqstp->rq_next_page != rqstp->rq_respages) { + struct page **pp = --rqstp->rq_next_page; + + if (*pp) { + put_page(*pp); + *pp = NULL; + } + } +} + /* * Called from a server thread as it's exiting. Caller must hold the "service * mutex" for the service. diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 36c79b718323..533e08c4f319 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -542,7 +542,7 @@ static void svc_xprt_release(struct svc_rqst *rqstp) rqstp->rq_deferred = NULL; pagevec_release(&rqstp->rq_pvec); - svc_free_res_pages(rqstp); + svc_rqst_release_pages(rqstp); rqstp->rq_res.page_len = 0; rqstp->rq_res.page_base = 0; From patchwork Sat Apr 15 00:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13212217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD85BC77B72 for ; Sat, 15 Apr 2023 00:18:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FC40900005; Fri, 14 Apr 2023 20:18:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AC92900002; Fri, 14 Apr 2023 20:18:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39B82900005; Fri, 14 Apr 2023 20:18:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 29A63900002 for ; Fri, 14 Apr 2023 20:18:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EE72A404A2 for ; Sat, 15 Apr 2023 00:18:06 +0000 (UTC) X-FDA: 80681712972.03.117F62F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 4E7FAC000A for ; Sat, 15 Apr 2023 00:18:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jYSxYefr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681517885; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JpB3cSieB112O2mmYFTwIYmI2UkhPG4R6zR8Kdva88Y=; b=qSW0n6O5GIJ3AkRPsRQeL8ZYWsbDaAQjrw8JiBjZmfZygvZmnzzaxu/kpY0zSBSEuLxpKa RDkfUSCHRY1fpr3yJ4MTTI/NJfVDVqAjvfNJN5VTrkjUPm1RuvimdzqtrE1XBNnkBllTCx wcEt1UChsZQ+qNzkBOQjY1cQPYcmwIE= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jYSxYefr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681517885; a=rsa-sha256; cv=none; b=HyEiAaxWvRE/tOZCTvfygYL6jUzNLQgoNREu0jxaM0eIg7tQhTwpIr08oW0qMFVH0EbDrh jKBnc4hZaVHuNzmHDGmz4wwM+jYNfuWERzwiNLzZ3LA2ZqqJR5YIoNPcCR/cRVcXirak/c y/IBluiF7asZPgHyI5Aetg5T6x2TvIE= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8483B616EB for ; Sat, 15 Apr 2023 00:18:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C42B6C4339E; Sat, 15 Apr 2023 00:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681517883; bh=RshTAt8N1txg6TF0maDP8tdDMDzPklBfrU/3+g+KeB8=; h=Subject:From:To:Date:In-Reply-To:References:From; b=jYSxYefrqfWu1kEKIKaipUqoEVNeS1w6Bew7vDGwis67wzwDtoDRpSup7gSR+lyhS 3o24x6abUfaF6oJH9e9zRDr/EucGPFxwfFnj6xwyJFgbNDDpCU5Y8S1hnbiVph2FDu k/iVHF6mKtq4B2eJdfBOZJomYCHedALLd0xFWnwyF9Z7VTN9YR9iy2DyMTSojnT7Gm mluQbC38LoNAC+bN8BgR53VzYVoDCbVzD2Yh23wE11YLdcK4pwjN0P/5sbT5OnFaaM a25PnOzBTCKvasRQP1BOitBiHL0JfByCoxIfCSfI14P4xAkpNJ2WU4QRySiSZWYrkr xhcHRqTR5aaDQ== Subject: [PATCH v1 2/4] SUNRPC: Convert svc_xprt_release() to the release_pages() API From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Fri, 14 Apr 2023 20:18:02 -0400 Message-ID: <168151788284.1588.1198570306681230834.stgit@klimt.1015granger.net> In-Reply-To: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> References: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4E7FAC000A X-Stat-Signature: fthdqfmccn3k5muim39ncffa6dftts1b X-HE-Tag: 1681517885-434609 X-HE-Meta: U2FsdGVkX1+PuRBnUnLuBWDAgyeSdBBDUmS10B2gMCtVwOBe/Q/fqHhTxGKJIdujxtHbTWQSsCtVr+RVOmFit54GET+AzG2/MMXiXZ+jueAWgvmnmNLDfGn+tMzwLXPL5bk99YLTw5wEqbX9HmJcO3wauuZldXt8GlnI1QQRLMII2CxebASySDyVth/V64H6ragfSWjjMcPfmRSu6oH2wERntUoN+sCdVrnT2GkJQmcANWsUfmrLbZqRyPTePlJ4ijfBmCkvua5wYLrU/0O9kmsghmD3/WmZOlncGTp/DdPMVGKl3E9eb5iwG3Py+SQtNn/Tedv+sxEEpsVNHA3fM2/cP+eDllyeKM6W0fspbmUoVsquYJunrW28eumBplRZFtc/LxTf6EnBRuqu0/fYfhTfQmfjjr52gcQMg2Eh485kIMg0+nNSxF25c23BBdTink32zYyqBPOmsAHvKE5cKeejMpbVKlGA7kOZ4g9H3Wu0zs1iuKGXPHaEEU4Z3DembHUeCVomq6uI/LpaBjjq0QEivira03qavgzq6MAUkENwjtgIkPqi1wxB5xugtD3Ks0yCm9dTg5NBG/jf5M8f1STiZeaKdRjO4RTRyIlkXFXRiNG71i4orxzaeQWZqnrDclpSpGyiO6Vh037YYY0nfDYYr2WFM4QJ01/PXGCSDr4E/JI8rCWomT90KMzmgMsq1Foj6TnLq8n/WUFFdFQvtROoH/zI91jpbTnVtqQcqzipCZVS8hHmTQAG0NLj8M6DQYcSEuLJSG/nUvi3nsRc+00hrA/p9TNXYnzr9m97EfnRIMEWGsdYjW15af4vhi0HQO3uNoAeMY/D2DcLLdqNhksg9HMi3KoBuo8GbVTDB24iU4KnQsNmRa0KCde6wGUcGez+/Echrm6NeleQCa/Qfd83kPx2ZUGwbCYbkdG2VBzJ5Lr+6c9vSahxMeav2YuCLg7x3e5+80KcNfE25lh vO2swBoD kn2l19+HcGO/ld31jezMxWZKo1emYTMRGZta4J/AIOuq+JVCIFrZZnlLJqiSPkz3LR9ccYQoU+2oPYt2ZJSOR7hfQdmpBLZkFjNavXs7vOort4zMLnyTCX9wSozJu+2EUtYVj6kYgvKhtb22l1UibQLcfPG59CXxN7Ui+7bXglvTmLCFXDaMxn0r5gk/m0tbusoGznPVeUK/r7LqTRYP2IjBa9YL6AhCLQlLcjMj2btGWDP9Yo+5DYf3pmhPwO75A24H93eT5wOxQsBGi/1rj6C5vCjakioENk5cX6kv3VFNvTm1rKu6/Wu768DpNOu1nry+G5Q/54lIXuGh2gzVehuqZ8tBCUr/gVNxQ87aa6fmR1SYWVV+e66h12RKI4w2+dezuxbx7mkRSVa3CMr6tbJ8/Qw== 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 Instead of invoking put_page() one-at-a-time, pass the "response" portion of rq_pages directly to release_pages() to reduce the number of times each nfsd thread invokes a page allocator API. Since svc_xprt_release() is not invoked while a client is waiting for an RPC Reply, this is not expected to directly impact mean request latencies on a lightly or moderately loaded server. However as workload intensity increases, I expect somewhat better scalability: the same number of server threads should be able to handle more work. Signed-off-by: Chuck Lever --- net/sunrpc/svc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 0fc70cc405b2..b982f802f2a0 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -878,13 +878,12 @@ EXPORT_SYMBOL_GPL(svc_rqst_replace_page); */ void svc_rqst_release_pages(struct svc_rqst *rqstp) { - while (rqstp->rq_next_page != rqstp->rq_respages) { - struct page **pp = --rqstp->rq_next_page; + int i, count = rqstp->rq_next_page - rqstp->rq_respages; - if (*pp) { - put_page(*pp); - *pp = NULL; - } + if (count) { + release_pages(rqstp->rq_respages, count); + for (i = 0; i < count; i++) + rqstp->rq_respages[i] = NULL; } } From patchwork Sat Apr 15 00:18:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13212218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B37C77B76 for ; Sat, 15 Apr 2023 00:18:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 830AC900006; Fri, 14 Apr 2023 20:18:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E0A0900002; Fri, 14 Apr 2023 20:18:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D02A900006; Fri, 14 Apr 2023 20:18:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 60381900002 for ; Fri, 14 Apr 2023 20:18:13 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3E7591604DB for ; Sat, 15 Apr 2023 00:18:13 +0000 (UTC) X-FDA: 80681713266.09.EB68145 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 95CC5100008 for ; Sat, 15 Apr 2023 00:18:11 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AJ6awgWM; spf=pass (imf05.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681517891; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6zedfpfHHANWZW8FHkMixTgvI3kIP5zUCCi+zSANlF4=; b=vMwBE3u8EK5gWBiCas0MZTm+f9vW9mqlRDtkHoq5v5pmdXKGs9JkcwsJY5D0BGXjPLRM7S 86GZL5JzWyCE+NdLQ9oEm4eMDWzSnKT0uTIowAcdA+CGzU1Ue0CjKlDR0coj/tcja9P89L HxQe/1bA9rRmf65u2cqO0ixrz5FeZiQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AJ6awgWM; spf=pass (imf05.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681517891; a=rsa-sha256; cv=none; b=WX+jzRT5eSINWOVyEoVJJU8xBGk8Cc+1bCukctq1FI16qPmAmNdpfWInz16mmeQSWB5Ffe itvJw8c2ePhMm4RzJuercTdLd+a8IIK3eMnKcGEN0AQMdA/aUCMbxIpWepkvD+5bAPbMZ8 Fwi0zlKPWR/AsNNDLOkuw9X4MKrLqgY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9E336450B for ; Sat, 15 Apr 2023 00:18:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18C2EC433D2; Sat, 15 Apr 2023 00:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681517890; bh=sTDSRZds3I5VoEZES7MzTU1WmuMqkd/9J180VGx4J2Y=; h=Subject:From:To:Date:In-Reply-To:References:From; b=AJ6awgWMSm3B3TfX59IIKRBUQuR6yBd3AA4wftjj7YJ+BvQMnJ0ebiRpshGEI4TnY RSUWdgYCu156/OJ1DjxyI11+KFeDIgxUPn2eC2s7bxqBHyla3bWJVJnkcRzWwy2zNc Ok0LfTV38XgpG/5m6JrR1SXv3emuat0CRFGdGkV2wxM/uIco8zBy+QIyuZBcN8HG2P 3InJk3jD8BqyeUP0+Qjo+z5hSOksJ86V+31kERTdQw8brsCHHmSccZKdyHJcP0m94i DxpFmg+fAMe3tn4H5Knu9gj6TXpJco+RSV1CSlD/V7aSnGckIt083n3wSk3uo4Mv3f P70g1Rjnh911w== Subject: [PATCH v1 3/4] SUNRPC: Convert svc_tcp_restore_pages() to the release_pages() API From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Fri, 14 Apr 2023 20:18:09 -0400 Message-ID: <168151788914.1588.17896994938586012232.stgit@klimt.1015granger.net> In-Reply-To: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> References: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 95CC5100008 X-Stat-Signature: riguubape13bj4uid4umujm7wikk7wx4 X-Rspam-User: X-HE-Tag: 1681517891-89363 X-HE-Meta: U2FsdGVkX19ZRhxTfm8DYSMS+KL2wD4pG27VCAGbhrgZ2QgMLNg6cZn5MqKQgcEP0cCrQb+cogHRM+NuRmSbuppfuCeUlMZm8fKKZSigdQqORXfFQrYte8kdsbE38D2H7aoFFPpmoLI3fOAQajE8N7lVDM6pz48wdTd2BxUkiMDu4omRoG3oLDeACH9LFqIjE9ix3L0QsK5mt4HIYq4SxRTEJxRyijDuJoA9jXAgPBOQCJCkbSGAdiXzOoIc1e3X0fk2LoRQNvPjyOJfVycetbBS7mehWfkVhz54OfFycwvHtG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EOcZI07NLEzb0/h4R4jcSDWEO9sY8uTJEMz2uVD9S6ZUjapg== 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 Instead of invoking put_page() one-at-a-time, pass the portion of rq_pages to be released directly to release_pages() to reduce the number of times each server thread invokes a page allocator API. Signed-off-by: Chuck Lever --- net/sunrpc/svcsock.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 302a14dd7882..44f72b558a1c 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -812,12 +812,12 @@ static size_t svc_tcp_restore_pages(struct svc_sock *svsk, if (!len) return 0; npages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; - for (i = 0; i < npages; i++) { - if (rqstp->rq_pages[i] != NULL) - put_page(rqstp->rq_pages[i]); - BUG_ON(svsk->sk_pages[i] == NULL); - rqstp->rq_pages[i] = svsk->sk_pages[i]; - svsk->sk_pages[i] = NULL; + if (npages) { + release_pages(rqstp->rq_pages, npages); + for (i = 0; i < npages; i++) { + rqstp->rq_pages[i] = svsk->sk_pages[i]; + svsk->sk_pages[i] = NULL; + } } rqstp->rq_arg.head[0].iov_base = page_address(rqstp->rq_pages[0]); return len; From patchwork Sat Apr 15 00:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13212219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CCBC77B72 for ; Sat, 15 Apr 2023 00:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD687900007; Fri, 14 Apr 2023 20:18:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D85DA900002; Fri, 14 Apr 2023 20:18:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C74D9900007; Fri, 14 Apr 2023 20:18:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BA920900002 for ; Fri, 14 Apr 2023 20:18:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 913501604D9 for ; Sat, 15 Apr 2023 00:18:19 +0000 (UTC) X-FDA: 80681713518.15.361492D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 02FBC4001C for ; Sat, 15 Apr 2023 00:18:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q30o4mYF; spf=pass (imf11.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681517898; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rpGrvsjXX0roeYU4i8chRr4Z9mJdVW+uPcunqIcdMC4=; b=4piywo8lYl+dyNXqwScyd/rMUi5sZsJUCC2q2/NNZK9+VDSFfT5/Igz4GcJe1mNbUjnZpW EU207Av5XygFmNSex3FuwpOPXd4jN4rwEZG1vYRlVarmyv78xsqruLXy6cnmU6QqeMkCvX GQcC9ZGkAkq6Heu2qASJDEIWy8ZiUgc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q30o4mYF; spf=pass (imf11.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681517898; a=rsa-sha256; cv=none; b=Nj7xRJ9JQQYBZXTsCmZZPf4230H0TWD34SWfBu/yAfMN5qQXYdFMmZy4yGV6C8vamwgp+v WXqQAhYIRLtg1BUbvVW1gjCv2bhBkqd4UEsaQbCTJN+fvbm42oy02Yxt/+YWzsremchSxQ sbMdxKaLi652e2IXNMiHqH0PzZX5Lo4= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C4EA645C6 for ; Sat, 15 Apr 2023 00:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AFF5C433EF; Sat, 15 Apr 2023 00:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681517896; bh=gwoDKthJAF1WHfbGuiCRuLpxNhrgjIi9oMkJ9fM63b0=; h=Subject:From:To:Date:In-Reply-To:References:From; b=q30o4mYFhbelsQ8SGE1YZKn7WuVdtBSkF/hM8jmtBXkBFL3iTHEyl/yOTRJojvgFL HtRjb1M2zuyVP9HdYzisBRXDr7Nudgn6kl8Sfkd6Wk5RiNo0Awfxy9tR01XCJdY+vN ztCNBwS4uIFBTzJzqXnDdlzU7Z+Pbk+zEUIZH+dmsfxnAMXQpeOg8MMG+e9ilf85Lq MK0S+fv153+w9uV3dASWZ/ekqK5L93DeDpcoPINWbGQmkp5OkG2brxO0k+oH/22SMe +XlBeo3arby3UnHwREkIDVlkbDJfJ+dOYot8uc+M3lMHXMV6OqcBkP5MVFIGHjG+1V EAIAoVm5G/SeQ== Subject: [PATCH v1 4/4] SUNRPC: Be even lazier about releasing pages From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Fri, 14 Apr 2023 20:18:15 -0400 Message-ID: <168151789543.1588.6591139655130358318.stgit@klimt.1015granger.net> In-Reply-To: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> References: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 02FBC4001C X-Stat-Signature: bktedx7psyjd7mrztcxrotqxiawpb8kn X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681517897-761596 X-HE-Meta: U2FsdGVkX18UxK/oC/tFIlMgvPuz0I7WF6vFSHuF6pJ6tET6/L/xEro9jSGc88fmxPQeTCVzOwgH/OgPsy0GNtBt9TxZXN96trzGXpM27oOid/89lSc5ohbNtVGE5SGGTm5Uvt1O1hyiwPVQ7LoZGeTEkerA8EfxRfEkgJKZ9Q6P3DlriWQBW/J1Kv3nO9ZCcf+uqg1FRosJAM3LytA+UtyM1aIDFnKiVZH/9Daq6vqniPZ7UdKqjYKm30MbYGiVO2x32Ut9G7ivb2ap6WxlAShFrOhE1/naBVTavgnVn18g6/6/4fdX5YBSuErrnnclozbE6O8fiAnTmSkb5QHIT2qK+jWxQWeWKQKeKp3+sQtqy2mjb0SoMw5ByLVJ7EWPBZiZfePeGh+2tJgNoF7Y+Y2a2YnR8/eW1Mva7W7KIrIs9h1Aoja8+RLKXlT5864empiWwVjepu7jcLewG5sV4BjP/9osKoCHIpSw3KW6Cjwx2ECrh/2fTO9o43VgdKn4akFQWlY6h2eTnfIEf2yZBwwh1cvsys3fz5uIx+jGV0SurltJjw85dMDqKtxBTlUNwYYlDwBX5L5oXG7KZfse+mnsDDX+k4XOp7UxXNsQQV7YlBsorPM1BRfOb4ZqFdtoCgvpsn695wlcplDuY+L9bEtsvJkM5f9cQqkSatNktGkilM1yYUg02sl1bhor6KVhx3klyJ35TgJUsaqpFhR+9OYVSi1uzqqJUtbeAQF/OQ2rDOtF5Eh9GIOeTTPqDMGNoSRaxJgfz9dZhL8onTsXbrB72lAW8/KgwQ4mpeolVHT5wt5t+UEk0jasUtw56x1VkDqo7u5Vb6FvNKAw2ABcKxrYZapimJe7BEon+NgfuwSWmfP336iz7iohx0cKb8NnCq7lDmhub/B/a5zDJIH/9PugPwuBm0S/fnmoJYlSlI55OBU3OuCNIN56o9R9xWXmbAbZmQaKFFpB1ySwp35 WydCYOsw ifcpViOMHuM9mi0agzY/kPBe7OeBuyTbtjlBl2xORdRUjbbJL1FW+b7rbM5K0h2SwoPlkxVy7s2G3J/GzzhEEdTgfnrz1xFF0N/P1sQeXpnqHdR6krUA157RD1lyZ3Q/SbZ+FhYb6VlFQwxLcQhiTl/iBX01lZnUtkwvtLk27H54JY7acW6hubUwQD3dy9WdiSqG0HWmhRnQQM3UtXWKZLNOCDwh4mRWnIBZLgY4BlqoKsAFX/TYo/MSV5mXpZDjwYfpJ8LWa3+U2nz9Q204Z4HUv8rq5e2BAeqgFnadmNAwWz9hHJG/AblMh9kVRUu7escpShEQKJ/9EvXlSWmFdb3ylIMTTQ+xTyuQn 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 A single RPC transaction that touches only a couple of pages means rq_pvec will not be even close to full in svc_xpt_release(). This is a common case. Instead, just leave the pages in rq_pvec until it is completely full. This improves the efficiency of the batch release mechanism on workloads that involve small RPC messages. The rq_pvec is also fully emptied just before thread exit. Signed-off-by: Chuck Lever --- net/sunrpc/svc.c | 3 +++ net/sunrpc/svc_xprt.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index b982f802f2a0..26367cf4c17a 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -649,6 +649,8 @@ svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node) if (!rqstp) return rqstp; + pagevec_init(&rqstp->rq_pvec); + __set_bit(RQ_BUSY, &rqstp->rq_flags); rqstp->rq_server = serv; rqstp->rq_pool = pool; @@ -894,6 +896,7 @@ void svc_rqst_release_pages(struct svc_rqst *rqstp) void svc_rqst_free(struct svc_rqst *rqstp) { + pagevec_release(&rqstp->rq_pvec); svc_release_buffer(rqstp); if (rqstp->rq_scratch_page) put_page(rqstp->rq_scratch_page); diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 533e08c4f319..e3952b690f54 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -541,7 +541,6 @@ static void svc_xprt_release(struct svc_rqst *rqstp) kfree(rqstp->rq_deferred); rqstp->rq_deferred = NULL; - pagevec_release(&rqstp->rq_pvec); svc_rqst_release_pages(rqstp); rqstp->rq_res.page_len = 0; rqstp->rq_res.page_base = 0; @@ -667,8 +666,6 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) struct xdr_buf *arg = &rqstp->rq_arg; unsigned long pages, filled, ret; - pagevec_init(&rqstp->rq_pvec); - pages = (serv->sv_max_mesg + 2 * PAGE_SIZE) >> PAGE_SHIFT; if (pages > RPCSVC_MAXPAGES) { pr_warn_once("svc: warning: pages=%lu > RPCSVC_MAXPAGES=%lu\n",