[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABexPfG0PAo31HUA_mOOgJvHzPdk_U9A-5zufbECSQ3=Riai=w@mail.gmail.com>
Date: Sun, 11 Dec 2011 22:01:35 +0800
From: zhihua che <zhihua.che@...il.com>
To: linux-kernel@...r.kernel.org
Subject: Re: [Slub allocator] There are chances that kmem_cache_cpu->freelist
is lost if the process is rescheduled to a differenet cpu before the local
irq is disabled when calling __slab_alloc()
2011/12/11 zhihua che <zhihua.che@...il.com>:
> Hi, everyone
> I'm reading the linux kernel and now focusing on memory
> management. Image a case like below, a process on cpu0 is calling
> slab_alloc for a free obj, and finds that the c0->freelist is null,
> where c0 is the pointer to a kmem_cache_cpu object corresponding to
> the current cpu0. Then the process resorts to the __slab_alloc and
> HERE, the process MAY BE rescheduled to a different cpu1 before the
> local irq is disabled. Then, a new kmem_cache_cpu pointer c1 is
> retrieved. I think there are chances that with respect to this
> different kmem_cache_cpu pointer c1, c1->freelist is NOT null and
> could be lost if the following code is executed in __slab_alloc:
>
> load_freelist:
> VM_BUG_ON(!page->frozen);
> c->freelist = get_free_pointer(s, object);
> /* THIS ASSIGNMENT */
> c->tid = next_tid(c->tid);
> local_irq_restore(flags);
> return object;
>
> I think the assignment above may cause the loss of the
> freelist pointed by c->freelist, because c now points to a different
> kmem_cache_cpu object due the reschedule and this freelist may be NOT
> null as I imaged earlier.
The case I imaged above is based on version 3.1.5. and I find that in
2.6.38, the local irq has been disabled in slab_alloc(), so this case
is not possible in earlier version.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists