[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231123212411.s6r5ekvkklvhwfra@moria.home.lan>
Date: Thu, 23 Nov 2023 16:24:11 -0500
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Qi Zheng <arch0.zheng@...il.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Qi Zheng <zhengqi.arch@...edance.com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Dave Chinner <david@...morbit.com>
Subject: Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers
On Thu, Nov 23, 2023 at 11:32:59AM +0800, Qi Zheng wrote:
> > + void (*to_text)(struct seq_buf *, struct shrinker *);
>
> The "to_text" looks a little strange, how about naming it
> "stat_objects"?
The convention I've been using heavily in bcachefs is
typename_to_text(), or type.to_text(), for debug reports. The
consistency is nice.
>
> > long batch; /* reclaim batch size, 0 = default */
> > int seeks; /* seeks to recreate an obj */
> > @@ -110,7 +114,6 @@ struct shrinker {
> > #endif
> > #ifdef CONFIG_SHRINKER_DEBUG
> > int debugfs_id;
> > - const char *name;
>
> The name will only be allocated memory when the CONFIG_SHRINKER_DEBUG is
> enabled, otherwise its value is NULL. So you can't move it out and use
> it while CONFIG_SHRINKER_DEBUG is disabled.
Good catch
> > +void shrinkers_to_text(struct seq_buf *out)
> > +{
> > + struct shrinker *shrinker;
> > + struct shrinker_by_mem {
> > + struct shrinker *shrinker;
> > + unsigned long mem;
>
> The "mem" also looks a little strange, how about naming it
> "freeable"?
The type is just used in this one function, but sure.
>
> > + } shrinkers_by_mem[10];
> > + int i, nr = 0;
> > +
> > + if (!mutex_trylock(&shrinker_mutex)) {
> > + seq_buf_puts(out, "(couldn't take shrinker lock)");
> > + return;
> > + }
>
> We now have lockless method (RCU + refcount) to iterate shrinker_list,
> please refer to shrink_slab().
Will do!
Powered by blists - more mailing lists