Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3816764ybi; Mon, 29 Jul 2019 13:11:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3KBEurm5QOchcfd/INk2xW0Wlaidn3/iF2x7raUOjRfu4pUhBXPpY4qM2I2417BA90oX4 X-Received: by 2002:a63:9318:: with SMTP id b24mr94858738pge.31.1564431103050; Mon, 29 Jul 2019 13:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431103; cv=none; d=google.com; s=arc-20160816; b=zYOSKOCGRIW1+kVot/ZaOzmtqdCwrD6HPEgLGFa7q3iJAswV1C/p1n7RpNzaH3fRxZ CgcSX+CjSQFc1PcG21OtdcmG7OMSX5/CbD7r7+GjOBIVeABcIyANF2OaFvbhpbhq4stl 5d+enwQUhkg0eExLISaFHHAwX1iRNSsuyDoJtzxBr9qtgSqNBpWO9FIvQHzh80Iiiw+m YwU1Xq/NqYaRrkgc/BnUizuCXGxz17mBS8YNQBWDx20gDx/cg+xlvBSkhvLWsxnwgSjy MSPdbgDoBZtMv6L7J/FbQ0VXCxUz3ayqoVpEOZ39NqZjeTbR4xg0Vr8PFXIh7eoUh5r4 +Vjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z4Y8RrlFi8XcaMNWW73oU13Sw5dYr/G5/kNWm9k0bFI=; b=Oe4Soqu0Hlnx/i5GutlKXEt6osXaujXgYanVXIkJuQv6B4aGQyF8ulE8UxUBl8Iv2c Rr3ndQ80dMPWGyQHtmQaouuIQSMrRdLzq0iiUugVQVfreoS0wYGYCnEd3G9g+PGKlI2E 8xzqC2dmV2FB87e+8CW5vR1JbNAwMYIMhrsGdXlQah5FgHGubNRXnITfCop36DgI9/pR alTxNseKmT7Rojvt9gad6MdJ1b8r2IeNbfPUwtLSI/emnF2CRN+FsT3LePNc+3+Xsexs oMPmeDORlz6ki31NR4M2zG3KYrOXzuYM++ETy5B5nBx4JXyMhdtzR0zBzoVZp3FB0QL8 URNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z1xGlAqT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si26389679pgv.417.2019.07.29.13.11.28; Mon, 29 Jul 2019 13:11:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z1xGlAqT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfG2TfE (ORCPT + 99 others); Mon, 29 Jul 2019 15:35:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:49304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388498AbfG2Te4 (ORCPT ); Mon, 29 Jul 2019 15:34:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D25F92070B; Mon, 29 Jul 2019 19:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428895; bh=HPL6Nhe5E/wS/WEEQvxSmxVoRnNhEPYzgfz2ZIYUhjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z1xGlAqTd6lLQJ1JB5kDeXbOiyhSaxg32fyuqcLeLR/qswiG0AVfTv6UUjBoQeS4O XSmeLPSXhtE2j5HbACsTnZcmy9B6KGxprr0l6DwoSBKBJE1EAUKTgl9PywpKXqeLgc E+LQlu83HgpgU5OXsVxWKYa3hcWNf7F7eoEZocnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Tracy , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 4.14 219/293] nfsd: fix performance-limiting session calculation Date: Mon, 29 Jul 2019 21:21:50 +0200 Message-Id: <20190729190841.287748515@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c54f24e338ed2a35218f117a4a1afb5f9e2b4e64 ] We're unintentionally limiting the number of slots per nfsv4.1 session to 10. Often more than 10 simultaneous RPCs are needed for the best performance. This calculation was meant to prevent any one client from using up more than a third of the limit we set for total memory use across all clients and sessions. Instead, it's limiting the client to a third of the maximum for a single session. Fix this. Reported-by: Chris Tracy Cc: stable@vger.kernel.org Fixes: de766e570413 "nfsd: give out fewer session slots as limit approaches" Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/nfs4state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index dd48353357d7..0bf88876c889 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1502,16 +1502,16 @@ static u32 nfsd4_get_drc_mem(struct nfsd4_channel_attrs *ca) { u32 slotsize = slot_bytes(ca); u32 num = ca->maxreqs; - int avail; + unsigned long avail, total_avail; spin_lock(&nfsd_drc_lock); - avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION, - nfsd_drc_max_mem - nfsd_drc_mem_used); + total_avail = nfsd_drc_max_mem - nfsd_drc_mem_used; + avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION, total_avail); /* * Never use more than a third of the remaining memory, * unless it's the only way to give this client a slot: */ - avail = clamp_t(int, avail, slotsize, avail/3); + avail = clamp_t(int, avail, slotsize, total_avail/3); num = min_t(int, num, avail / slotsize); nfsd_drc_mem_used += num * slotsize; spin_unlock(&nfsd_drc_lock); -- 2.20.1