All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rmaplock 2/6 SLAB_DESTROY_BY_RCU
Date: Tue, 13 Jul 2004 22:36:08 +0200	[thread overview]
Message-ID: <40F447B8.5080208@colorfullife.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0407132029540.8535-100000@localhost.localdomain>

Hugh Dickins wrote:

>On Tue, 13 Jul 2004, Manfred Spraul wrote:
>  
>
>>An interesting idea:
>>The slab caches are object caches. If a rcu user only needs a valid 
>>object but doesn't care which one then there is no need to wait for a 
>>quiescent cycle after free - the quiescent cycle can be delayed until 
>>the destructor is called.
>>    
>>
>
>Sorry, to be honest, I've not understood you there at all.
>I wonder if you're seeing some other use than I intended.
>
>  
>
No, I just tried to reworden your idea and I obviously failed.
Previously, I always assumed that the free call had to be delayed, but 
you have shown that this is wrong: If a rcu user can detect that an 
object changed its identity (or if he doesn't care), then it's not 
necessary to delay the free call, it's sufficient to delay the object 
destruction. And since the slab cache is an object cache delaying 
destruction causes virtually no overhead at all.
A second restriction is that it must be possible to recover from 
identity changes. I think this rules out the dentry cache - the hash 
chains point to wrong positions after a free/alloc/reuse cycle, it's not 
possible to recover from that.

>>But there are two flaws in your patch:
>>- you must disable poisoning and unmapping if SLAB_DESTROY_BY_RCU is set.
>>    
>>
>
>How right you are!  Thank you.  Does the further patch below suit?
>
>  
>
Yes, that should work.

>>- either delay the dtor calls a well or fail if an object has a non-NULL 
>>dtor and SLAB_DESTROY_BY_RCU is set.
>>    
>>
>
>Doesn't that rather depend on what the dtor does?  I'm not used to how
>destructors are commonly used, but I can easily imagine a destructor
>which, say, frees up some attached objects, but still leaves this cache
>object recognizably itself, good enough for the reference-after-free
>which SLAB_DESTROY_BY_RCU is allowing - all we need to avoid is the
>page being freed (or poisoned or unmapped) and reused.
>
This would introduce a concept of a half destroyed object. I think it's 
a bad idea, too easy to introduce bugs.
The correct fix would be to move the whole slab_destroy call into the 
rcu callback instead of just the kmem_cache_free call, but locking would 
be tricky - kmem_cache_destroy would have to wait for completion of 
outstanding rcu calls, etc.
Thus I'd propose a quick fix (fail if there is a dtor - are there any 
slab caches with dtors at all?) and in the long run slab_destroy should 
be moved into the rcu callback.

--
    Manfred

  reply	other threads:[~2004-07-13 20:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-12 21:49 [PATCH] rmaplock 1/6 PageAnon in mapping Hugh Dickins
2004-07-12 21:50 ` [PATCH] rmaplock 2/6 kill page_map_lock Hugh Dickins
2004-07-12 21:52 ` [PATCH] rmaplock 2/6 SLAB_DESTROY_BY_RCU Hugh Dickins
2004-07-13 16:36   ` Manfred Spraul
2004-07-13 19:53     ` Hugh Dickins
2004-07-13 20:36       ` Manfred Spraul [this message]
2004-07-13 22:17         ` William Lee Irwin III
2004-07-14 20:25         ` Hugh Dickins
2004-07-12 21:53 ` [PATCH] rmaplock 4/6 mm lock ordering Hugh Dickins
2004-07-12 21:54 ` [PATCH] rmaplock 5/6 unuse_process mmap_sem Hugh Dickins
2004-07-12 21:55 ` [PATCH] rmaplock 6/6 swapoff use anon_vma Hugh Dickins
2004-07-13  4:48 ` [PATCH] rmaplock 1/6 PageAnon in mapping Andrew Morton
2004-07-13  7:08   ` Hugh Dickins

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=40F447B8.5080208@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.