Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp774341imw; Fri, 8 Jul 2022 11:26:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6Yn2BM/I4pezzNzAAFvF3Db3PrHJTJMkm29vz5lfYYkuhNGxE1Xkz/PQIci6N0xcfAezR X-Received: by 2002:a17:90a:ca89:b0:1ef:7de9:ac45 with SMTP id y9-20020a17090aca8900b001ef7de9ac45mr1242869pjt.59.1657304776719; Fri, 08 Jul 2022 11:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657304776; cv=none; d=google.com; s=arc-20160816; b=EyoCTGzoHudxg5wAVmWkT1w+oRQiedG6ndupGt8p0omb/IxvMFGlLyM8yJAPvSUyDF dpROcuqQjX5Rri0DtUwVh7ZAoiP4LgvyHwRX+dfCz0fEZnIo7FUi2JYpIKT41BWNlJ99 uYLHVmhKG6jSNlhtE8ybOn6BldD/4TOiZgcsoPoEpMPZnUl0Kr+g/7pu9QTSu02e3lRG zjn5e2iK9Y9PQaPSMnQuoc94tecFwHF6pFClZVbUQxtXDSOKUiY6/Qv4OdLvwaexFGQM CYYwMAd26+BVu/L8BiovnaVwnsdFJpPgbaWTVpsYNiKErIpWhoNyRl9+Evy05g3aFE5j f6aw== 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:references:in-reply-to:message-id:date:cc:to:from :subject; bh=LZh/hZWM5EpsOWJUfOpoolWTTEZeZASGisJGqaP0l1E=; b=Sn1vtjjLV3ae3fWf6NV5JwQqv8ktqI0WCsMxYRhfkDZaCOt7fcilq6aH2Y0mBmf3L5 Hanr23PAmrDu6mVfS/vyhm966MlbOt/yRM0wo89zTZmDVceYXIFItEI80l63BcnR7xn6 6REuQ3ENca7Uvu85hop/y+i/Gcvs57vGPxyLMuEIfPtkdlj72JGUQjrBa8IOXZauNfs4 hBfPouH+JauVXKdVgO4j2jEnUPS6eXT5O/SuymI9dDYyDdeEqkj3XzmoovoR27t0gg6L Sl9qUCnB/TyBMZBg5V1nF3oFlzl6nZdaoXEiESEfyWC5emn1GlAvhbJbvbn7Xq+7pQim 8VDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a635c0d000000b003fe25580685si5299406pgb.349.2022.07.08.11.26.05; Fri, 08 Jul 2022 11:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239455AbiGHSZf (ORCPT + 99 others); Fri, 8 Jul 2022 14:25:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239458AbiGHSZ1 (ORCPT ); Fri, 8 Jul 2022 14:25:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3B8823B8; Fri, 8 Jul 2022 11:25:26 -0700 (PDT) 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 56DD7625AC; Fri, 8 Jul 2022 18:25:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 580BCC341C0; Fri, 8 Jul 2022 18:25:25 +0000 (UTC) Subject: [PATCH v3 16/32] NFSD: Fix the filecache LRU shrinker From: Chuck Lever To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: david@fromorbit.com, jlayton@redhat.com, tgraf@suug.ch Date: Fri, 08 Jul 2022 14:25:24 -0400 Message-ID: <165730472428.28142.17571886266553271473.stgit@klimt.1015granger.net> In-Reply-To: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> References: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Without LRU item rotation, the shrinker visits only a few items on the end of the LRU list, and those would always be long-term OPEN files for NFSv4 workloads. That makes the filecache shrinker completely ineffective. Adopt the same strategy as the inode LRU by using LRU_ROTATE. Suggested-by: Dave Chinner Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 6e9e186334ab..bd6ba63f69ae 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -452,6 +452,7 @@ nfsd_file_dispose_list_delayed(struct list_head *dispose) * * Return values: * %LRU_REMOVED: @item was removed from the LRU + * %LRU_ROTATED: @item is to be moved to the LRU tail * %LRU_SKIP: @item cannot be evicted */ static enum lru_status @@ -490,7 +491,7 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru, if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) { trace_nfsd_file_gc_referenced(nf); - return LRU_SKIP; + return LRU_ROTATE; } if (!test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { @@ -532,7 +533,7 @@ nfsd_file_gc(void) unsigned long ret; ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb, - &dispose, LONG_MAX); + &dispose, list_lru_count(&nfsd_file_lru)); trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru)); nfsd_file_gc_dispose_list(&dispose); }