Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4207185iog; Tue, 28 Jun 2022 11:08:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2Ieai3FssDMfctNyPCp8p6XQixrtzhQhsPKb3kp4VY+Uv6FDDhE/b1+U//CKtbBNquhXw X-Received: by 2002:a05:6a00:1a0c:b0:523:1a23:957f with SMTP id g12-20020a056a001a0c00b005231a23957fmr5992635pfv.45.1656439695312; Tue, 28 Jun 2022 11:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656439695; cv=none; d=google.com; s=arc-20160816; b=jtRuAhLx3Vihzlc7kpjMT/zmBYPtjkBt6Jm9DOldoRA2NZnrrvzD1aivUKkth+KXnp uD7SBQGdMXRRIZp6N/6FvXN5xd23WSkvqCodJP+tUKmN5VnpgMHxCllpONM1DHxlb3ed WXYs3kVCx4QKHsB58H0XqT/pwoPQaXVbuwB+Rfp2fyIJNd6CJvIKTSg3KKuF/+VaStSl JnS8IWjdq45g4Q0ShvXs+IEZl0xdEB/QhfxGTeDM9eRyUWd/ouRXpZWXb50L4xoIZCSx JdOK4yAJ0nDkI8Egz0Zxi4sx0OEzDl38vt/0aG7BQd1t1axJdRZ7K9n9vKij9j9eu7yd X+Qw== 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=nOnOx4ubl8c8TXb9bXtTkHLmyPmeDBLV3qrU+USM+euRAN845TrrM+on3hJbdlSw2p BAw7Be00S3E2BZmKBwotn6WlPM5ePGOf1wyuxQvaF5wya91VJGW+xQBs5AVABQerAlVE W2ugslZnQJ+E6OjpdhWjbTxwSUlbNHT5CFda+Z+7VYclGfrt/0ZOINrtJoUCFeBPe4Je NkYFHyDpqzQMT4xGNlrDnjz3XSdT1PnUukvLon2j6FEFd+xNjYHCuZpZzXa7jRqdTrl/ 8Wt1LF2jgpbfmWkRku34yPXlsNec8oOEZWuoNQYH101HmCFNxd48y9acOJsjKb9Qs9eA RVnQ== 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 a30-20020a631a5e000000b003fc75297697si20467607pgm.4.2022.06.28.11.08.02; Tue, 28 Jun 2022 11:08:15 -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 S234217AbiF1SHe (ORCPT + 99 others); Tue, 28 Jun 2022 14:07:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiF1SHd (ORCPT ); Tue, 28 Jun 2022 14:07:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F63A1EAE8; Tue, 28 Jun 2022 11:07:32 -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 29CCC61ADB; Tue, 28 Jun 2022 18:07:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B083C3411D; Tue, 28 Jun 2022 18:07:31 +0000 (UTC) Subject: [PATCH v2 16/31] 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: Tue, 28 Jun 2022 14:07:30 -0400 Message-ID: <165643965013.84360.5320447476976778288.stgit@manet.1015granger.net> In-Reply-To: <165643915086.84360.2809940286726976517.stgit@manet.1015granger.net> References: <165643915086.84360.2809940286726976517.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 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); }