From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65BCC7083D for ; Thu, 16 Jan 2025 07:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737013878; cv=none; b=MdkdcBt/1C1zNJHU9U5/jTzMDPV08MiLWy+ZH5J+vti2l9Cw600c5Y0/7vLJ3CJuQXWPuZSvDHEUGTbOv6n4qi+gEarEnmEidObIJa+JgUikil+xfHZS2bev5iTtzLMwhKhoBHgDzvTAQt0alQyfXmp9eQexMU4GMleXBmd8lvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737013878; c=relaxed/simple; bh=msPm2hCle81/oXHwljJVLi7GT4eiGLi9NgiNKR4buAs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T+kJqAKhGNbqRRYEdsBhx2Kw9oT5OUxfd4bPvAZlvjL7op2L6gnMCuRmzEFfLOEQj0YO3QXBpyOpvJLvS0rW5AMxTRaAj7T4unb/6QRDthvFS6VSQtgIBWMGQPZSaQRVLL/zsb+oIMTNCsLYxfpKSjhDBEFEGJylsSWs0X1BN04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=J/2Bv0w1; arc=none smtp.client-ip=115.124.30.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="J/2Bv0w1" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1737013873; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=5/uQUXKHYLMtTWj1lVfWlv4rTg4eAI8aIXpMUNNc0hU=; b=J/2Bv0w19eKG051O2SLpBhkM+z+j0G69+OGUYvthmHashhO3EWsgcYMajuKmoEGSPh+y/GdKVOq9wRQ6Fr7LkfyR55KeGY0MuqK95caJca3NkSH+Bd9mSzz+Di3J4EHJQJ+u3yTE4aa4fJW4boV77Dq6kb8lBzlCnh5pw+Oz8Nk= Received: from 30.221.130.221(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WNksvNR_1737013872 cluster:ay36) by smtp.aliyun-inc.com; Thu, 16 Jan 2025 15:51:13 +0800 Message-ID: Date: Thu, 16 Jan 2025 15:51:12 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs(shrinker): return SHRINK_EMPTY if no objects to free To: Chen Linxuan , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Sandeep Dhavale Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <433DB98624BCDF95+20250116072042.189710-1-chenlinxuan@uniontech.com> From: Gao Xiang In-Reply-To: <433DB98624BCDF95+20250116072042.189710-1-chenlinxuan@uniontech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Linxuan, On 2025/1/16 15:20, Chen Linxuan wrote: > Comments in file include/linux/shrinker.h says that > `count_objects` of `struct shrinker` should return SHRINK_EMPTY > when there are no objects to free. > >> If there are no objects to free, it should return SHRINK_EMPTY, >> while 0 is returned in cases of the number of freeable items cannot >> be determined or shrinker should skip this cache for this time >> (e.g., their number is below shrinkable limit). Thanks for the patch! Yeah, it seems that is the case. Yet it'd better to document what the impact if 0 is returned here if you know more.. > > Signed-off-by: Chen Linxuan > --- > fs/erofs/zutil.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c > index 0dd65cefce33..682863fa9e1c 100644 > --- a/fs/erofs/zutil.c > +++ b/fs/erofs/zutil.c > @@ -243,7 +243,9 @@ void erofs_shrinker_unregister(struct super_block *sb) > static unsigned long erofs_shrink_count(struct shrinker *shrink, > struct shrink_control *sc) > { > - return atomic_long_read(&erofs_global_shrink_cnt); > + unsigned long count = atomic_long_read(&erofs_global_shrink_cnt); > + > + return count ? count : SHRINK_EMPTY; I guess you could just use return atomic_long_read(&erofs_global_shrink_cnt) ?: SHRINK_EMPTY; Thanks, Gao Xiang > } > > static unsigned long erofs_shrink_scan(struct shrinker *shrink,