linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Paul Jackson <pj@sgi.com>
Cc: Andi Kleen <ak@suse.de>,
	akpm@osdl.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH]: Clean up of __alloc_pages
Date: Mon, 07 Nov 2005 17:08:03 +1100	[thread overview]
Message-ID: <436EEF43.2050403@yahoo.com.au> (raw)
In-Reply-To: <20051106203717.58c3eed0.pj@sgi.com>

Paul Jackson wrote:
> Nick wrote:
> 
>>Anyway, I think the first problem is a showstopper. I'd look into
>>Hugh's SLAB_DESTROY_BY_RCU for this ...
> 
> 
> Andi wrote:
> 
>>RCU could be used to avoid that. Just only free it in a RCU callback.
> 
> 
> 
> ... looking at mm/slab.h and rcupdate.h for the first time ... 
> 

Yeah, take a look at rmap.c as well, and some of the comments in
changelogs if you need a better feel for it.

Basically SLAB_DESTROY_BY_RCU will allow the entries to be freed
back to the slab for reuse, but will not allow the slab caches to
be freed back to the page allocator inside rcu readside.

So your cpusets may be reused, but only as new cpusets. This should
be no problem at all for you.

> Would this mean that I had to put the cpuset structures on their own
> slab cache, marked SLAB_DESTROY_BY_RCU?
> 
> And is the pair of operators:
>   task_lock(current), task_unlock(current)
> really that much worse than the pair of operatots
>   rcu_read_lock, rcu_read_unlock
> which apparently reduce to:
>   preempt_disable, preempt_enable
> 

You may also have to be careful about memory ordering when setting
a pointer which may be concurrently dereferenced by another CPU so
that stale data doesn't get picked up.

The set side needs an rcu_assign_pointer, and the dereference side
needs rcu_dereference. Unless you either don't care about races, or
already have the correct barriers in place. But it is better to be
safe.

> Would this work something like the following?  Say task A, on processor
> AP, is trying to dereference its cpuset pointer, while task B, on
> processor BP, is trying hard to destroy that cpuset. Then if task A
> wraps its reference in <rcu_read_lock, rcu_read_unlock>, this will keep
> the RCU freeing of that memory from completing, until interrupts on AP
> are re-enabled.
> 

Sounds like it should work.

> For that matter, if I just put cpuset structs in their own slab
> cache, would that be sufficient.
> 

No, because the slab caches can get freed back into the general
page allocator at any time.

>   Nick - Does use-after-free debugging even catch use of objects
> 	 returned to their slab cache?
> 

Yes (slab debugging catches write-after-free at least, I believe),
however there are exceptions made for RCU freed slab caches. That
is: it is acceptable to access a freed RCU slab object, especially
if you only read it (writes need to be more careful, but they're
possible in some situations).

> What about the other suggestions, Andi:
>  1) subset zonelists (which you asked to reconsider)
>  2) a kernel flag "cpusets_have_been_used" flag to short circuit
>     cpuset logic on systems not using cpusets.
> 

Not too sure at present. I think #1 might be a good idea though
it would be a bigger change. #2 again might be a good hack for
the time being, although it would be nice to try to get the same
performance from the normal cpuset fastpath.

My RCU suggestion was mainly an idea to get around your immediate
problem with a lockless fastpath, rather than advocating it over
any of the alternatives.

Thanks,
Nick

-- 
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2005-11-07  6:08 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-29  1:33 Rohit, Seth
2005-10-29  2:33 ` Nick Piggin
2005-10-31 20:55   ` Rohit Seth
2005-11-01  1:14     ` Nick Piggin
2005-11-04 18:15       ` Rohit Seth
2005-11-05  0:00         ` Nick Piggin
2005-10-30  0:16 ` Paul Jackson
2005-10-31 19:09   ` Rohit Seth
2005-11-05 17:09   ` Andi Kleen
2005-11-06  4:18     ` Paul Jackson
2005-11-06 17:35       ` Andi Kleen
2005-11-06 20:49         ` Paul Jackson
2005-11-07  2:57           ` Nick Piggin
2005-11-07  3:42             ` Andi Kleen
2005-11-07  4:37               ` Paul Jackson
2005-11-07  6:08                 ` Nick Piggin [this message]
2005-11-07  9:46                   ` Paul Jackson
2005-11-07 10:17                     ` Nick Piggin
2005-11-07 14:41                       ` Paul Jackson
2005-11-07  3:44             ` Paul Jackson
2005-10-30  1:47 ` Paul Jackson
2005-10-30  2:01   ` Nick Piggin
2005-10-30  2:19     ` Paul Jackson
2005-10-30  2:32       ` Nick Piggin
2005-10-30  3:06         ` Paul Jackson
2005-10-30  3:53           ` Nick Piggin
2005-10-30  2:26     ` Paul Jackson
2005-10-30  2:36       ` Nick Piggin
2005-10-30  3:09         ` Paul Jackson
2005-10-30  3:55           ` Nick Piggin
2005-10-30  4:11             ` Paul Jackson
2005-10-31 21:20   ` Rohit Seth
2005-10-31 21:28     ` Paul Jackson
  -- strict thread matches above, loose matches on Subject: below --
2005-11-05  1:57 Seth, Rohit
2005-10-01 19:00 Seth, Rohit
2005-10-02  3:09 ` Nick Piggin
2005-10-03 16:50   ` Rohit Seth
2005-10-03 15:34 ` Christoph Lameter
2005-10-03 16:55   ` Rohit Seth
2005-10-03 16:57     ` Christoph Lameter
2005-10-03 17:48       ` Rohit Seth
2005-10-04 13:27         ` Andi Kleen
2005-10-04 16:26           ` Ray Bryant
2005-10-04 16:10             ` Martin J. Bligh
2005-10-04 17:02               ` Ray Bryant

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=436EEF43.2050403@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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