Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3150433pxb; Sun, 29 Aug 2021 15:37:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXmowKS0S4iyLb/KnfNlxd2hnCHa7Apd4JSjhIoYeD/3VMMclOSW+6vofksf1gnBrnfQtJ X-Received: by 2002:a17:906:f24d:: with SMTP id gy13mr17045085ejb.395.1630276636790; Sun, 29 Aug 2021 15:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630276636; cv=none; d=google.com; s=arc-20160816; b=u9xN2nW03kVqIFbW64ehVpv/Z0GjCd1q4R802yY4eylEQgMHQzSoVo38YIqwye9uBp JLUstGFcW3lO8YMM5ZUQcbImESSIBTuCMC83MU+yyzj4qK4Fh6Aq57lKstrua7K5QFLZ xEZROiF5xWpL7zuLP8j/yVxchfy1HINaFut8NNr7DsEizdJQGGiTZtYn84yDesU2ZAkF Qrpbky+aslums1ExWWK3tHT5eLf4DO7ZzpQLnCx3v6mCCkYt8KRs/pA1e+zrUo5RgSBj /9ISf2mulSfyOrmuMM57BdpUOxJFKpUsQhjiigZ9uKbjDHSoitOf5/aVaut4dR9EKQML CTVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=6ERyju+YGgckczfvqFNw8PPOmwWjSJxho30DW5PrBO0=; b=YXgtS5Nxvtsr40c/T7eO0mPgVqRaeNdGVDc1PL8Ps6R+1R8NUk3ZvtZ/8h4Pd8tmlR oAupi+9MTYsP1mIHzK8dZrE9k3LSmSlar8QM1Ryl5TMW3T/Yr24tCA211sTyc2P8P2JO o/WGDn0xj9T0dRPtfi2lTw7xuoWWtOn3xsfGCn3ENyUpUQzhtkDc3fuxdFluDCFz8Sn8 CvCsS1+dfCSTJU1x5752E6L9XXKIX5KkReZ6EJvnhTgGrPMVPyWTR7gOQAskzjtGM6/6 vbJ/7dkx9Qw6lgRiceSEZYrJu7UlOvQAfobTWpno94FcEqbaeAYi3BBKntZuLgAIkbIe UGbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="K4ooxdP/"; dkim=neutral (no key) header.i=@suse.de; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si12750615edd.193.2021.08.29.15.36.41; Sun, 29 Aug 2021 15:37:16 -0700 (PDT) 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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="K4ooxdP/"; dkim=neutral (no key) header.i=@suse.de; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234860AbhH2Whc (ORCPT + 99 others); Sun, 29 Aug 2021 18:37:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:57196 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbhH2Whc (ORCPT ); Sun, 29 Aug 2021 18:37:32 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C7C62202C; Sun, 29 Aug 2021 22:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1630276599; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6ERyju+YGgckczfvqFNw8PPOmwWjSJxho30DW5PrBO0=; b=K4ooxdP/3lxmCVrAErsqGPJ86EIL/UamBpFiSNnHJQIFeciFMKHi/34HBnfzQ+xqR+xGsa kqZCumxcOGbUmJGYZco4w0IeD6ITBYKaKIpKWMpcCEijEw6Pwu7l0oGAwgFnmQNLEj4LWl WfhAiJcSKNwpwaEGpEwpA/HehrMXTVM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1630276599; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6ERyju+YGgckczfvqFNw8PPOmwWjSJxho30DW5PrBO0=; b=gDvfE4NVoofWJzgsB0rRSCYQwxQcH7lciZ6qPkhvnZrlZITO5A2CfdM7vz9Y3bdycN2Qu5 SDK4mlA1/HO+Z2Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BFC1513216; Sun, 29 Aug 2021 22:36:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9Q5VH/ULLGGORgAAMHmgww (envelope-from ); Sun, 29 Aug 2021 22:36:37 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" Cc: "Mike Javorski" , "Mel Gorman" , "Linux NFS Mailing List" Subject: [PATCH] SUNRPC: don't pause on incomplete allocation In-reply-to: <12B831AA-4A4E-4102-ADA3-97B6FA0B119E@oracle.com> References: , <162846730406.22632.14734595494457390936@noble.neil.brown.name>, , , <162855893202.12431.3423894387218130632@noble.neil.brown.name>, , <162882238416.1695.4958036322575947783@noble.neil.brown.name>, , , <162907681945.1695.10796003189432247877@noble.neil.brown.name>, <87777C39-BDDA-4E1E-83FA-5B46918A66D3@oracle.com>, , <162915491276.9892.7049267765583701172@noble.neil.brown.name>, <162941948235.9892.6790956894845282568@noble.neil.brown.name>, , , <162960371884.9892.13803244995043191094@noble.neil.brown.name>, , <162966962721.9892.5962616727949224286@noble.neil.brown.name>, , <163001427749.7591.7281634750945934559@noble.neil.brown.name>, , <163004202961.7591.12633163545286005205@noble.neil.brown.name>, , <163004848514.7591.2757618782251492498@noble.neil.brown.name>, <6CC9C852-CEE3-4657-86AD-9D5759E2BE1C@oracle.com>, , , <416268C9-BEAC-483C-9392-8139340BC849@oracle.com>, , <12B831AA-4A4E-4102-ADA3-97B6FA0B119E@oracle.com> Date: Mon, 30 Aug 2021 08:36:34 +1000 Message-id: <163027659478.7591.8897815399981483759@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org alloc_pages_bulk_array() attempts to allocate at least one page based on the provided pages, and then opportunistically allocates more if that can be done without dropping the spinlock. So if it returns fewer than requested, that could just mean that it needed to drop the lock. In that case, try again immediately. Only pause for a time if no progress could be made. Reported-and-tested-by: Mike Javorski Reported-and-tested-by: Lothar Paltins Fixes: f6e70aab9dfe ("SUNRPC: refresh rq_pages using a bulk page allocator") Signed-off-by: NeilBrown --- I decided I would resend, as I thought the for() loops could be clearer. This patch should perform exactly the same as the previous one. net/sunrpc/svc_xprt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index d66a8e44a1ae..e74d5cf3cbb4 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -662,7 +662,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) { struct svc_serv *serv = rqstp->rq_server; struct xdr_buf *arg = &rqstp->rq_arg; - unsigned long pages, filled; + unsigned long pages, filled, ret; pages = (serv->sv_max_mesg + 2 * PAGE_SIZE) >> PAGE_SHIFT; if (pages > RPCSVC_MAXPAGES) { @@ -672,11 +672,12 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) pages = RPCSVC_MAXPAGES; } - for (;;) { - filled = alloc_pages_bulk_array(GFP_KERNEL, pages, - rqstp->rq_pages); - if (filled == pages) - break; + for (filled = 0; filled < pages; filled = ret) { + ret = alloc_pages_bulk_array(GFP_KERNEL, pages, + rqstp->rq_pages); + if (ret > filled) + /* Made progress, don't sleep yet */ + continue; set_current_state(TASK_INTERRUPTIBLE); if (signalled() || kthread_should_stop()) { -- 2.32.0