mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Linxuan <chenlinxuan@uniontech.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>,
	Gao Xiang <xiang@kernel.org>,  Chao Yu <chao@kernel.org>,
	Yue Hu <zbestahu@gmail.com>,
	Jeffle Xu <jefflexu@linux.alibaba.com>,
	 Sandeep Dhavale <dhavale@google.com>
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] erofs(shrinker): return SHRINK_EMPTY if no objects to free
Date: Thu, 16 Jan 2025 16:24:56 +0800	[thread overview]
Message-ID: <AC9D4F55C39C7580+c01e5ccb2bf8f14644d02a84ccc834ad49f86fbb.camel@uniontech.com> (raw)
In-Reply-To: <b33944b1-18fa-4a27-858f-5922ea1e1003@linux.alibaba.com>

On Thu, 2025-01-16 at 15:51 +0800, Gao Xiang wrote:
> 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..

Sorry, I have no idea about that.

> 
> > 
> > Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.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,
> 
> 
> 


  reply	other threads:[~2025-01-16  8:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16  7:20 Chen Linxuan
2025-01-16  7:51 ` Gao Xiang
2025-01-16  8:24   ` Chen Linxuan [this message]
2025-01-16  8:45     ` Gao Xiang
2025-01-16  8:48       ` Chen Linxuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AC9D4F55C39C7580+c01e5ccb2bf8f14644d02a84ccc834ad49f86fbb.camel@uniontech.com \
    --to=chenlinxuan@uniontech.com \
    --cc=chao@kernel.org \
    --cc=dhavale@google.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    --cc=zbestahu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®