linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: JoonSoo Kim <js1304@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	David Rientjes <rientjes@google.com>
Subject: Re: [PATCH] slub: try to get cpu partial slab even if we get enough objects for cpu freelist
Date: Fri, 17 Aug 2012 22:34:18 +0900	[thread overview]
Message-ID: <CAAmzW4P=w6-yrmDmK1SPo3pwgH68Q0+RCe0tpqZPXnk-QEBLMQ@mail.gmail.com> (raw)
In-Reply-To: <00000139306844c8-bb717c88-ca56-48b3-9b8f-9186053359d3-000000@email.amazonses.com>

2012/8/17 Christoph Lameter <cl@linux.com>:
> On Thu, 16 Aug 2012, JoonSoo Kim wrote:
>
>> But, if you prefer that s->cpu_partial is for both cpu slab and cpu
>> partial slab,
>> get_partial_node() needs an another minor fix.
>> We should add number of objects in cpu slab when we refill cpu partial slab.
>> Following is my suggestion.
>>
>> @@ -1546,7 +1546,7 @@ static void *get_partial_node(struct kmem_cache *s,
>>         spin_lock(&n->list_lock);
>>         list_for_each_entry_safe(page, page2, &n->partial, lru) {
>>                 void *t = acquire_slab(s, n, page, object == NULL);
>> -               int available;
>> +               int available, nr = 0;
>>
>>                 if (!t)
>>                         break;
>> @@ -1557,10 +1557,10 @@ static void *get_partial_node(struct kmem_cache *s,
>>                         object = t;
>>                         available =  page->objects - page->inuse;
>>                 } else {
>> -                       available = put_cpu_partial(s, page, 0);
>> +                       nr = put_cpu_partial(s, page, 0);
>>                         stat(s, CPU_PARTIAL_NODE);
>>                 }
>> -               if (kmem_cache_debug(s) || available > s->cpu_partial / 2)
>> +               if (kmem_cache_debug(s) || (available + nr) >
>> s->cpu_partial / 2)
>>                         break;
>>
>>         }
>>
>> If you agree with this suggestion, I send a patch for this.
>
> What difference does this patch make? At the end of the day you need the
> total number of objects available in the partial slabs and the cpu slab
> for comparison.

It doesn't induce any large difference, but this makes code robust and
consistent.
Consistent code make us easily knowing what code does.

It is somewhat odd that in first loop, we consider number of objects
kept in cpu slab,
but second loop exclude that number and just consider number of
objects in cpu partial slab.

Thanks!

  reply	other threads:[~2012-08-17 13:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 15:38 [PATCH] slub: try to get cpu partial slab even if we get enough objects for cpu freelist Joonsoo Kim
2012-08-15 15:45 ` Christoph Lameter
2012-08-15 16:35   ` JoonSoo Kim
2012-08-15 17:32     ` Christoph Lameter
2012-08-16 13:47       ` JoonSoo Kim
2012-08-16 17:08         ` Christoph Lameter
2012-08-17 13:34           ` JoonSoo Kim [this message]
2012-08-17 14:02             ` Christoph Lameter
2012-08-17 14:37               ` JoonSoo Kim
2012-08-17 14:56                 ` Christoph Lameter

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='CAAmzW4P=w6-yrmDmK1SPo3pwgH68Q0+RCe0tpqZPXnk-QEBLMQ@mail.gmail.com' \
    --to=js1304@gmail.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.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;
as well as URLs for NNTP newsgroup(s).