linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pengfei Li <lpf.vector@gmail.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Christopher Lameter <cl@linux.com>,
	penberg@kernel.org, iamjoonsoo.kim@lge.com,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,  Roman Gushchin <guro@fb.com>
Subject: Re: [RESEND v4 6/7] mm, slab_common: Initialize the same size of kmalloc_caches[]
Date: Mon, 16 Sep 2019 23:04:29 +0800	[thread overview]
Message-ID: <CAD7_sbEKRc0ipTh2SU93C9wJ8hOdqpwFFhacFkWg0Yn71ZYQfA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1909151434140.211705@chino.kir.corp.google.com>

On Mon, Sep 16, 2019 at 5:38 AM David Rientjes <rientjes@google.com> wrote:

Thanks for your review comments!

>
> On Mon, 16 Sep 2019, Pengfei Li wrote:
>
> > diff --git a/mm/slab_common.c b/mm/slab_common.c
> > index 2aed30deb071..e7903bd28b1f 100644
> > --- a/mm/slab_common.c
> > +++ b/mm/slab_common.c
> > @@ -1165,12 +1165,9 @@ void __init setup_kmalloc_cache_index_table(void)
> >               size_index[size_index_elem(i)] = 0;
> >  }
> >
> > -static void __init
> > +static __always_inline void __init
> >  new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
> >  {
> > -     if (type == KMALLOC_RECLAIM)
> > -             flags |= SLAB_RECLAIM_ACCOUNT;
> > -
> >       kmalloc_caches[type][idx] = create_kmalloc_cache(
> >                                       kmalloc_info[idx].name[type],
> >                                       kmalloc_info[idx].size, flags, 0,
> > @@ -1185,30 +1182,22 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
> >  void __init create_kmalloc_caches(slab_flags_t flags)
> >  {
> >       int i;
> > -     enum kmalloc_cache_type type;
> >
> > -     for (type = KMALLOC_NORMAL; type <= KMALLOC_RECLAIM; type++) {
> > -             for (i = 0; i < KMALLOC_CACHE_NUM; i++) {
> > -                     if (!kmalloc_caches[type][i])
> > -                             new_kmalloc_cache(i, type, flags);
> > -             }
> > -     }
> > +     for (i = 0; i < KMALLOC_CACHE_NUM; i++) {
> > +             if (!kmalloc_caches[KMALLOC_NORMAL][i])
> > +                     new_kmalloc_cache(i, KMALLOC_NORMAL, flags);
> >
> > -     /* Kmalloc array is now usable */
> > -     slab_state = UP;
> > +             new_kmalloc_cache(i, KMALLOC_RECLAIM,
> > +                                     flags | SLAB_RECLAIM_ACCOUNT);
>
> This seems less robust, no?  Previously we verified that the cache doesn't
> exist before creating a new cache over top of it (for NORMAL and RECLAIM).
> Now we presume that the RECLAIM cache never exists.
>

Agree, this is really less robust.

I have checked the code and found that there is no place to initialize
kmalloc-rcl-xxx before create_kmalloc_caches(). So I assume that
kmalloc-rcl-xxx is NULL.

> Can we just move a check to new_kmalloc_cache() to see if
> kmalloc_caches[type][idx] already exists and, if so, just return?  This
> should be more robust and simplify create_kmalloc_caches() slightly more.

For better robustness, I will do it as you suggested in v5.


  reply	other threads:[~2019-09-16 15:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 17:08 [RESEND v4 0/7] mm, slab: Make kmalloc_info[] contain all types of names Pengfei Li
2019-09-15 17:08 ` [RESEND v4 1/7] " Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-16 14:52     ` Pengfei Li
2019-09-15 17:08 ` [RESEND v4 2/7] mm, slab: Remove unused kmalloc_size() Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-15 17:08 ` [RESEND v4 3/7] mm, slab_common: Use enum kmalloc_cache_type to iterate over kmalloc caches Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-15 17:08 ` [RESEND v4 4/7] mm, slab: Return ZERO_SIZE_ALLOC for zero sized kmalloc requests Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-15 17:08 ` [RESEND v4 5/7] mm, slab_common: Make kmalloc_caches[] start at size KMALLOC_MIN_SIZE Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-17 14:10     ` Pengfei Li
2019-09-16  1:45   ` kbuild test robot
2019-09-16 15:14     ` Pengfei Li
2019-09-16  3:14   ` kbuild test robot
2019-09-16  4:53   ` kbuild test robot
2019-09-16 15:15     ` Pengfei Li
2019-09-16  4:53   ` [RFC PATCH] mm, slab_common: all_kmalloc_info[] can be static kbuild test robot
2019-09-15 17:08 ` [RESEND v4 6/7] mm, slab_common: Initialize the same size of kmalloc_caches[] Pengfei Li
2019-09-15 21:38   ` David Rientjes
2019-09-16 15:04     ` Pengfei Li [this message]
2019-09-15 17:08 ` [RESEND v4 7/7] mm, slab_common: Modify kmalloc_caches[type][idx] to kmalloc_caches[idx][type] Pengfei Li
2019-09-15 21:38   ` David Rientjes

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=CAD7_sbEKRc0ipTh2SU93C9wJ8hOdqpwFFhacFkWg0Yn71ZYQfA@mail.gmail.com \
    --to=lpf.vector@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=guro@fb.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.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