Skip to content

Commit 112166f

Browse files
Christoph Lametertorvalds
authored andcommitted
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>
1 parent 91a9014 commit 112166f

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎kernel/fork.c‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,17 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
205205
void *stack;
206206
int i;
207207

208-
local_irq_disable();
209208
for (i = 0; i < NR_CACHED_STACKS; i++) {
210-
struct vm_struct *s = this_cpu_read(cached_stacks[i]);
209+
struct vm_struct *s;
210+
211+
s = this_cpu_xchg(cached_stacks[i], NULL);
211212

212213
if (!s)
213214
continue;
214-
this_cpu_write(cached_stacks[i], NULL);
215215

216216
tsk->stack_vm_area = s;
217-
local_irq_enable();
218217
return s->addr;
219218
}
220-
local_irq_enable();
221219

222220
stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
223221
VMALLOC_START, VMALLOC_END,
@@ -245,19 +243,15 @@ static inline void free_thread_stack(struct task_struct *tsk)
245243
{
246244
#ifdef CONFIG_VMAP_STACK
247245
if (task_stack_vm_area(tsk)) {
248-
unsigned long flags;
249246
int i;
250247

251-
local_irq_save(flags);
252248
for (i = 0; i < NR_CACHED_STACKS; i++) {
253-
if (this_cpu_read(cached_stacks[i]))
249+
if (this_cpu_cmpxchg(cached_stacks[i],
250+
NULL, tsk->stack_vm_area) != NULL)
254251
continue;
255252

256-
this_cpu_write(cached_stacks[i], tsk->stack_vm_area);
257-
local_irq_restore(flags);
258253
return;
259254
}
260-
local_irq_restore(flags);
261255

262256
vfree_atomic(tsk->stack);
263257
return;

0 commit comments

Comments
 (0)