]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/fork.c
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
[karo-tx-linux.git] / kernel / fork.c
index 0f69a3e5281effb9185a71bd5f4fcd79f58a6140..17921b0390b4f91113bcf8c9ccac5c1225751460 100644 (file)
@@ -205,19 +205,17 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
        void *stack;
        int i;
 
-       local_irq_disable();
        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)
                        continue;
-               this_cpu_write(cached_stacks[i], NULL);
 
                tsk->stack_vm_area = s;
-               local_irq_enable();
                return s->addr;
        }
-       local_irq_enable();
 
        stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
                                     VMALLOC_START, VMALLOC_END,
@@ -245,19 +243,15 @@ static inline void free_thread_stack(struct task_struct *tsk)
 {
 #ifdef CONFIG_VMAP_STACK
        if (task_stack_vm_area(tsk)) {
-               unsigned long flags;
                int i;
 
-               local_irq_save(flags);
                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;
 
-                       this_cpu_write(cached_stacks[i], tsk->stack_vm_area);
-                       local_irq_restore(flags);
                        return;
                }
-               local_irq_restore(flags);
 
                vfree_atomic(tsk->stack);
                return;
@@ -560,7 +554,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
        set_task_stack_end_magic(tsk);
 
 #ifdef CONFIG_CC_STACKPROTECTOR
-       tsk->stack_canary = get_random_long();
+       tsk->stack_canary = get_random_canary();
 #endif
 
        /*
@@ -579,6 +573,10 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
 
        kcov_task_init(tsk);
 
+#ifdef CONFIG_FAULT_INJECTION
+       tsk->fail_nth = 0;
+#endif
+
        return tsk;
 
 free_stack: