lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b33944b1-18fa-4a27-858f-5922ea1e1003@linux.alibaba.com>
Date: Thu, 16 Jan 2025 15:51:12 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Chen Linxuan <chenlinxuan@...ontech.com>, Gao Xiang <xiang@...nel.org>,
 Chao Yu <chao@...nel.org>, Yue Hu <zbestahu@...il.com>,
 Jeffle Xu <jefflexu@...ux.alibaba.com>, Sandeep Dhavale <dhavale@...gle.com>
Cc: linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] erofs(shrinker): return SHRINK_EMPTY if no objects to
 free

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 <chenlinxuan@...ontech.com>
> ---
>   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,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ