Merge tag 'ktest-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-microblaze.git] / kernel / fork.c
index f98de49..771e0ea 100644 (file)
@@ -96,6 +96,7 @@
 #include <linux/kasan.h>
 #include <linux/scs.h>
 #include <linux/io_uring.h>
+#include <linux/bpf.h>
 
 #include <asm/pgalloc.h>
 #include <linux/uaccess.h>
@@ -379,14 +380,17 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
        void *stack = task_stack_page(tsk);
        struct vm_struct *vm = task_stack_vm_area(tsk);
 
+       if (vm) {
+               int i;
 
-       /* All stack pages are in the same node. */
-       if (vm)
-               mod_lruvec_page_state(vm->pages[0], NR_KERNEL_STACK_KB,
-                                     account * (THREAD_SIZE / 1024));
-       else
+               for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
+                       mod_lruvec_page_state(vm->pages[i], NR_KERNEL_STACK_KB,
+                                             account * (PAGE_SIZE / 1024));
+       } else {
+               /* All stack pages are in the same node. */
                mod_lruvec_kmem_state(stack, NR_KERNEL_STACK_KB,
                                      account * (THREAD_SIZE / 1024));
+       }
 }
 
 static int memcg_charge_kernel_stack(struct task_struct *tsk)
@@ -734,6 +738,7 @@ void __put_task_struct(struct task_struct *tsk)
        cgroup_free(tsk);
        task_numa_free(tsk, true);
        security_task_free(tsk);
+       bpf_task_storage_free(tsk);
        exit_creds(tsk);
        delayacct_tsk_free(tsk);
        put_signal_struct(tsk->signal);
@@ -927,6 +932,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
        tsk->splice_pipe = NULL;
        tsk->task_frag.page = NULL;
        tsk->wake_q.next = NULL;
+       tsk->pf_io_worker = NULL;
 
        account_kernel_stack(tsk, 1);
 
@@ -1941,7 +1947,7 @@ static __latent_entropy struct task_struct *copy_process(
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
        retval = -ERESTARTNOINTR;
-       if (signal_pending(current))
+       if (task_sigpending(current))
                goto fork_out;
 
        retval = -ENOMEM;
@@ -2079,6 +2085,9 @@ static __latent_entropy struct task_struct *copy_process(
        p->sequential_io        = 0;
        p->sequential_io_avg    = 0;
 #endif
+#ifdef CONFIG_BPF_SYSCALL
+       RCU_INIT_POINTER(p->bpf_storage, NULL);
+#endif
 
        /* Perform scheduler related setup. Assign this task to a CPU. */
        retval = sched_fork(clone_flags, p);