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 23:37:40 +0900	[thread overview]
Message-ID: <CAAmzW4PXf=GK-a8-r_Ep4vR=kx54pr9h5K00iEDx3rVii5ROiA@mail.gmail.com> (raw)
In-Reply-To: <0000013934e4a8cf-51ac82e4-ad78-46b0-abf7-8dc81be01952-000000@email.amazonses.com>

2012/8/17 Christoph Lameter <cl@linux.com>:
> On Fri, 17 Aug 2012, JoonSoo Kim wrote:
>
>> > 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.
>
> Consistency depends on the way you think about the code.
>
>> 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.
>
> In the loop we consider the number of objects available to the cpu
> without locking.
>
> First we populate the per_cpu slab and if that does not give us enough per
> cpu objects then we use the per cpu partial list to increase that number
> to the desired count given by s->cpu_partial.
>
> "available" is the number of objects available for a particular cpu
> without having to go to the partial slab lists (which means having to acquire a
> per node lock).
>

Yes! You are right!
But, currently, "available" is not used as above meaning exactly.
It is used twice and each one has different meaning.

                if (!object) {
                        c->page = page;
                        stat(s, ALLOC_FROM_PARTIAL);
                        object = t;
                        available =  page->objects - page->inuse;
                } else {
                        available = put_cpu_partial(s, page, 0);
                        stat(s, CPU_PARTIAL_NODE);
                }

See above code.
In case of !object (available =  page->objects - page->inuse;),
"available" means the number of objects in cpu slab.
In this time, we don't have any cpu partial slab, so "available" imply
the number of objects available to the cpu without locking.
This is what we want.


But, see another "available" (available = put_cpu_partial(s, page, 0);).

This "available" doesn't include the number of objects in cpu slab.
It only include the number of objects in cpu partial slab.
So, it doesn't imply the number of objects available to the cpu without locking.
This isn't what we want.

Therefore, I think a minor fix is needed for consistency.
Isn't it reasonable?

Thanks!

  reply	other threads:[~2012-08-17 14:38 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
2012-08-17 14:02             ` Christoph Lameter
2012-08-17 14:37               ` JoonSoo Kim [this message]
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='CAAmzW4PXf=GK-a8-r_Ep4vR=kx54pr9h5K00iEDx3rVii5ROiA@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).