hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
kernel/kernel/fork.c
....@@ -42,6 +42,7 @@
4242 #include <linux/hmm.h>
4343 #include <linux/fs.h>
4444 #include <linux/mm.h>
45
+#include <linux/kprobes.h>
4546 #include <linux/vmacache.h>
4647 #include <linux/nsproxy.h>
4748 #include <linux/capability.h>
....@@ -649,6 +650,19 @@
649650 }
650651 EXPORT_SYMBOL_GPL(__mmdrop);
651652
653
+#ifdef CONFIG_PREEMPT_RT_BASE
654
+/*
655
+ * RCU callback for delayed mm drop. Not strictly rcu, but we don't
656
+ * want another facility to make this work.
657
+ */
658
+void __mmdrop_delayed(struct rcu_head *rhp)
659
+{
660
+ struct mm_struct *mm = container_of(rhp, struct mm_struct, delayed_drop);
661
+
662
+ __mmdrop(mm);
663
+}
664
+#endif
665
+
652666 static void mmdrop_async_fn(struct work_struct *work)
653667 {
654668 struct mm_struct *mm;
....@@ -683,12 +697,23 @@
683697 if (atomic_dec_and_test(&sig->sigcnt))
684698 free_signal_struct(sig);
685699 }
686
-
700
+#ifdef CONFIG_PREEMPT_RT_BASE
701
+static
702
+#endif
687703 void __put_task_struct(struct task_struct *tsk)
688704 {
689705 WARN_ON(!tsk->exit_state);
690706 WARN_ON(atomic_read(&tsk->usage));
691707 WARN_ON(tsk == current);
708
+
709
+ /*
710
+ * Remove function-return probe instances associated with this
711
+ * task and put them back on the free list.
712
+ */
713
+ kprobe_flush_task(tsk);
714
+
715
+ /* Task is done with its stack. */
716
+ put_task_stack(tsk);
692717
693718 cgroup_free(tsk);
694719 task_numa_free(tsk, true);
....@@ -700,7 +725,18 @@
700725 if (!profile_handoff_task(tsk))
701726 free_task(tsk);
702727 }
728
+#ifndef CONFIG_PREEMPT_RT_BASE
703729 EXPORT_SYMBOL_GPL(__put_task_struct);
730
+#else
731
+void __put_task_struct_cb(struct rcu_head *rhp)
732
+{
733
+ struct task_struct *tsk = container_of(rhp, struct task_struct, put_rcu);
734
+
735
+ __put_task_struct(tsk);
736
+
737
+}
738
+EXPORT_SYMBOL_GPL(__put_task_struct_cb);
739
+#endif
704740
705741 void __init __weak arch_task_cache_init(void) { }
706742
....@@ -863,6 +899,8 @@
863899 #ifdef CONFIG_STACKPROTECTOR
864900 tsk->stack_canary = get_random_canary();
865901 #endif
902
+ if (orig->cpus_ptr == &orig->cpus_mask)
903
+ tsk->cpus_ptr = &tsk->cpus_mask;
866904
867905 /*
868906 * One for us, one for whoever does the "release_task()" (usually
....@@ -875,6 +913,7 @@
875913 tsk->splice_pipe = NULL;
876914 tsk->task_frag.page = NULL;
877915 tsk->wake_q.next = NULL;
916
+ tsk->wake_q_sleeper.next = NULL;
878917
879918 account_kernel_stack(tsk, 1);
880919
....@@ -1600,6 +1639,9 @@
16001639 */
16011640 static void posix_cpu_timers_init(struct task_struct *tsk)
16021641 {
1642
+#ifdef CONFIG_PREEMPT_RT_BASE
1643
+ tsk->posix_timer_list = NULL;
1644
+#endif
16031645 tsk->cputime_expires.prof_exp = 0;
16041646 tsk->cputime_expires.virt_exp = 0;
16051647 tsk->cputime_expires.sched_exp = 0;
....@@ -1915,6 +1957,7 @@
19151957 spin_lock_init(&p->alloc_lock);
19161958
19171959 init_sigpending(&p->pending);
1960
+ p->sigqueue_cache = NULL;
19181961
19191962 p->utime = p->stime = p->gtime = 0;
19201963 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME