lkml.org 
[lkml]   [2012]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [patch] mm, slub: ensure irqs are enabled for kmemcheck
From
Date
On Mon, 2012-07-09 at 03:36 -0700, David Rientjes wrote:
> kmemcheck_alloc_shadow() requires irqs to be enabled, so wait to disable
> them until after its called for __GFP_WAIT allocations.
>
> This fixes a warning for such allocations:
>
> WARNING: at kernel/lockdep.c:2739 lockdep_trace_alloc+0x14e/0x1c0()
>
> Cc: stable@vger.kernel.org [3.1+]
> Acked-by: Fengguang Wu <fengguang.wu@intel.com>
> Tested-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> mm/slub.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1314,13 +1314,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
> stat(s, ORDER_FALLBACK);
> }
>
> - if (flags & __GFP_WAIT)
> - local_irq_disable();
> -
> - if (!page)
> - return NULL;
> -
> - if (kmemcheck_enabled
> + if (page && kmemcheck_enabled

One micro-optimization nit...

If kmemcheck_enabled is mostly false, and page is mostly true, wouldn't
it be better to swap the two?

if (kmemcheck_enabled && page

Then the first check would just short-circuit out and we don't do the
double check.

Otherwise it looks good.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> && !(s->flags & (SLAB_NOTRACK | DEBUG_DEFAULT_FLAGS))) {
> int pages = 1 << oo_order(oo);
>
> @@ -1336,6 +1330,11 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
> kmemcheck_mark_unallocated_pages(page, pages);
> }
>
> + if (flags & __GFP_WAIT)
> + local_irq_disable();
> + if (!page)
> + return NULL;
> +
> page->objects = oo_objects(oo);
> mod_zone_page_state(page_zone(page),
> (s->flags & SLAB_RECLAIM_ACCOUNT) ?




\
 
 \ /
  Last update: 2012-07-09 17:01    [W:0.076 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site