* [patch 0/2] mm, slub: remaining changes for -mm @ 2014-07-22 22:57 David Rientjes 2014-07-22 22:57 ` [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() David Rientjes 2014-07-22 22:58 ` [patch 2/2] mm, slub: fix some indenting in cmpxchg_double_slab() David Rientjes 0 siblings, 2 replies; 5+ messages in thread From: David Rientjes @ 2014-07-22 22:57 UTC (permalink / raw) To: Andrew Morton Cc: Vladimir Davydov, Dan Carpenter, Christoph Lameter, Joonsoo Kim, Pekka Enberg, linux-kernel, linux-mm Two patches remain in Pekka's slab/next branch that can deferred to 3.17 but need to get pushed to -mm. Unless there's an objection, it should be possible to remove Pekka's slab trees from linux-next until he starts pushing changes again. --- mm/slub.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() 2014-07-22 22:57 [patch 0/2] mm, slub: remaining changes for -mm David Rientjes @ 2014-07-22 22:57 ` David Rientjes 2014-07-24 12:21 ` Johannes Weiner 2014-07-22 22:58 ` [patch 2/2] mm, slub: fix some indenting in cmpxchg_double_slab() David Rientjes 1 sibling, 1 reply; 5+ messages in thread From: David Rientjes @ 2014-07-22 22:57 UTC (permalink / raw) To: Andrew Morton Cc: Vladimir Davydov, Dan Carpenter, Christoph Lameter, Joonsoo Kim, Pekka Enberg, linux-kernel, linux-mm From: Vladimir Davydov <vdavydov@parallels.com> Commit c65c1877bd68 ("slub: use lockdep_assert_held") requires remove_partial() to be called with n->list_lock held, but free_partial() called from kmem_cache_close() on cache destruction does not follow this rule, leading to a warning: WARNING: CPU: 0 PID: 2787 at mm/slub.c:1536 __kmem_cache_shutdown+0x1b2/0x1f0() Modules linked in: CPU: 0 PID: 2787 Comm: modprobe Tainted: G W 3.14.0-rc1-mm1+ #1 Hardware name: 0000000000000600 ffff88003ae1dde8 ffffffff816d9583 0000000000000600 0000000000000000 ffff88003ae1de28 ffffffff8107c107 0000000000000000 ffff880037ab2b00 ffff88007c240d30 ffffea0001ee5280 ffffea0001ee52a0 Call Trace: [<ffffffff816d9583>] dump_stack+0x51/0x6e [<ffffffff8107c107>] warn_slowpath_common+0x87/0xb0 [<ffffffff8107c145>] warn_slowpath_null+0x15/0x20 [<ffffffff811c7fe2>] __kmem_cache_shutdown+0x1b2/0x1f0 [<ffffffff811908d3>] kmem_cache_destroy+0x43/0xf0 [<ffffffffa013a123>] xfs_destroy_zones+0x103/0x110 [xfs] [<ffffffffa0192b54>] exit_xfs_fs+0x38/0x4e4 [xfs] [<ffffffff811036fa>] SyS_delete_module+0x19a/0x1f0 [<ffffffff816dfcd8>] ? retint_swapgs+0x13/0x1b [<ffffffff810d2125>] ? trace_hardirqs_on_caller+0x105/0x1d0 [<ffffffff81359efe>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff816e8539>] system_call_fastpath+0x16/0x1b Although this cannot actually result in a race, because on cache destruction there should not be any concurrent frees or allocations from the cache, let's add spin_lock/unlock to free_partial() just to keep lockdep happy. Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: David Rientjes <rientjes@google.com> --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c --- a/mm/slub.c +++ b/mm/slub.c @@ -3195,12 +3195,13 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, /* * Attempt to free all partial slabs on a node. * This is called from kmem_cache_close(). We must be the last thread - * using the cache and therefore we do not need to lock anymore. + * using the cache, but we still have to lock for lockdep's sake. */ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) { struct page *page, *h; + spin_lock_irq(&n->list_lock); list_for_each_entry_safe(page, h, &n->partial, lru) { if (!page->inuse) { __remove_partial(n, page); @@ -3210,6 +3211,7 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) "Objects remaining in %s on kmem_cache_close()"); } } + spin_unlock_irq(&n->list_lock); } /* -- 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() 2014-07-22 22:57 ` [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() David Rientjes @ 2014-07-24 12:21 ` Johannes Weiner 2014-07-24 22:18 ` David Rientjes 0 siblings, 1 reply; 5+ messages in thread From: Johannes Weiner @ 2014-07-24 12:21 UTC (permalink / raw) To: David Rientjes Cc: Andrew Morton, Vladimir Davydov, Dan Carpenter, Christoph Lameter, Joonsoo Kim, Pekka Enberg, linux-kernel, linux-mm On Tue, Jul 22, 2014 at 03:57:58PM -0700, David Rientjes wrote: > From: Vladimir Davydov <vdavydov@parallels.com> > > Commit c65c1877bd68 ("slub: use lockdep_assert_held") requires > remove_partial() to be called with n->list_lock held, but free_partial() > called from kmem_cache_close() on cache destruction does not follow this > rule, leading to a warning: > > WARNING: CPU: 0 PID: 2787 at mm/slub.c:1536 __kmem_cache_shutdown+0x1b2/0x1f0() > Modules linked in: > CPU: 0 PID: 2787 Comm: modprobe Tainted: G W 3.14.0-rc1-mm1+ #1 > Hardware name: > 0000000000000600 ffff88003ae1dde8 ffffffff816d9583 0000000000000600 > 0000000000000000 ffff88003ae1de28 ffffffff8107c107 0000000000000000 > ffff880037ab2b00 ffff88007c240d30 ffffea0001ee5280 ffffea0001ee52a0 > Call Trace: > [<ffffffff816d9583>] dump_stack+0x51/0x6e > [<ffffffff8107c107>] warn_slowpath_common+0x87/0xb0 > [<ffffffff8107c145>] warn_slowpath_null+0x15/0x20 > [<ffffffff811c7fe2>] __kmem_cache_shutdown+0x1b2/0x1f0 > [<ffffffff811908d3>] kmem_cache_destroy+0x43/0xf0 > [<ffffffffa013a123>] xfs_destroy_zones+0x103/0x110 [xfs] > [<ffffffffa0192b54>] exit_xfs_fs+0x38/0x4e4 [xfs] > [<ffffffff811036fa>] SyS_delete_module+0x19a/0x1f0 > [<ffffffff816dfcd8>] ? retint_swapgs+0x13/0x1b > [<ffffffff810d2125>] ? trace_hardirqs_on_caller+0x105/0x1d0 > [<ffffffff81359efe>] ? trace_hardirqs_on_thunk+0x3a/0x3f > [<ffffffff816e8539>] system_call_fastpath+0x16/0x1b > > Although this cannot actually result in a race, because on cache > destruction there should not be any concurrent frees or allocations from > the cache, let's add spin_lock/unlock to free_partial() just to keep > lockdep happy. Please never add needless locking just to please lockdep. > Acked-by: Christoph Lameter <cl@linux.com> > Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> > Signed-off-by: Pekka Enberg <penberg@kernel.org> > Signed-off-by: David Rientjes <rientjes@google.com> > --- > mm/slub.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3195,12 +3195,13 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, > /* > * Attempt to free all partial slabs on a node. > * This is called from kmem_cache_close(). We must be the last thread > - * using the cache and therefore we do not need to lock anymore. > + * using the cache, but we still have to lock for lockdep's sake. > */ > static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) > { > struct page *page, *h; > > + spin_lock_irq(&n->list_lock); > list_for_each_entry_safe(page, h, &n->partial, lru) { > if (!page->inuse) { > __remove_partial(n, page); This already uses __remove_partial(), which does not have the lockdep assertion. You even acked the patch that made this change, why add the spinlock now? commit 1e4dd9461fabfbc780cdfaf103cec790f3a53325 Author: Steven Rostedt <rostedt@goodmis.org> Date: Mon Feb 10 14:25:46 2014 -0800 slub: do not assert not having lock in removing freed partial Vladimir reported the following issue: Commit c65c1877bd68 ("slub: use lockdep_assert_held") requires remove_partial() to be called with n->list_lock held, but free_partial() called from kmem_cache_close() on cache destruction does not follow this rule, leading to a warning: WARNING: CPU: 0 PID: 2787 at mm/slub.c:1536 __kmem_cache_shutdown+0x1b2/0x1f0() Modules linked in: CPU: 0 PID: 2787 Comm: modprobe Tainted: G W 3.14.0-rc1-mm1+ #1 Hardware name: 0000000000000600 ffff88003ae1dde8 ffffffff816d9583 0000000000000600 0000000000000000 ffff88003ae1de28 ffffffff8107c107 0000000000000000 ffff880037ab2b00 ffff88007c240d30 ffffea0001ee5280 ffffea0001ee52a0 Call Trace: __kmem_cache_shutdown+0x1b2/0x1f0 kmem_cache_destroy+0x43/0xf0 xfs_destroy_zones+0x103/0x110 [xfs] exit_xfs_fs+0x38/0x4e4 [xfs] SyS_delete_module+0x19a/0x1f0 system_call_fastpath+0x16/0x1b His solution was to add a spinlock in order to quiet lockdep. Although there would be no contention to adding the lock, that lock also requires disabling of interrupts which will have a larger impact on the system. Instead of adding a spinlock to a location where it is not needed for lockdep, make a __remove_partial() function that does not test if the list_lock is held, as no one should have it due to it being freed. Also added a __add_partial() function that does not do the lock validation either, as it is not needed for the creation of the cache. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Reported-by: Vladimir Davydov <vdavydov@parallels.com> Suggested-by: David Rientjes <rientjes@google.com> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Vladimir Davydov <vdavydov@parallels.com> Acked-by: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> -- 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() 2014-07-24 12:21 ` Johannes Weiner @ 2014-07-24 22:18 ` David Rientjes 0 siblings, 0 replies; 5+ messages in thread From: David Rientjes @ 2014-07-24 22:18 UTC (permalink / raw) To: Johannes Weiner Cc: Andrew Morton, Vladimir Davydov, Dan Carpenter, Christoph Lameter, Joonsoo Kim, Pekka Enberg, linux-kernel, linux-mm On Thu, 24 Jul 2014, Johannes Weiner wrote: > > diff --git a/mm/slub.c b/mm/slub.c > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -3195,12 +3195,13 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, > > /* > > * Attempt to free all partial slabs on a node. > > * This is called from kmem_cache_close(). We must be the last thread > > - * using the cache and therefore we do not need to lock anymore. > > + * using the cache, but we still have to lock for lockdep's sake. > > */ > > static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) > > { > > struct page *page, *h; > > > > + spin_lock_irq(&n->list_lock); > > list_for_each_entry_safe(page, h, &n->partial, lru) { > > if (!page->inuse) { > > __remove_partial(n, page); > > This already uses __remove_partial(), which does not have the lockdep > assertion. You even acked the patch that made this change, why add > the spinlock now? > Yup, thanks. This was sitting in Pekka's slab/next branch but isn't actually needed after commit 1e4dd9461fab ("slub: do not assert not having lock in removing freed partial"). Good catch! -- 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 2/2] mm, slub: fix some indenting in cmpxchg_double_slab() 2014-07-22 22:57 [patch 0/2] mm, slub: remaining changes for -mm David Rientjes 2014-07-22 22:57 ` [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() David Rientjes @ 2014-07-22 22:58 ` David Rientjes 1 sibling, 0 replies; 5+ messages in thread From: David Rientjes @ 2014-07-22 22:58 UTC (permalink / raw) To: Andrew Morton Cc: Vladimir Davydov, Dan Carpenter, Christoph Lameter, Joonsoo Kim, Pekka Enberg, linux-kernel, linux-mm From: Dan Carpenter <dan.carpenter@oracle.com> The return statement goes with the cmpxchg_double() condition so it needs to be indented another tab. Also these days the fashion is to line function parameters up, and it looks nicer that way because then the "freelist_new" is not at the same indent level as the "return 1;". Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: David Rientjes <rientjes@google.com> --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c --- a/mm/slub.c +++ b/mm/slub.c @@ -382,9 +382,9 @@ static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct page *page defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE) if (s->flags & __CMPXCHG_DOUBLE) { if (cmpxchg_double(&page->freelist, &page->counters, - freelist_old, counters_old, - freelist_new, counters_new)) - return 1; + freelist_old, counters_old, + freelist_new, counters_new)) + return 1; } else #endif { @@ -418,9 +418,9 @@ static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct page *page, defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE) if (s->flags & __CMPXCHG_DOUBLE) { if (cmpxchg_double(&page->freelist, &page->counters, - freelist_old, counters_old, - freelist_new, counters_new)) - return 1; + freelist_old, counters_old, + freelist_new, counters_new)) + return 1; } else #endif { -- 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-24 22:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-07-22 22:57 [patch 0/2] mm, slub: remaining changes for -mm David Rientjes 2014-07-22 22:57 ` [patch 1/2] mm, slub: fix false-positive lockdep warning in free_partial() David Rientjes 2014-07-24 12:21 ` Johannes Weiner 2014-07-24 22:18 ` David Rientjes 2014-07-22 22:58 ` [patch 2/2] mm, slub: fix some indenting in cmpxchg_double_slab() David Rientjes
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox