From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4766C433FF for ; Mon, 29 Jul 2019 20:10:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C0DB20C01 for ; Mon, 29 Jul 2019 20:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564431021; bh=HPL6Nhe5E/wS/WEEQvxSmxVoRnNhEPYzgfz2ZIYUhjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ChNcW4oATP67ZQlLtnle+M29OkscfX0ZRmkU8/j3RN6jZUGELERHyXSlfXPSe2zcs YnaJA7YhR4gWLpwvqb4IWU3EyLeYs0Wzq50OjXK+IZtDBDIqxmnKvJF6qXItDIvBY1 lm/QNL5DCLIpcHtTTiyDnQIqKGY9Z3VgwF8w2c4M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbfG2Te6 (ORCPT ); Mon, 29 Jul 2019 15:34:58 -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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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