Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1560176 > unrolled thread

Re: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg cache release path

Started byJoonsoo Kim <iamjoonsoo.kim@lge.com>
First post2017-01-17 01:10 +0100
Last post2017-01-17 20:10 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg  cache release path Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2017-01-17 01:10 +0100
    Re: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg  cache release path Tejun Heo <tj@kernel.org> - 2017-01-17 17:40 +0100
      Re: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg  cache release path Tejun Heo <tj@kernel.org> - 2017-01-17 20:10 +0100

#1560176 — Re: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg cache release path

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2017-01-17 01:10 +0100
SubjectRe: [PATCH 2/9] slab: remove synchronous rcu_barrier() call in memcg cache release path
Message-ID<t0pvz-85c-11@gated-at.bofh.it>
On Sat, Jan 14, 2017 at 10:19:21AM -0500, Tejun Heo wrote:
> Hello, Vladimir.
> 
> On Sat, Jan 14, 2017 at 04:19:39PM +0300, Vladimir Davydov wrote:
> > On Sat, Jan 14, 2017 at 12:54:42AM -0500, Tejun Heo wrote:
> > > This patch updates the cache release path so that it simply uses
> > > call_rcu() instead of the synchronous rcu_barrier() + custom batching.
> > > This doesn't cost more while being logically simpler and way more
> > > scalable.
> > 
> > The point of rcu_barrier() is to wait until all rcu calls freeing slabs
> > from the cache being destroyed are over (rcu_free_slab, kmem_rcu_free).
> > I'm not sure if call_rcu() guarantees that for all rcu implementations
> > too. If it did, why would we need rcu_barrier() at all?
> 
> Yeah, I had a similar question and scanned its users briefly.  Looks
> like it's used in combination with ctors so that its users can
> opportunistically dereference objects and e.g. check ids / state /
> whatever without worrying about the objects' lifetimes.

Hello, Tejun.

Long time no see! :)

IIUC, rcu_barrier() here prevents to destruct the kmem_cache until all
slab pages in it are freed. These slab pages are freed through call_rcu().

Your patch changes it to another call_rcu() and, I think, if sequence of
executing rcu callbacks is the same with sequence of adding rcu
callbacks, it would work. However, I'm not sure that it is
guaranteed by RCU API. Am I missing something?

Thanks.

[toc] | [next] | [standalone]


#1560788

FromTejun Heo <tj@kernel.org>
Date2017-01-17 17:40 +0100
Message-ID<t0EXF-VQ-45@gated-at.bofh.it>
In reply to#1560176
Hello, Joonsoo.

On Tue, Jan 17, 2017 at 09:07:54AM +0900, Joonsoo Kim wrote:
> Long time no see! :)

Yeah, happy new year!

> IIUC, rcu_barrier() here prevents to destruct the kmem_cache until all
> slab pages in it are freed. These slab pages are freed through call_rcu().

Hmm... why do we need that tho?  SLAB_DESTROY_BY_RCU only needs to
protect the slab pages, not kmem cache struct.  I thought that this
was because kmem cache destruction is allowed to release pages w/o RCU
delaying it.

> Your patch changes it to another call_rcu() and, I think, if sequence of
> executing rcu callbacks is the same with sequence of adding rcu
> callbacks, it would work. However, I'm not sure that it is
> guaranteed by RCU API. Am I missing something?

The call sequence doesn't matter.  Whether you're using call_rcu() or
rcu_barrier(), you're just waiting for a grace period to pass before
continuing.  It doens't give any other ordering guarantees, so the new
code should be equivalent to the old one except for being asynchronous.

Thanks.

-- 
tejun

[toc] | [prev] | [next] | [standalone]


#1560940

FromTejun Heo <tj@kernel.org>
Date2017-01-17 20:10 +0100
Message-ID<t0HiO-2uu-25@gated-at.bofh.it>
In reply to#1560788
On Tue, Jan 17, 2017 at 08:37:45AM -0800, Tejun Heo wrote:
> The call sequence doesn't matter.  Whether you're using call_rcu() or
> rcu_barrier(), you're just waiting for a grace period to pass before
> continuing.  It doens't give any other ordering guarantees, so the new
> code should be equivalent to the old one except for being asynchronous.

Oh I was confusing synchronize_rcu() with rcu_barrier(), so you're
right, kmem_cache struct needs to stay around for the slab pages to be
freed after RCU grace period.  Will revise the patch accordingly,
thanks.

Thanks.

-- 
tejun

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web