Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4207209iog; Tue, 28 Jun 2022 11:08:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tYtIfzESSWBWGV2JQXlZXDAzqNnNUFsThNLjQqN2i7Z9vG1opsjX9Vy08Y2prT+aXIxx/F X-Received: by 2002:a17:902:b081:b0:16a:4266:b467 with SMTP id p1-20020a170902b08100b0016a4266b467mr5974524plr.172.1656439696900; Tue, 28 Jun 2022 11:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656439696; cv=none; d=google.com; s=arc-20160816; b=vySAQll+eT8V32XZhUR26MNsQroRdUwbses/ZQ/PqKRrT21z0xNsnlLaeMZgfkwnEO oVfJ/uLOSYwcboFSp/S8OFlG2RzlSsorTKUZ8Idl0U+XvQNbQcXDpFscOL9D7r9uAdiC TNA5GHqttwHKhhgDjsDRIek8ulxts6y0NBkR5RfhoYanUPZeNWzLG5ClAQ55dKQnFQBv I8grrZpDA8Epx4X0Z5H5nb2SzFPP26yJTLxioRYwmsF6D9tuYRD9R0FTbnuyWQldY8c5 XIESBIiwb1QuhhYzFC0lwsBNQwpo8kGteod3GlVkuKBZXjoMtBN+98dzm9ZtqjbjsrGC ZR2A== 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=omy8utYOhmD01ntOfOcLQGAKPoZBNvbyTcBvtpz+X4c=; b=yHlmYht/egZlgPowbkVgnJzR3NaG+hh//RabO9yQKOKE83cY9IH5lpVZzgWOvjWAa3 K80WdeD7IJuvpmZkgkgsJK/O5/NkjmluzAw1b2o3kithfe7VKOj0h5Ii+ZobxNUErkWH nETuBPaiu1CwWj47TnuZYFFeI/VuEXktl0jnj5JkPS573p5EEC9h3WMHMaJNSrAtudTF xC55xQGJyR7eZXEhcWgbr0n0SbbIM+goGw9Cmd5G+hxgWJJBeQVabmxLiE4ODfraWl6n xGezY5Q9ck16gbm5rlgftDQUgoVwoSHvNemmdNxG40jzWAgddZr2S9RFJgittj0hhV0q GXXQ== 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 y9-20020a056a00180900b0051e756bec27si22066612pfa.146.2022.06.28.11.08.04; Tue, 28 Jun 2022 11:08: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 S231657AbiF1SHp (ORCPT + 99 others); Tue, 28 Jun 2022 14:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232588AbiF1SHj (ORCPT ); Tue, 28 Jun 2022 14:07:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1021EC58; Tue, 28 Jun 2022 11:07:38 -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 8A81761AD5; Tue, 28 Jun 2022 18:07:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A250DC3411D; Tue, 28 Jun 2022 18:07:37 +0000 (UTC) Subject: [PATCH v2 17/31] NFSD: Never call nfsd_file_gc() in foreground paths 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:36 -0400 Message-ID: <165643965677.84360.11591963051893106165.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 The checks in nfsd_file_acquire() and nfsd_file_put() that directly invoke filecache garbage collection are intended to keep cache occupancy between a low- and high-watermark. The reason to limit the capacity of the filecache is to keep filecache lookups reasonably fast. However, invoking garbage collection at those points has some undesirable negative impacts. Files that are held open by NFSv4 clients often push the occupancy of the filecache over these watermarks. At that point: - Every call to nfsd_file_acquire() and nfsd_file_put() results in an LRU walk. This has the same effect on lookup latency as long chains in the hash table. - Garbage collection will then run on every nfsd thread, causing a lot of unnecessary lock contention. - Limiting cache capacity pushes out files used only by NFSv3 clients, which are the type of files the filecache is supposed to help. To address those negative impacts, remove the direct calls to the garbage collector. Subsequent patches will address maintaining lookup efficiency as cache capacity increases. Suggested-by: Wang Yugui Suggested-by: Dave Chinner Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index bd6ba63f69ae..faa8588663d6 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -29,8 +29,6 @@ #define NFSD_LAUNDRETTE_DELAY (2 * HZ) #define NFSD_FILE_SHUTDOWN (1) -#define NFSD_FILE_LRU_THRESHOLD (4096UL) -#define NFSD_FILE_LRU_LIMIT (NFSD_FILE_LRU_THRESHOLD << 2) /* We only care about NFSD_MAY_READ/WRITE for this cache */ #define NFSD_FILE_MAY_MASK (NFSD_MAY_READ|NFSD_MAY_WRITE) @@ -66,8 +64,6 @@ static struct fsnotify_group *nfsd_file_fsnotify_group; static atomic_long_t nfsd_filecache_count; static struct delayed_work nfsd_filecache_laundrette; -static void nfsd_file_gc(void); - static void nfsd_file_schedule_laundrette(void) { @@ -350,9 +346,6 @@ nfsd_file_put(struct nfsd_file *nf) nfsd_file_schedule_laundrette(); } else nfsd_file_put_noref(nf); - - if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT) - nfsd_file_gc(); } struct nfsd_file * @@ -1075,8 +1068,7 @@ nfsd_do_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, nfsd_file_hashtbl[hashval].nfb_maxcount = max(nfsd_file_hashtbl[hashval].nfb_maxcount, nfsd_file_hashtbl[hashval].nfb_count); spin_unlock(&nfsd_file_hashtbl[hashval].nfb_lock); - if (atomic_long_inc_return(&nfsd_filecache_count) >= NFSD_FILE_LRU_THRESHOLD) - nfsd_file_gc(); + atomic_long_inc(&nfsd_filecache_count); nf->nf_mark = nfsd_file_mark_find_or_create(nf); if (nf->nf_mark) {