lkml.org 
[lkml]   [2023]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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!

\
 
 \ /
  Last update: 2023-11-23 22:24    [W:0.914 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site