kernel/fork.c: virtually mapped stacks: do not disable interrupts
The reason to disable interrupts seems to be to avoid switching to a different processor while handling per cpu data using individual loads and stores. If we use per cpu RMV primitives we will not have to disable interrupts. Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1705171055130.5898@east.gentwo.org Signed-off-by: Christoph Lameter <cl@linux.com> Cc: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
91a90140f9
commit
112166f88c
@ -205,19 +205,17 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
|
|||||||
void *stack;
|
void *stack;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
local_irq_disable();
|
|
||||||
for (i = 0; i < NR_CACHED_STACKS; i++) {
|
for (i = 0; i < NR_CACHED_STACKS; i++) {
|
||||||
struct vm_struct *s = this_cpu_read(cached_stacks[i]);
|
struct vm_struct *s;
|
||||||
|
|
||||||
|
s = this_cpu_xchg(cached_stacks[i], NULL);
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
continue;
|
continue;
|
||||||
this_cpu_write(cached_stacks[i], NULL);
|
|
||||||
|
|
||||||
tsk->stack_vm_area = s;
|
tsk->stack_vm_area = s;
|
||||||
local_irq_enable();
|
|
||||||
return s->addr;
|
return s->addr;
|
||||||
}
|
}
|
||||||
local_irq_enable();
|
|
||||||
|
|
||||||
stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
|
stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
|
||||||
VMALLOC_START, VMALLOC_END,
|
VMALLOC_START, VMALLOC_END,
|
||||||
@ -245,19 +243,15 @@ static inline void free_thread_stack(struct task_struct *tsk)
|
|||||||
{
|
{
|
||||||
#ifdef CONFIG_VMAP_STACK
|
#ifdef CONFIG_VMAP_STACK
|
||||||
if (task_stack_vm_area(tsk)) {
|
if (task_stack_vm_area(tsk)) {
|
||||||
unsigned long flags;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
local_irq_save(flags);
|
|
||||||
for (i = 0; i < NR_CACHED_STACKS; i++) {
|
for (i = 0; i < NR_CACHED_STACKS; i++) {
|
||||||
if (this_cpu_read(cached_stacks[i]))
|
if (this_cpu_cmpxchg(cached_stacks[i],
|
||||||
|
NULL, tsk->stack_vm_area) != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
this_cpu_write(cached_stacks[i], tsk->stack_vm_area);
|
|
||||||
local_irq_restore(flags);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
local_irq_restore(flags);
|
|
||||||
|
|
||||||
vfree_atomic(tsk->stack);
|
vfree_atomic(tsk->stack);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user