[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABexPfEXWo4YYG=3hA-ZW1tqV8-R=BQj=COgUM6_7_epPavx5g@mail.gmail.com>
Date: Sun, 11 Dec 2011 17:52:47 +0800
From: zhihua che <zhihua.che@...il.com>
To: linux-kernel@...r.kernel.org
Subject: [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()
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.
--
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