Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1314987pxb; Fri, 22 Jan 2021 12:23:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcnIOIWi8jQq2adQUJ+xGgHvvg5j2mOHCU9PKW9zyXkyBZrr6WbGBcmbDcLHZ6ld2ipkHs X-Received: by 2002:a17:906:ada:: with SMTP id z26mr4180167ejf.127.1611347015054; Fri, 22 Jan 2021 12:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611347015; cv=none; d=google.com; s=arc-20160816; b=Y7hMQRbDvZssaeXpPEFkN3nyyzUf9NKA5pTHYh+OSzJ9Fl6l/aUyRcfHj9Nr6vqPZ1 6D9B6EmJme7AS/2V3H61+yMil+KgMjD1RpgBWGegsclrxVEAMigICvn14Xwj+MSGlGBC 1HjaTo+xXh+/uM0oJxlbq4nqqM77outg8qmjuC5dtqpyRExzS6G//yEZX5PRbr2BCTZ7 iPF5CbyAJ4VF2Y4MQhas/rvDEEt7b3j08cUVrxyb1/7XHLN+SgfijzLH5yLmt2W+m4lJ 9I32KNVCHRonIsII1cifGaiILKuXlqh/cCNfG0b/A4alYcilTzw2JsXUf06gHgbW/uPM 9e6w== 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 :user-agent:message-id:date:to:from:subject; bh=Slt1gC+A7c7SvTmB39aw/X3af7pljQLw3h8AoIZv+CY=; b=JiOkXLpFszQHTZriytoNwY1OAYrsu1uyUlj7Fg7QDmL7gT9nSQ541Pq39ubKJkB6wE iIuIxHVnHKi8t3H9p16CbKPx4AAWnHAFsiJBRpy9Nx3JKADyxJsQVDWJ0KYv7vpZfI0J uidhK7Mh4M6kUQz3BNy+U6KIJPLk14q1+KTKpdlPPmjqVaeVE03SNFeBwPYPUiKpNsA0 CB42nNmHxaRhRazo7ev6H2eKl9DJm5h5mOxcMtofbn1wXarh59NK/XCr4u9CmjcReRuW eljJI+43QxrO6+T1IkZrvNJ0NvNOqUzh5Wis+O3pg6f90jFsaUBVSs3z5DHwsXbHTVq7 g/Pg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si3340125eje.293.2021.01.22.12.23.01; Fri, 22 Jan 2021 12:23:35 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbhAVUWs (ORCPT + 99 others); Fri, 22 Jan 2021 15:22:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:42052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728368AbhAVUVw (ORCPT ); Fri, 22 Jan 2021 15:21:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D21F23AFC for ; Fri, 22 Jan 2021 20:21:11 +0000 (UTC) Subject: [PATCH RFC] NFSD: Reduce svc_rqst::rq_pages churn during READDIR operations From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 22 Jan 2021 15:21:10 -0500 Message-ID: <161134687025.19311.4882007133082076189.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org During NFSv2 and NFSv3 READDIR/PLUS operations, NFSD advances rq_next_page to the full size of the client-requested buffer, then releases all those pages at the end of the request. The next request to use that nfsd thread has to refill the pages. NFSD does this even when the dirlist in the reply is small. With NFSv3 clients that send READDIR operations with large buffer sizes, that can be 256 put_page/alloc_page pairs per READDIR request, even though those pages often remain unused. We can save some work by not releasing dirlist buffer pages that were not used to form the READDIR Reply. I've left the NFSv2 code alone since there are never more than three pages involved in an NFSv2 READDIR operation. Eventually we should nail down why these pages need to be released at all in order to avoid allocating and releasing pages unnecessarily. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 8675851199f8..569bfff314f0 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -492,6 +492,7 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp) } count += PAGE_SIZE; } + rqstp->rq_next_page = p; resp->count = count >> 2; if (resp->offset) { if (unlikely(resp->offset1)) { @@ -557,6 +558,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp) } count += PAGE_SIZE; } + rqstp->rq_next_page = p; resp->count = count >> 2; if (resp->offset) { if (unlikely(resp->offset1)) {