Message ID | 20220530012947.16451-1-wangyugui@e16-tech.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | nfsd: serialize filecache garbage collector | expand |
Hi Wang,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.18 next-20220527]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Wang-Yugui/nfsd-serialize-filecache-garbage-collector/20220530-093218
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b00ed48bb0a7c295facf9036135a573a5cdbe7de
config: x86_64-randconfig-s021 (https://download.01.org/0day-ci/archive/20220531/202205311402.i5by7a5m-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-14-g5a0004b5-dirty
# https://github.com/intel-lab-lkp/linux/commit/7e2af8570695784cb8a9f9a3931dc631a9077206
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Wang-Yugui/nfsd-serialize-filecache-garbage-collector/20220530-093218
git checkout 7e2af8570695784cb8a9f9a3931dc631a9077206
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/nfsd/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> fs/nfsd/filecache.c:475:10: sparse: sparse: symbol 'nfsd_file_gc_running' was not declared. Should it be static?
Please review and possibly fold the followup patch.
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index f172412447f5..28a8f8d6d235 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -471,10 +471,15 @@ nfsd_file_lru_walk_list(struct shrink_control *sc) return ret; } +/* concurrency nfsd_file_gc() is almost meaningless, so 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
When many(>NFSD_FILE_LRU_THRESHOLD) files are kept as OPEN, such as xfstests generic/531, nfsd proceses are in CPU high-load state, and nfsd_file_gc(nfsd filecache garbage collector) waste many CPU times. concurrency nfsd_file_gc() is almost meaningless, so serialize it. Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> --- fs/nfsd/filecache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)