linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Ruipeng Qi <ruipengqi7@gmail.com>
Cc: cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com,
	 akpm@linux-foundation.org, vbabka@suse.cz,
	roman.gushchin@linux.dev,  42.hyeyoo@gmail.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 qiruipeng <qiruipeng@lixiang.com>
Subject: Re: [RFC PATCH 6/7] mm/slub: make slab data more observable
Date: Thu, 21 Dec 2023 13:50:44 -0800 (PST)	[thread overview]
Message-ID: <9cb6a9a3-25fb-22ca-8b62-52c60519bee2@google.com> (raw)
In-Reply-To: <20231221133717.882-1-ruipengqi7@gmail.com>

On Thu, 21 Dec 2023, Ruipeng Qi wrote:

> From: qiruipeng <qiruipeng@lixiang.com>
> 
> Osdump is interested in data stored within slab subsystem. Add full list
> back into corresponding struct, and record full list within respective
> functions instead of enabling SLUB_DEBUG directly, which will intruduce
> sensible overhead.
> 
> Signed-off-by: qiruipeng <qiruipeng@lixiang.com>

Hi Ruipeng, please make sure to send your patch sets as a single email 
thread (all patches 1-7 should be a reply to your 0/7 cover letter).

There is some other feedback on previous patches in this series which 
refers to alternatives, so I think the cover letter to the patch series 
will need to spell out why we need a brand new solution to this.

That said, from the slab perspective, this is basically splitting out a 
part of SLUB_DEBUG into a single feature.  Likely best to propose it as a 
feature that SLUB_DEBUG would then directly enable itself rather than 
duplicating code in definitions.

That is, assuming the question about why we need a new solution for this 
can be resolved in the cover letter of a v2.

> ---
>  mm/slab.h |  2 ++
>  mm/slub.c | 38 +++++++++++++++++++++++++++++++++++++-
>  2 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/slab.h b/mm/slab.h
> index 3d07fb428393..a42a54c9c5de 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -799,6 +799,8 @@ struct kmem_cache_node {
>  	atomic_long_t nr_slabs;
>  	atomic_long_t total_objects;
>  	struct list_head full;
> +#elif defined(CONFIG_OS_MINIDUMP)
> +	struct list_head full;
>  #endif
>  #endif
>  
> diff --git a/mm/slub.c b/mm/slub.c
> index 63d281dfacdb..1a496ec945b6 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1730,10 +1730,26 @@ static inline int check_object(struct kmem_cache *s, struct slab *slab,
>  static inline depot_stack_handle_t set_track_prepare(void) { return 0; }
>  static inline void set_track(struct kmem_cache *s, void *object,
>  			     enum track_item alloc, unsigned long addr) {}
> +#ifndef CONFIG_OS_MINIDUMP
>  static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,
>  					struct slab *slab) {}
>  static inline void remove_full(struct kmem_cache *s, struct kmem_cache_node *n,
>  					struct slab *slab) {}
> +#else
> +static inline void add_full(struct kmem_cache *s,
> +	struct kmem_cache_node *n, struct slab *slab)
> +{
> +	lockdep_assert_held(&n->list_lock);
> +	list_add(&slab->slab_list, &n->full);
> +}
> +
> +static inline void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct slab *slab)
> +{
> +	lockdep_assert_held(&n->list_lock);
> +	list_del(&slab->slab_list);
> +}
> +#endif
> +
>  slab_flags_t kmem_cache_flags(unsigned int object_size,
>  	slab_flags_t flags, const char *name)
>  {
> @@ -2570,6 +2586,14 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>  		spin_lock_irqsave(&n->list_lock, flags);
>  	} else {
>  		mode = M_FULL_NOLIST;
> +#ifdef CONFIG_OS_MINIDUMP
> +		/*
> +		 * Taking the spinlock removes the possibility that
> +		 * acquire_slab() will see a slab that is frozen
> +		 */
> +		spin_lock_irqsave(&n->list_lock, flags);
> +
> +#endif
>  	}
>  
>  
> @@ -2577,7 +2601,11 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>  				old.freelist, old.counters,
>  				new.freelist, new.counters,
>  				"unfreezing slab")) {
> +#ifndef CONFIG_OS_MINIDUMP
>  		if (mode == M_PARTIAL)
> +#else
> +		if (mode != M_FREE)
> +#endif
>  			spin_unlock_irqrestore(&n->list_lock, flags);
>  		goto redo;
>  	}
> @@ -2592,6 +2620,10 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>  		discard_slab(s, slab);
>  		stat(s, FREE_SLAB);
>  	} else if (mode == M_FULL_NOLIST) {
> +#ifdef CONFIG_OS_MINIDUMP
> +		add_full(s, n, slab);
> +		spin_unlock_irqrestore(&n->list_lock, flags);
> +#endif
>  		stat(s, DEACTIVATE_FULL);
>  	}
>  }
> @@ -4202,6 +4234,9 @@ init_kmem_cache_node(struct kmem_cache_node *n)
>  	atomic_long_set(&n->nr_slabs, 0);
>  	atomic_long_set(&n->total_objects, 0);
>  	INIT_LIST_HEAD(&n->full);
> +#elif defined(CONFIG_OS_MINIDUMP)
> +	INIT_LIST_HEAD(&n->full);
> +
>  #endif
>  }
>  
> @@ -5009,7 +5044,8 @@ static struct kmem_cache * __init bootstrap(struct kmem_cache *static_cache)
>  		list_for_each_entry(p, &n->partial, slab_list)
>  			p->slab_cache = s;
>  
> -#ifdef CONFIG_SLUB_DEBUG
> +#if defined(CONFIG_SLUB_DEBUG) || \
> +	defined(CONFIG_OS_MINIDUMP)
>  		list_for_each_entry(p, &n->full, slab_list)
>  			p->slab_cache = s;
>  #endif
> -- 
> 2.17.1
> 
> 


      reply	other threads:[~2023-12-21 21:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 13:37 Ruipeng Qi
2023-12-21 21:50 ` David Rientjes [this message]

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=9cb6a9a3-25fb-22ca-8b62-52c60519bee2@google.com \
    --to=rientjes@google.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=qiruipeng@lixiang.com \
    --cc=roman.gushchin@linux.dev \
    --cc=ruipengqi7@gmail.com \
    --cc=vbabka@suse.cz \
    /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