Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2586562ioo; Sat, 28 May 2022 19:32:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqR8YVI+G8eCzFMuaRpqlR5n6Y9+Oi/gtH2bkhrOCTndH0R2KJizSPvCYePFbsfUq7UAWG X-Received: by 2002:a05:6a00:2488:b0:518:afb4:bb60 with SMTP id c8-20020a056a00248800b00518afb4bb60mr29745855pfv.51.1653791555603; Sat, 28 May 2022 19:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653791555; cv=none; d=google.com; s=arc-20160816; b=Gt4gZCeLltcfgCh7ZfX9QxXN+eXdbr8p81NStgWTWi3KLVC02z8uL8TdOGXkSAiXT0 NpTawKj0GGJqpg3pNcJ6e8dzObArxOTIM7CZTiVCuCrGoRnIeqHkBvuaqF3miGQMihff 5ew6els7wNYORoRh+mOUeTPCNWWo3vMZgSNcabP0UorDn30QpuSCT0YDJ/u35fS4xOje uUd9H/yW43oE52b10SQWKkyuLN/PNASmi2L+PF6ZHxts1g/mRRW0RYgZyfP6Hx2isEdG WWlsf9KuhF+zOs1TAvG+HM+pNs3CeXCivjJWnKp2+hd9Pn+W6YJdDfJw2lyMu/VkyxcL twXQ== 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 :message-id:references:in-reply-to:cc:subject:to:from:date; bh=GNF0JdynYO/tCJlwrTW6u5/2jLBfD6Gmbp836bpnD50=; b=muaijbmNZTdKhh7TzULKB7g2F/mJEmVJqWdSw+aT2J6KYDP8WtNIxcH0+06Nr+1qyr OlmH8rzqknxHUsKCz8nbnAoAZ0F2xW5pdmqyoCWRLP5a4tq4IyF5VkgpSX39O9db9vdL cRNIXS6qWs2agNtnYiEv2ihIMuH7hmH7Umrm/9CGuOSEKc74LtUlk210bZmcZPaEWN7F YSYiKfnv88w5ZhtnHi1LeR2DZ5FZGOnNt/BdexJEVEAD5WrsjRs5H2IDlgtp+Vp7nVkR k8Tf5+Hmkl8QDgAY0EZRAlVjghU9dktSjKHvMnzoDtpd1xHqV6Mq43jW+9uSqwA31HYR EgMA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g2-20020a056a0023c200b0050d4affda05si10119529pfc.214.2022.05.28.19.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 19:32:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 174765B3FE; Sat, 28 May 2022 19:32:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbiE2Ccb (ORCPT + 99 others); Sat, 28 May 2022 22:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiE2Ccb (ORCPT ); Sat, 28 May 2022 22:32:31 -0400 Received: from out20-206.mail.aliyun.com (out20-206.mail.aliyun.com [115.124.20.206]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00B45B3FE for ; Sat, 28 May 2022 19:32:21 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.04948568|-1;BR=01201311R121S10rulernew998_84748_2000303;CH=blue;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0186616-0.00150413-0.979834;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047202;MF=wangyugui@e16-tech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.NuwvtCj_1653791538; Received: from 192.168.2.112(mailfrom:wangyugui@e16-tech.com fp:SMTPD_---.NuwvtCj_1653791538) by smtp.aliyun-inc.com(33.37.77.208); Sun, 29 May 2022 10:32:19 +0800 Date: Sun, 29 May 2022 10:32:19 +0800 From: Wang Yugui To: Chuck Lever III Subject: Re: filecache LRU performance regression Cc: Frank van der Linden , Linux NFS Mailing List , Matthew Wilcox , Liam Howlett In-Reply-To: References: <20220527203721.GA10628@dev-dsk-fllinden-2c-d7720709.us-west-2.amazon.com> Message-Id: <20220529103218.65DA.409509F4@e16-tech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.75.04 [en] X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 Hi, > > > > On May 27, 2022, at 4:37 PM, Frank van der Linden wrote: > > > > On Fri, May 27, 2022 at 06:59:47PM +0000, Chuck Lever III wrote: > >> > >> > >> Hi Frank- > >> > >> Bruce recently reminded me about this issue. Is there a bugzilla somewhere? > >> Do you have a reproducer I can try? > > > > Hi Chuck, > > > > The easiest way to reproduce the issue is to run generic/531 over an > > NFSv4 mount, using a system with a larger number of CPUs on the client > > side (or just scaling the test up manually - it has a calculation based > > on the number of CPUs). > > > > The test will take a long time to finish. I initially described the > > details here: > > > > https://lore.kernel.org/linux-nfs/20200608192122.GA19171@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com/ > > > > Since then, it was also reported here: > > > > https://lore.kernel.org/all/20210531125948.2D37.409509F4@e16-tech.com/T/#m8c3e4173696e17a9d5903d2a619550f352314d20 > > Thanks for the summary. So, there isn't a bugzilla tracking this > issue? If not, please create one here: > > https://bugzilla.linux-nfs.org/ > > Then we don't have to keep asking for a repeat summary ;-) > > > > I posted an experimental patch, but it's actually not quite correct > > (although I think the idea behind it is makes sense): > > > > https://lore.kernel.org/linux-nfs/20201020183718.14618-4-trondmy@kernel.org/T/#m869aa427f125afee2af9a89d569c6b98e12e516f > > A handful of random comments: > > - nfsd_file_put() is now significantly different than it used > to be, so that part of the patch will have to be updated in > order to apply to v5.18+ When many open files(>NFSD_FILE_LRU_THRESHOLD), nfsd_file_gc() will waste many CPU times. Can we serialize nfsd_file_gc() for v5.18+ as a first step? diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 3d944ca..6abefd9 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -63,6 +63,8 @@ static struct delayed_work nfsd_filecache_laundrette; static void nfsd_file_gc(void); +static atomic_t nfsd_file_gc_queue_delayed = ATOMIC_INIT(0); + static void nfsd_file_schedule_laundrette(void) { @@ -71,8 +73,10 @@ nfsd_file_schedule_laundrette(void) if (count == 0 || test_bit(NFSD_FILE_SHUTDOWN, &nfsd_file_lru_flags)) return; - queue_delayed_work(system_wq, &nfsd_filecache_laundrette, + if(atomic_cmpxchg(&nfsd_file_gc_queue_delayed, 0, 1)==0){ + queue_delayed_work(system_wq, &nfsd_filecache_laundrette, NFSD_LAUNDRETTE_DELAY); + } } static void @@ -468,15 +472,22 @@ nfsd_file_lru_walk_list(struct shrink_control *sc) return ret; } +// nfsd_file_gc() support concurrency, but serialize it +atomic_t nfsd_file_gc_running = ATOMIC_INIT(0); static void nfsd_file_gc(void) { - nfsd_file_lru_walk_list(NULL); + if(atomic_cmpxchg(&nfsd_file_gc_running, 0, 1)==0){ + nfsd_file_lru_walk_list(NULL); + atomic_set(&nfsd_file_gc_running, 0); + } } static void nfsd_file_gc_worker(struct work_struct *work) { + atomic_set(&nfsd_file_gc_queue_delayed, 0); + // pr_info("nfsd_file_gc_worker\n"); nfsd_file_gc(); nfsd_file_schedule_laundrette(); } Best Regards Wang Yugui (wangyugui@e16-tech.com) 2022/05/29