From: Eric Dumazet <dada1@cosmosbay.com>
To: Paul Jackson <pj@sgi.com>
Cc: clameter@engr.sgi.com, akpm@osdl.org,
linux-kernel@vger.kernel.org, nickpiggin@yahoo.com.au,
Simon.Derr@bull.net, ak@suse.de
Subject: Re: [PATCH] Cpuset: rcu optimization of page alloc hook
Date: Tue, 13 Dec 2005 22:38:54 +0100 [thread overview]
Message-ID: <439F3F6E.6010701@cosmosbay.com> (raw)
In-Reply-To: <20051213130350.464a3054.pj@sgi.com>
Paul Jackson a écrit :
> Eric wrote:
>
>>If this variable is not frequently used, why then define its own cache ?
>>
>>Ie why not use kmalloc() and let kernel use a general cache ?
>
>
> This change from kmalloc() to a dedicated slab cache was made just a
> couple of days ago, at the suggestion of Andi Kleen and Nick Piggin, in
> order to optimize out a tasklock spinlock from the primary code path
> for allocating a page of memory.
>
> Indeed, this email thread is the thread that presented that patch.
>
> By using a dedicated slab cache, I was able to make an unusual use of
> Hugh Dicken's SLAB_DESTROY_BY_RCU implementation, and access a variable
> inside the cpuset structure safely, even after that cpuset structure
> might have been asynchronously free'd. What I read from that variable
> might well be garbage, but at least the slab would not have freed that
> page of memory entirely, inside my rcu_read_lock section.
OK, I'm afraid I cannot comment on this, this is too complex for me :)
>
> Since all I needed was to edge trigger on the condition that the
> contents of a variable changed since last read, that was sufficient.
>
>
>>On a 32 CPUS machine, a kmem_create() costs a *lot* of ram.
>
>
> Hmmm ... if 32 is bad, then what does it cost for say 512 CPUs?
You dont want to know :)
struct kmem_cache itself will be about 512*8 + some bytes
then for each cpu a 'struct array_cache' will be allocated (count 128 bytes
minimum each, it depends on various factors (and sizeof(void*) of course)
So I would say about 80 K Bytes at a very minimum.
>
> And when is that memory required? On many systems, that will have
> cpusets CONFIG_CPUSET enabled, but that are not using cpusets, just
> the kmem_cache_create() will be called to create cpuset_cache, but
> -no- kmem_cache_alloc() calls done. On those systems using cpusets,
> there might be one 'struct cpuset' allocated per gigabyte of ram, as a
> rough idea.
>
> Can you quantify "costs a *lot* of ram" ?
>
> I suppose that I could add a little bit of logic that avoided the
> initial kmem_cache_create() until needed by actual cpuset usage on the
> system (on the first cpuset_create(), the first time that user code
> tries to create a cpuset). In a related optimization, I might be able
> to avoid -even- the rcu_read_lock() guards on systems not using
> cpusets (never called cpuset_create() since boot), reducing that guard
> to a simple comparison of the current tasks cpuset pointer with the
> pointer to the one statically allocated global cpuset, known as the root
> cpuset. Actually, that last opimization would benefit any task still
> in the root cpuset, even after other cpusets had been dynamically
> created.
>
> Or, if using the slab cache was still too expensive for this use, I
> could perhaps make a more conventional use of RCU, to guard the kfree()
> myself, instead of making this unusual use of SLAB_DESTROY_BY_RCU. I'd
> have to learn more about RCU to know how to do that, or even it made
> sense.
>
Thank you for this details.
Eric
next prev parent reply other threads:[~2005-12-13 21:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-11 23:31 [PATCH] Cpuset: rcu optimization of page alloc hook Paul Jackson
2005-12-12 3:29 ` Andi Kleen
2005-12-12 6:11 ` Paul Jackson
2005-12-12 6:21 ` Andi Kleen
2005-12-12 6:50 ` Paul Jackson
2005-12-12 8:49 ` Eric Dumazet
2005-12-12 8:54 ` Nick Piggin
2005-12-12 9:06 ` Eric Dumazet
2005-12-12 9:11 ` Andrew Morton
2005-12-12 9:38 ` Nick Piggin
2005-12-12 10:02 ` Paul Jackson
2005-12-12 10:12 ` Andrew Morton
2005-12-13 15:53 ` Paul Jackson
2005-12-13 16:31 ` Eric Dumazet
2005-12-13 17:42 ` Christoph Lameter
2005-12-13 17:56 ` Eric Dumazet
2005-12-13 18:07 ` Christoph Lameter
2005-12-13 21:03 ` Paul Jackson
2005-12-13 21:16 ` Christoph Lameter
2005-12-13 21:38 ` Eric Dumazet [this message]
2005-12-13 22:23 ` Paul Jackson
2005-12-13 22:29 ` Christoph Lameter
2005-12-14 3:54 ` Paul Jackson
2005-12-14 4:02 ` Andi Kleen
2005-12-14 4:06 ` Paul Jackson
2005-12-14 8:06 ` Eric Dumazet
2005-12-14 8:40 ` Paul Jackson
2005-12-13 20:08 ` Paul Jackson
2005-12-13 20:29 ` Eric Dumazet
2005-12-13 22:35 ` Paul Jackson
2005-12-13 21:44 ` Paul Jackson
2005-12-13 17:37 ` 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=439F3F6E.6010701@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=Simon.Derr@bull.net \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=clameter@engr.sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=pj@sgi.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