hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/sched.h
....@@ -18,17 +18,23 @@
1818 #include <linux/mutex.h>
1919 #include <linux/plist.h>
2020 #include <linux/hrtimer.h>
21
+#include <linux/irqflags.h>
2122 #include <linux/seccomp.h>
2223 #include <linux/nodemask.h>
2324 #include <linux/rcupdate.h>
25
+#include <linux/refcount.h>
2426 #include <linux/resource.h>
2527 #include <linux/latencytop.h>
2628 #include <linux/sched/prio.h>
29
+#include <linux/sched/types.h>
2730 #include <linux/signal_types.h>
2831 #include <linux/mm_types_task.h>
29
-#include <linux/mm_event.h>
3032 #include <linux/task_io_accounting.h>
33
+#include <linux/posix-timers.h>
3134 #include <linux/rseq.h>
35
+#include <linux/seqlock.h>
36
+#include <linux/kcsan.h>
37
+#include <linux/android_vendor.h>
3238 #include <linux/android_kabi.h>
3339
3440 /* task_struct member predeclarations (sorted alphabetically): */
....@@ -36,6 +42,7 @@
3642 struct backing_dev_info;
3743 struct bio_list;
3844 struct blk_plug;
45
+struct capture_control;
3946 struct cfs_rq;
4047 struct fs_struct;
4148 struct futex_pi_state;
....@@ -49,6 +56,8 @@
4956 struct rcu_node;
5057 struct reclaim_state;
5158 struct robust_list_head;
59
+struct root_domain;
60
+struct rq;
5261 struct sched_attr;
5362 struct sched_param;
5463 struct seq_file;
....@@ -56,6 +65,7 @@
5665 struct signal_struct;
5766 struct task_delay_info;
5867 struct task_group;
68
+struct io_uring_task;
5969
6070 /*
6171 * Task state bitmask. NOTE! These bits are also
....@@ -103,15 +113,7 @@
103113 __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
104114 TASK_PARKED)
105115
106
-#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
107
-
108116 #define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
109
-
110
-#define task_is_stopped_or_traced(task) ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
111
-
112
-#define task_contributes_to_load(task) ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
113
- (task->flags & PF_FROZEN) == 0 && \
114
- (task->state & TASK_NOLOAD) == 0)
115117
116118 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
117119
....@@ -136,6 +138,9 @@
136138 smp_store_mb(current->state, (state_value)); \
137139 } while (0)
138140
141
+#define __set_current_state_no_track(state_value) \
142
+ current->state = (state_value);
143
+
139144 #define set_special_state(state_value) \
140145 do { \
141146 unsigned long flags; /* may shadow */ \
....@@ -153,31 +158,31 @@
153158 *
154159 * for (;;) {
155160 * set_current_state(TASK_UNINTERRUPTIBLE);
156
- * if (!need_sleep)
157
- * break;
161
+ * if (CONDITION)
162
+ * break;
158163 *
159164 * schedule();
160165 * }
161166 * __set_current_state(TASK_RUNNING);
162167 *
163168 * If the caller does not need such serialisation (because, for instance, the
164
- * condition test and condition change and wakeup are under the same lock) then
169
+ * CONDITION test and condition change and wakeup are under the same lock) then
165170 * use __set_current_state().
166171 *
167172 * The above is typically ordered against the wakeup, which does:
168173 *
169
- * need_sleep = false;
174
+ * CONDITION = 1;
170175 * wake_up_state(p, TASK_UNINTERRUPTIBLE);
171176 *
172
- * where wake_up_state() executes a full memory barrier before accessing the
173
- * task state.
177
+ * where wake_up_state()/try_to_wake_up() executes a full memory barrier before
178
+ * accessing p->state.
174179 *
175180 * Wakeup will do: if (@state & p->state) p->state = TASK_RUNNING, that is,
176181 * once it observes the TASK_UNINTERRUPTIBLE store the waking CPU can issue a
177182 * TASK_RUNNING store which can collide with __set_current_state(TASK_RUNNING).
178183 *
179184 * However, with slightly different timing the wakeup TASK_RUNNING store can
180
- * also collide with the TASK_UNINTERRUPTIBLE store. Loosing that store is not
185
+ * also collide with the TASK_UNINTERRUPTIBLE store. Losing that store is not
181186 * a problem either because that will result in one extra go around the loop
182187 * and our @cond test will save the day.
183188 *
....@@ -188,6 +193,9 @@
188193
189194 #define set_current_state(state_value) \
190195 smp_store_mb(current->state, (state_value))
196
+
197
+#define __set_current_state_no_track(state_value) \
198
+ __set_current_state(state_value)
191199
192200 /*
193201 * set_special_state() should be used for those states when the blocking task
....@@ -219,6 +227,7 @@
219227 extern long schedule_timeout_idle(long timeout);
220228 asmlinkage void schedule(void);
221229 extern void schedule_preempt_disabled(void);
230
+asmlinkage void preempt_schedule_irq(void);
222231
223232 extern int __must_check io_schedule_prepare(void);
224233 extern void io_schedule_finish(int token);
....@@ -242,40 +251,24 @@
242251 #endif
243252 };
244253
245
-/**
246
- * struct task_cputime - collected CPU time counts
247
- * @utime: time spent in user mode, in nanoseconds
248
- * @stime: time spent in kernel mode, in nanoseconds
249
- * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
250
- *
251
- * This structure groups together three kinds of CPU time that are tracked for
252
- * threads and thread groups. Most things considering CPU time want to group
253
- * these counts together and treat all three of them in parallel.
254
- */
255
-struct task_cputime {
256
- u64 utime;
257
- u64 stime;
258
- unsigned long long sum_exec_runtime;
259
-};
260
-
261
-/* Alternate field names when used on cache expirations: */
262
-#define virt_exp utime
263
-#define prof_exp stime
264
-#define sched_exp sum_exec_runtime
265
-
266254 enum vtime_state {
267255 /* Task is sleeping or running in a CPU with VTIME inactive: */
268256 VTIME_INACTIVE = 0,
269
- /* Task runs in userspace in a CPU with VTIME active: */
270
- VTIME_USER,
257
+ /* Task is idle */
258
+ VTIME_IDLE,
271259 /* Task runs in kernelspace in a CPU with VTIME active: */
272260 VTIME_SYS,
261
+ /* Task runs in userspace in a CPU with VTIME active: */
262
+ VTIME_USER,
263
+ /* Task runs as guests in a CPU with VTIME active: */
264
+ VTIME_GUEST,
273265 };
274266
275267 struct vtime {
276268 seqcount_t seqcount;
277269 unsigned long long starttime;
278270 enum vtime_state state;
271
+ unsigned int cpu;
279272 u64 utime;
280273 u64 stime;
281274 u64 gtime;
....@@ -292,6 +285,11 @@
292285 UCLAMP_MAX,
293286 UCLAMP_CNT
294287 };
288
+
289
+#ifdef CONFIG_SMP
290
+extern struct root_domain def_root_domain;
291
+extern struct mutex sched_domains_mutex;
292
+#endif
295293
296294 struct sched_info {
297295 #ifdef CONFIG_SCHED_INFO
....@@ -354,36 +352,46 @@
354352 * Only for tasks we track a moving average of the past instantaneous
355353 * estimated utilization. This allows to absorb sporadic drops in utilization
356354 * of an otherwise almost periodic task.
355
+ *
356
+ * The UTIL_AVG_UNCHANGED flag is used to synchronize util_est with util_avg
357
+ * updates. When a task is dequeued, its util_est should not be updated if its
358
+ * util_avg has not been updated in the meantime.
359
+ * This information is mapped into the MSB bit of util_est.enqueued at dequeue
360
+ * time. Since max value of util_est.enqueued for a task is 1024 (PELT util_avg
361
+ * for a task) it is safe to use MSB.
357362 */
358363 struct util_est {
359364 unsigned int enqueued;
360365 unsigned int ewma;
361366 #define UTIL_EST_WEIGHT_SHIFT 2
367
+#define UTIL_AVG_UNCHANGED 0x80000000
362368 } __attribute__((__aligned__(sizeof(u64))));
363369
364370 /*
365
- * The load_avg/util_avg accumulates an infinite geometric series
366
- * (see __update_load_avg() in kernel/sched/fair.c).
371
+ * The load/runnable/util_avg accumulates an infinite geometric series
372
+ * (see __update_load_avg_cfs_rq() in kernel/sched/pelt.c).
367373 *
368374 * [load_avg definition]
369375 *
370376 * load_avg = runnable% * scale_load_down(load)
371377 *
372
- * where runnable% is the time ratio that a sched_entity is runnable.
373
- * For cfs_rq, it is the aggregated load_avg of all runnable and
374
- * blocked sched_entities.
378
+ * [runnable_avg definition]
379
+ *
380
+ * runnable_avg = runnable% * SCHED_CAPACITY_SCALE
375381 *
376382 * [util_avg definition]
377383 *
378384 * util_avg = running% * SCHED_CAPACITY_SCALE
379385 *
380
- * where running% is the time ratio that a sched_entity is running on
381
- * a CPU. For cfs_rq, it is the aggregated util_avg of all runnable
382
- * and blocked sched_entities.
386
+ * where runnable% is the time ratio that a sched_entity is runnable and
387
+ * running% the time ratio that a sched_entity is running.
383388 *
384
- * load_avg and util_avg don't direcly factor frequency scaling and CPU
385
- * capacity scaling. The scaling is done through the rq_clock_pelt that
386
- * is used for computing those signals (see update_rq_clock_pelt())
389
+ * For cfs_rq, they are the aggregated values of all runnable and blocked
390
+ * sched_entities.
391
+ *
392
+ * The load/runnable/util_avg doesn't directly factor frequency scaling and CPU
393
+ * capacity scaling. The scaling is done through the rq_clock_pelt that is used
394
+ * for computing those signals (see update_rq_clock_pelt())
387395 *
388396 * N.B., the above ratios (runnable% and running%) themselves are in the
389397 * range of [0, 1]. To do fixed point arithmetics, we therefore scale them
....@@ -407,11 +415,11 @@
407415 struct sched_avg {
408416 u64 last_update_time;
409417 u64 load_sum;
410
- u64 runnable_load_sum;
418
+ u64 runnable_sum;
411419 u32 util_sum;
412420 u32 period_contrib;
413421 unsigned long load_avg;
414
- unsigned long runnable_load_avg;
422
+ unsigned long runnable_avg;
415423 unsigned long util_avg;
416424 struct util_est util_est;
417425 } ____cacheline_aligned;
....@@ -455,7 +463,6 @@
455463 struct sched_entity {
456464 /* For load-balancing: */
457465 struct load_weight load;
458
- unsigned long runnable_weight;
459466 struct rb_node run_node;
460467 struct list_head group_node;
461468 unsigned int on_rq;
....@@ -476,6 +483,8 @@
476483 struct cfs_rq *cfs_rq;
477484 /* rq "owned" by this entity/group: */
478485 struct cfs_rq *my_q;
486
+ /* cached value of my_q->h_nr_running */
487
+ unsigned long runnable_weight;
479488 #endif
480489
481490 #ifdef CONFIG_SMP
....@@ -533,7 +542,7 @@
533542
534543 /*
535544 * Actual scheduling parameters. Initialized with the values above,
536
- * they are continously updated during task execution. Note that
545
+ * they are continuously updated during task execution. Note that
537546 * the remaining runtime could be < 0 in case we are in overrun.
538547 */
539548 s64 runtime; /* Remaining runtime for this instance */
....@@ -546,10 +555,6 @@
546555 * @dl_throttled tells if we exhausted the runtime. If so, the
547556 * task has to wait for a replenishment to be performed at the
548557 * next firing of dl_timer.
549
- *
550
- * @dl_boosted tells if we are boosted due to DI. If so we are
551
- * outside bandwidth enforcement mechanism (but only until we
552
- * exit the critical section);
553558 *
554559 * @dl_yielded tells if task gave up the CPU before consuming
555560 * all its available runtime during the last job.
....@@ -565,7 +570,6 @@
565570 * overruns.
566571 */
567572 unsigned int dl_throttled : 1;
568
- unsigned int dl_boosted : 1;
569573 unsigned int dl_yielded : 1;
570574 unsigned int dl_non_contending : 1;
571575 unsigned int dl_overrun : 1;
....@@ -584,6 +588,15 @@
584588 * time.
585589 */
586590 struct hrtimer inactive_timer;
591
+
592
+#ifdef CONFIG_RT_MUTEXES
593
+ /*
594
+ * Priority Inheritance. When a DEADLINE scheduling entity is boosted
595
+ * pi_se points to the donor, otherwise points to the dl_se it belongs
596
+ * to (the original one/itself).
597
+ */
598
+ struct sched_dl_entity *pi_se;
599
+#endif
587600 };
588601
589602 #ifdef CONFIG_UCLAMP_TASK
....@@ -625,10 +638,8 @@
625638 struct {
626639 u8 blocked;
627640 u8 need_qs;
628
- u8 exp_need_qs;
629
-
630
- /* Otherwise the compiler can store garbage here: */
631
- u8 pad;
641
+ u8 exp_hint; /* Hint for performance. */
642
+ u8 need_mb; /* Readers need smp_mb(). */
632643 } b; /* Bits. */
633644 u32 s; /* Set of bits. */
634645 };
....@@ -644,6 +655,13 @@
644655 struct wake_q_node *next;
645656 };
646657
658
+struct kmap_ctrl {
659
+#ifdef CONFIG_KMAP_LOCAL
660
+ int idx;
661
+ pte_t pteval[KM_MAX_IDX];
662
+#endif
663
+};
664
+
647665 struct task_struct {
648666 #ifdef CONFIG_THREAD_INFO_IN_TASK
649667 /*
....@@ -654,6 +672,8 @@
654672 #endif
655673 /* -1 unrunnable, 0 runnable, >0 stopped: */
656674 volatile long state;
675
+ /* saved state for "spinlock sleepers" */
676
+ volatile long saved_state;
657677
658678 /*
659679 * This begins the randomizable portion of task_struct. Only
....@@ -662,14 +682,14 @@
662682 randomized_struct_fields_start
663683
664684 void *stack;
665
- atomic_t usage;
685
+ refcount_t usage;
666686 /* Per task flags (PF_*), defined further below: */
667687 unsigned int flags;
668688 unsigned int ptrace;
669689
670690 #ifdef CONFIG_SMP
671
- struct llist_node wake_entry;
672691 int on_cpu;
692
+ struct __call_single_node wake_entry;
673693 #ifdef CONFIG_THREAD_INFO_IN_TASK
674694 /* Current CPU: */
675695 unsigned int cpu;
....@@ -698,23 +718,26 @@
698718 const struct sched_class *sched_class;
699719 struct sched_entity se;
700720 struct sched_rt_entity rt;
701
-
702
- /* task boost vendor fields */
703
- u64 last_sleep_ts;
704
- int boost;
705
- u64 boost_period;
706
- u64 boost_expires;
707
-
708721 #ifdef CONFIG_CGROUP_SCHED
709722 struct task_group *sched_task_group;
710723 #endif
711724 struct sched_dl_entity dl;
712725
713726 #ifdef CONFIG_UCLAMP_TASK
714
- /* Clamp values requested for a scheduling entity */
727
+ /*
728
+ * Clamp values requested for a scheduling entity.
729
+ * Must be updated with task_rq_lock() held.
730
+ */
715731 struct uclamp_se uclamp_req[UCLAMP_CNT];
716
- /* Effective clamp values used for a scheduling entity */
732
+ /*
733
+ * Effective clamp values used for a scheduling entity.
734
+ * Must be updated with task_rq_lock() held.
735
+ */
717736 struct uclamp_se uclamp[UCLAMP_CNT];
737
+#endif
738
+
739
+#ifdef CONFIG_HOTPLUG_CPU
740
+ struct list_head percpu_kthread_node;
718741 #endif
719742
720743 #ifdef CONFIG_PREEMPT_NOTIFIERS
....@@ -728,8 +751,13 @@
728751
729752 unsigned int policy;
730753 int nr_cpus_allowed;
731
- cpumask_t cpus_allowed;
732
- cpumask_t cpus_requested;
754
+ const cpumask_t *cpus_ptr;
755
+ cpumask_t cpus_mask;
756
+ void *migration_pending;
757
+#ifdef CONFIG_SMP
758
+ unsigned short migration_disabled;
759
+#endif
760
+ unsigned short migration_flags;
733761
734762 #ifdef CONFIG_PREEMPT_RCU
735763 int rcu_read_lock_nesting;
....@@ -745,6 +773,14 @@
745773 int rcu_tasks_idle_cpu;
746774 struct list_head rcu_tasks_holdout_list;
747775 #endif /* #ifdef CONFIG_TASKS_RCU */
776
+
777
+#ifdef CONFIG_TASKS_TRACE_RCU
778
+ int trc_reader_nesting;
779
+ int trc_ipi_to_cpu;
780
+ union rcu_special trc_reader_special;
781
+ bool trc_reader_checked;
782
+ struct list_head trc_holdout_list;
783
+#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
748784
749785 struct sched_info sched_info;
750786
....@@ -778,7 +814,6 @@
778814 unsigned sched_reset_on_fork:1;
779815 unsigned sched_contributes_to_load:1;
780816 unsigned sched_migrated:1;
781
- unsigned sched_remote_wakeup:1;
782817 #ifdef CONFIG_PSI
783818 unsigned sched_psi_wake_requeue:1;
784819 #endif
....@@ -788,6 +823,21 @@
788823
789824 /* Unserialized, strictly 'current' */
790825
826
+ /*
827
+ * This field must not be in the scheduler word above due to wakelist
828
+ * queueing no longer being serialized by p->on_cpu. However:
829
+ *
830
+ * p->XXX = X; ttwu()
831
+ * schedule() if (p->on_rq && ..) // false
832
+ * smp_mb__after_spinlock(); if (smp_load_acquire(&p->on_cpu) && //true
833
+ * deactivate_task() ttwu_queue_wakelist())
834
+ * p->on_rq = 0; p->sched_remote_wakeup = Y;
835
+ *
836
+ * guarantees all stores of 'current' are visible before
837
+ * ->sched_remote_wakeup gets used, so it can be in this word.
838
+ */
839
+ unsigned sched_remote_wakeup:1;
840
+
791841 /* Bit to tell LSMs we're in execve(): */
792842 unsigned in_execve:1;
793843 unsigned in_iowait:1;
....@@ -796,9 +846,6 @@
796846 #endif
797847 #ifdef CONFIG_MEMCG
798848 unsigned in_user_fault:1;
799
-#ifdef CONFIG_MEMCG_KMEM
800
- unsigned memcg_kmem_skip_account:1;
801
-#endif
802849 #endif
803850 #ifdef CONFIG_COMPAT_BRK
804851 unsigned brk_randomized:1;
....@@ -806,10 +853,19 @@
806853 #ifdef CONFIG_CGROUPS
807854 /* disallow userland-initiated cgroup migration */
808855 unsigned no_cgroup_migration:1;
856
+ /* task is frozen/stopped (used by the cgroup freezer) */
857
+ unsigned frozen:1;
809858 #endif
810859 #ifdef CONFIG_BLK_CGROUP
811
- /* to be used once the psi infrastructure lands upstream. */
812860 unsigned use_memdelay:1;
861
+#endif
862
+#ifdef CONFIG_PSI
863
+ /* Stalled due to lack of memory */
864
+ unsigned in_memstall:1;
865
+#endif
866
+#ifdef CONFIG_EVENTFD
867
+ /* Recursion prevention for eventfd_signal() */
868
+ unsigned in_eventfd_signal:1;
813869 #endif
814870
815871 unsigned long atomic_flags; /* Flags requiring atomic access. */
....@@ -892,15 +948,17 @@
892948 u64 start_time;
893949
894950 /* Boot based time in nsecs: */
895
- u64 real_start_time;
951
+ u64 start_boottime;
896952
897953 /* MM fault and swap info: this can arguably be seen as either mm-specific or thread-specific: */
898954 unsigned long min_flt;
899955 unsigned long maj_flt;
900956
901
-#ifdef CONFIG_POSIX_TIMERS
902
- struct task_cputime cputime_expires;
903
- struct list_head cpu_timers[3];
957
+ /* Empty if CONFIG_POSIX_CPUTIMERS=n */
958
+ struct posix_cputimers posix_cputimers;
959
+
960
+#ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK
961
+ struct posix_cputimers_work posix_cputimers_work;
904962 #endif
905963
906964 /* Process credentials: */
....@@ -913,6 +971,11 @@
913971
914972 /* Effective (overridable) subjective task credentials (COW): */
915973 const struct cred __rcu *cred;
974
+
975
+#ifdef CONFIG_KEYS
976
+ /* Cached requested key. */
977
+ struct key *cached_requested_key;
978
+#endif
916979
917980 /*
918981 * executable name, excluding path.
....@@ -939,25 +1002,36 @@
9391002 /* Open file information: */
9401003 struct files_struct *files;
9411004
1005
+#ifdef CONFIG_IO_URING
1006
+ struct io_uring_task *io_uring;
1007
+#endif
1008
+
9421009 /* Namespaces: */
9431010 struct nsproxy *nsproxy;
9441011
9451012 /* Signal handlers: */
9461013 struct signal_struct *signal;
947
- struct sighand_struct *sighand;
1014
+ struct sighand_struct __rcu *sighand;
1015
+ struct sigqueue *sigqueue_cache;
9481016 sigset_t blocked;
9491017 sigset_t real_blocked;
9501018 /* Restored if set_restore_sigmask() was used: */
9511019 sigset_t saved_sigmask;
9521020 struct sigpending pending;
1021
+#ifdef CONFIG_PREEMPT_RT
1022
+ /* TODO: move me into ->restart_block ? */
1023
+ struct kernel_siginfo forced_info;
1024
+#endif
9531025 unsigned long sas_ss_sp;
9541026 size_t sas_ss_size;
9551027 unsigned int sas_ss_flags;
9561028
9571029 struct callback_head *task_works;
9581030
959
- struct audit_context *audit_context;
1031
+#ifdef CONFIG_AUDIT
9601032 #ifdef CONFIG_AUDITSYSCALL
1033
+ struct audit_context *audit_context;
1034
+#endif
9611035 kuid_t loginuid;
9621036 unsigned int sessionid;
9631037 #endif
....@@ -974,6 +1048,8 @@
9741048 raw_spinlock_t pi_lock;
9751049
9761050 struct wake_q_node wake_q;
1051
+ struct wake_q_node wake_q_sleeper;
1052
+ int wake_q_count;
9771053
9781054 #ifdef CONFIG_RT_MUTEXES
9791055 /* PI waiters blocked on a rt_mutex held by this task: */
....@@ -983,29 +1059,26 @@
9831059 /* Deadlock detection and priority inheritance handling: */
9841060 struct rt_mutex_waiter *pi_blocked_on;
9851061 #endif
986
-#ifdef CONFIG_MM_EVENT_STAT
987
- struct mm_event_task mm_event[MM_TYPE_NUM];
988
- unsigned long next_period;
989
-#endif
1062
+
9901063 #ifdef CONFIG_DEBUG_MUTEXES
9911064 /* Mutex deadlock detection: */
9921065 struct mutex_waiter *blocked_on;
9931066 #endif
9941067
1068
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
1069
+ int non_block_count;
1070
+#endif
1071
+
9951072 #ifdef CONFIG_TRACE_IRQFLAGS
996
- unsigned int irq_events;
997
- unsigned long hardirq_enable_ip;
998
- unsigned long hardirq_disable_ip;
999
- unsigned int hardirq_enable_event;
1000
- unsigned int hardirq_disable_event;
1001
- int hardirqs_enabled;
1002
- int hardirq_context;
1003
- unsigned long softirq_disable_ip;
1004
- unsigned long softirq_enable_ip;
1005
- unsigned int softirq_disable_event;
1006
- unsigned int softirq_enable_event;
1073
+ struct irqtrace_events irqtrace;
1074
+ unsigned int hardirq_threaded;
1075
+ u64 hardirq_chain_key;
10071076 int softirqs_enabled;
10081077 int softirq_context;
1078
+ int irq_config;
1079
+#endif
1080
+#ifdef CONFIG_PREEMPT_RT
1081
+ int softirq_disable_cnt;
10091082 #endif
10101083
10111084 #ifdef CONFIG_LOCKDEP
....@@ -1016,7 +1089,7 @@
10161089 struct held_lock held_locks[MAX_LOCK_DEPTH];
10171090 #endif
10181091
1019
-#ifdef CONFIG_UBSAN
1092
+#if defined(CONFIG_UBSAN) && !defined(CONFIG_UBSAN_TRAP)
10201093 unsigned int in_ubsan;
10211094 #endif
10221095
....@@ -1038,9 +1111,12 @@
10381111
10391112 struct io_context *io_context;
10401113
1114
+#ifdef CONFIG_COMPACTION
1115
+ struct capture_control *capture_control;
1116
+#endif
10411117 /* Ptrace state: */
10421118 unsigned long ptrace_message;
1043
- siginfo_t *last_siginfo;
1119
+ kernel_siginfo_t *last_siginfo;
10441120
10451121 struct task_io_accounting ioac;
10461122 #ifdef CONFIG_PSI
....@@ -1059,7 +1135,7 @@
10591135 /* Protected by ->alloc_lock: */
10601136 nodemask_t mems_allowed;
10611137 /* Seqence number to catch updates: */
1062
- seqcount_t mems_allowed_seq;
1138
+ seqcount_spinlock_t mems_allowed_seq;
10631139 int cpuset_mem_spread_rotor;
10641140 int cpuset_slab_spread_rotor;
10651141 #endif
....@@ -1069,7 +1145,7 @@
10691145 /* cg_list protected by css_set_lock and tsk->alloc_lock: */
10701146 struct list_head cg_list;
10711147 #endif
1072
-#ifdef CONFIG_INTEL_RDT
1148
+#ifdef CONFIG_X86_CPU_RESCTRL
10731149 u32 closid;
10741150 u32 rmid;
10751151 #endif
....@@ -1080,6 +1156,8 @@
10801156 #endif
10811157 struct list_head pi_state_list;
10821158 struct futex_pi_state *pi_state_cache;
1159
+ struct mutex futex_exit_mutex;
1160
+ unsigned int futex_state;
10831161 #endif
10841162 #ifdef CONFIG_PERF_EVENTS
10851163 struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
....@@ -1147,7 +1225,6 @@
11471225
11481226 #ifdef CONFIG_RSEQ
11491227 struct rseq __user *rseq;
1150
- u32 rseq_len;
11511228 u32 rseq_sig;
11521229 /*
11531230 * RmW on rseq_event_mask must be performed atomically
....@@ -1158,7 +1235,10 @@
11581235
11591236 struct tlbflush_unmap_batch tlb_ubc;
11601237
1161
- struct rcu_head rcu;
1238
+ union {
1239
+ refcount_t rcu_users;
1240
+ struct rcu_head rcu;
1241
+ };
11621242
11631243 /* Cache last used pipe for splice(): */
11641244 struct pipe_inode_info *splice_pipe;
....@@ -1193,8 +1273,19 @@
11931273 u64 timer_slack_ns;
11941274 u64 default_timer_slack_ns;
11951275
1196
-#ifdef CONFIG_KASAN
1276
+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
11971277 unsigned int kasan_depth;
1278
+#endif
1279
+
1280
+#ifdef CONFIG_KCSAN
1281
+ struct kcsan_ctx kcsan_ctx;
1282
+#ifdef CONFIG_TRACE_IRQFLAGS
1283
+ struct irqtrace_events kcsan_save_irqtrace;
1284
+#endif
1285
+#endif
1286
+
1287
+#if IS_ENABLED(CONFIG_KUNIT)
1288
+ struct kunit *kunit_test;
11981289 #endif
11991290
12001291 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
....@@ -1246,6 +1337,9 @@
12461337
12471338 /* KCOV sequence number: */
12481339 int kcov_sequence;
1340
+
1341
+ /* Collect coverage from softirq context: */
1342
+ unsigned int kcov_softirq;
12491343 #endif
12501344
12511345 #ifdef CONFIG_MEMCG
....@@ -1271,6 +1365,7 @@
12711365 unsigned int sequential_io;
12721366 unsigned int sequential_io_avg;
12731367 #endif
1368
+ struct kmap_ctrl kmap_ctrl;
12741369 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
12751370 unsigned long task_state_change;
12761371 #endif
....@@ -1283,7 +1378,7 @@
12831378 #endif
12841379 #ifdef CONFIG_THREAD_INFO_IN_TASK
12851380 /* A live task holds one reference: */
1286
- atomic_t stack_refcount;
1381
+ refcount_t stack_refcount;
12871382 #endif
12881383 #ifdef CONFIG_LIVEPATCH
12891384 int patch_state;
....@@ -1292,27 +1387,33 @@
12921387 /* Used by LSM modules for access restriction: */
12931388 void *security;
12941389 #endif
1295
- /* task is frozen/stopped (used by the cgroup freezer) */
1296
- ANDROID_KABI_USE(1, unsigned frozen:1);
12971390
1298
- /* 095444fad7e3 ("futex: Replace PF_EXITPIDONE with a state") */
1299
- ANDROID_KABI_USE(2, unsigned int futex_state);
1391
+#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
1392
+ unsigned long lowest_stack;
1393
+ unsigned long prev_lowest_stack;
1394
+#endif
13001395
1301
- /*
1302
- * f9b0c6c556db ("futex: Add mutex around futex exit")
1303
- * A struct mutex takes 32 bytes, or 4 64bit entries, so pick off
1304
- * 4 of the reserved members, and replace them with a struct mutex.
1305
- * Do the GENKSYMS hack to work around the CRC issues
1306
- */
1307
-#ifdef __GENKSYMS__
1396
+#ifdef CONFIG_X86_MCE
1397
+ void __user *mce_vaddr;
1398
+ __u64 mce_kflags;
1399
+ u64 mce_addr;
1400
+ __u64 mce_ripv : 1,
1401
+ mce_whole_page : 1,
1402
+ __mce_reserved : 62;
1403
+ struct callback_head mce_kill_me;
1404
+ int mce_count;
1405
+#endif
1406
+ ANDROID_VENDOR_DATA_ARRAY(1, 64);
1407
+ ANDROID_OEM_DATA_ARRAY(1, 32);
1408
+
1409
+ /* PF_IO_WORKER */
1410
+ ANDROID_KABI_USE(1, void *pf_io_worker);
1411
+
1412
+ ANDROID_KABI_RESERVE(2);
13081413 ANDROID_KABI_RESERVE(3);
13091414 ANDROID_KABI_RESERVE(4);
13101415 ANDROID_KABI_RESERVE(5);
13111416 ANDROID_KABI_RESERVE(6);
1312
-#else
1313
- struct mutex futex_exit_mutex;
1314
-#endif
1315
-
13161417 ANDROID_KABI_RESERVE(7);
13171418 ANDROID_KABI_RESERVE(8);
13181419
....@@ -1490,9 +1591,10 @@
14901591 /*
14911592 * Per process flags
14921593 */
1594
+#define PF_VCPU 0x00000001 /* I'm a virtual CPU */
14931595 #define PF_IDLE 0x00000002 /* I am an IDLE thread */
14941596 #define PF_EXITING 0x00000004 /* Getting shut down */
1495
-#define PF_VCPU 0x00000010 /* I'm a virtual CPU */
1597
+#define PF_IO_WORKER 0x00000010 /* Task is an IO worker */
14961598 #define PF_WQ_WORKER 0x00000020 /* I'm a workqueue worker */
14971599 #define PF_FORKNOEXEC 0x00000040 /* Forked but didn't exec */
14981600 #define PF_MCE_PROCESS 0x00000080 /* Process policy on mce errors */
....@@ -1507,14 +1609,14 @@
15071609 #define PF_KSWAPD 0x00020000 /* I am kswapd */
15081610 #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
15091611 #define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */
1510
-#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
1612
+#define PF_LOCAL_THROTTLE 0x00100000 /* Throttle writes only against the bdi I write to,
1613
+ * I am cleaning dirty pages from some other bdi. */
15111614 #define PF_KTHREAD 0x00200000 /* I am a kernel thread */
15121615 #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */
15131616 #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
1514
-#define PF_MEMSTALL 0x01000000 /* Stalled due to lack of memory */
1515
-#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
1617
+#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */
15161618 #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1517
-#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
1619
+#define PF_MEMALLOC_NOCMA 0x10000000 /* All allocation request will have _GFP_MOVABLE cleared */
15181620 #define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
15191621 #define PF_SUSPEND_TASK 0x80000000 /* This thread called freeze_processes() and should not be frozen */
15201622
....@@ -1564,6 +1666,7 @@
15641666 #define PFA_SPEC_SSB_FORCE_DISABLE 4 /* Speculative Store Bypass force disabled*/
15651667 #define PFA_SPEC_IB_DISABLE 5 /* Indirect branch speculation restricted */
15661668 #define PFA_SPEC_IB_FORCE_DISABLE 6 /* Indirect branch speculation permanently restricted */
1669
+#define PFA_SPEC_SSB_NOEXEC 7 /* Speculative Store Bypass clear on execve() */
15671670
15681671 #define TASK_PFA_TEST(name, func) \
15691672 static inline bool task_##func(struct task_struct *p) \
....@@ -1592,6 +1695,10 @@
15921695 TASK_PFA_SET(SPEC_SSB_DISABLE, spec_ssb_disable)
15931696 TASK_PFA_CLEAR(SPEC_SSB_DISABLE, spec_ssb_disable)
15941697
1698
+TASK_PFA_TEST(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1699
+TASK_PFA_SET(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1700
+TASK_PFA_CLEAR(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1701
+
15951702 TASK_PFA_TEST(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable)
15961703 TASK_PFA_SET(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable)
15971704
....@@ -1610,10 +1717,21 @@
16101717 }
16111718
16121719 extern int cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
1613
-extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_cpus_allowed);
1720
+extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_effective_cpus);
1721
+
1722
+#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
1723
+extern bool cpupri_check_rt(void);
1724
+#else
1725
+static inline bool cpupri_check_rt(void)
1726
+{
1727
+ return false;
1728
+}
1729
+#endif
1730
+
16141731 #ifdef CONFIG_SMP
16151732 extern void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask);
16161733 extern int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask);
1734
+extern void force_compatible_cpus_allowed_ptr(struct task_struct *p);
16171735 #else
16181736 static inline void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
16191737 {
....@@ -1624,10 +1742,6 @@
16241742 return -EINVAL;
16251743 return 0;
16261744 }
1627
-#endif
1628
-
1629
-#ifndef cpu_relax_yield
1630
-#define cpu_relax_yield() cpu_relax()
16311745 #endif
16321746
16331747 extern int yield_to(struct task_struct *p, bool preempt);
....@@ -1651,6 +1765,9 @@
16511765 extern int available_idle_cpu(int cpu);
16521766 extern int sched_setscheduler(struct task_struct *, int, const struct sched_param *);
16531767 extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *);
1768
+extern void sched_set_fifo(struct task_struct *p);
1769
+extern void sched_set_fifo_low(struct task_struct *p);
1770
+extern void sched_set_normal(struct task_struct *p, int nice);
16541771 extern int sched_setattr(struct task_struct *, const struct sched_attr *);
16551772 extern int sched_setattr_nocheck(struct task_struct *, const struct sched_attr *);
16561773 extern struct task_struct *idle_task(int cpu);
....@@ -1661,7 +1778,7 @@
16611778 *
16621779 * Return: 1 if @p is an idle task. 0 otherwise.
16631780 */
1664
-static inline bool is_idle_task(const struct task_struct *p)
1781
+static __always_inline bool is_idle_task(const struct task_struct *p)
16651782 {
16661783 return !!(p->flags & PF_IDLE);
16671784 }
....@@ -1717,6 +1834,7 @@
17171834
17181835 extern int wake_up_state(struct task_struct *tsk, unsigned int state);
17191836 extern int wake_up_process(struct task_struct *tsk);
1837
+extern int wake_up_lock_sleeper(struct task_struct *tsk);
17201838 extern void wake_up_new_task(struct task_struct *tsk);
17211839
17221840 #ifdef CONFIG_SMP
....@@ -1739,7 +1857,15 @@
17391857 })
17401858
17411859 #ifdef CONFIG_SMP
1742
-void scheduler_ipi(void);
1860
+static __always_inline void scheduler_ipi(void)
1861
+{
1862
+ /*
1863
+ * Fold TIF_NEED_RESCHED into the preempt_count; anybody setting
1864
+ * TIF_NEED_RESCHED remotely (for the first time) will also send
1865
+ * this IPI.
1866
+ */
1867
+ preempt_fold_need_resched();
1868
+}
17431869 extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
17441870 #else
17451871 static inline void scheduler_ipi(void) { }
....@@ -1799,13 +1925,96 @@
17991925 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
18001926 }
18011927
1928
+#ifdef CONFIG_PREEMPT_LAZY
1929
+static inline void set_tsk_need_resched_lazy(struct task_struct *tsk)
1930
+{
1931
+ set_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY);
1932
+}
1933
+
1934
+static inline void clear_tsk_need_resched_lazy(struct task_struct *tsk)
1935
+{
1936
+ clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY);
1937
+}
1938
+
1939
+static inline int test_tsk_need_resched_lazy(struct task_struct *tsk)
1940
+{
1941
+ return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY));
1942
+}
1943
+
1944
+static inline int need_resched_lazy(void)
1945
+{
1946
+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
1947
+}
1948
+
1949
+static inline int need_resched_now(void)
1950
+{
1951
+ return test_thread_flag(TIF_NEED_RESCHED);
1952
+}
1953
+
1954
+#else
1955
+static inline void clear_tsk_need_resched_lazy(struct task_struct *tsk) { }
1956
+static inline int need_resched_lazy(void) { return 0; }
1957
+
1958
+static inline int need_resched_now(void)
1959
+{
1960
+ return test_thread_flag(TIF_NEED_RESCHED);
1961
+}
1962
+
1963
+#endif
1964
+
1965
+
1966
+static inline bool __task_is_stopped_or_traced(struct task_struct *task)
1967
+{
1968
+ if (task->state & (__TASK_STOPPED | __TASK_TRACED))
1969
+ return true;
1970
+#ifdef CONFIG_PREEMPT_RT
1971
+ if (task->saved_state & (__TASK_STOPPED | __TASK_TRACED))
1972
+ return true;
1973
+#endif
1974
+ return false;
1975
+}
1976
+
1977
+static inline bool task_is_stopped_or_traced(struct task_struct *task)
1978
+{
1979
+ bool traced_stopped;
1980
+
1981
+#ifdef CONFIG_PREEMPT_RT
1982
+ unsigned long flags;
1983
+
1984
+ raw_spin_lock_irqsave(&task->pi_lock, flags);
1985
+ traced_stopped = __task_is_stopped_or_traced(task);
1986
+ raw_spin_unlock_irqrestore(&task->pi_lock, flags);
1987
+#else
1988
+ traced_stopped = __task_is_stopped_or_traced(task);
1989
+#endif
1990
+ return traced_stopped;
1991
+}
1992
+
1993
+static inline bool task_is_traced(struct task_struct *task)
1994
+{
1995
+ bool traced = false;
1996
+
1997
+ if (task->state & __TASK_TRACED)
1998
+ return true;
1999
+#ifdef CONFIG_PREEMPT_RT
2000
+ /* in case the task is sleeping on tasklist_lock */
2001
+ raw_spin_lock_irq(&task->pi_lock);
2002
+ if (task->state & __TASK_TRACED)
2003
+ traced = true;
2004
+ else if (task->saved_state & __TASK_TRACED)
2005
+ traced = true;
2006
+ raw_spin_unlock_irq(&task->pi_lock);
2007
+#endif
2008
+ return traced;
2009
+}
2010
+
18022011 /*
18032012 * cond_resched() and cond_resched_lock(): latency reduction via
18042013 * explicit rescheduling in places that are safe. The return
18052014 * value indicates whether a reschedule was done in fact.
18062015 * cond_resched_lock() will drop the spinlock before scheduling,
18072016 */
1808
-#ifndef CONFIG_PREEMPT
2017
+#ifndef CONFIG_PREEMPTION
18092018 extern int _cond_resched(void);
18102019 #else
18112020 static inline int _cond_resched(void) { return 0; }
....@@ -1834,12 +2043,12 @@
18342043
18352044 /*
18362045 * Does a critical section need to be broken due to another
1837
- * task waiting?: (technically does not depend on CONFIG_PREEMPT,
2046
+ * task waiting?: (technically does not depend on CONFIG_PREEMPTION,
18382047 * but a general need for low latency)
18392048 */
18402049 static inline int spin_needbreak(spinlock_t *lock)
18412050 {
1842
-#ifdef CONFIG_PREEMPT
2051
+#ifdef CONFIG_PREEMPTION
18432052 return spin_is_contended(lock);
18442053 #else
18452054 return 0;
....@@ -1889,7 +2098,10 @@
18892098 * running or not.
18902099 */
18912100 #ifndef vcpu_is_preempted
1892
-# define vcpu_is_preempted(cpu) false
2101
+static inline bool vcpu_is_preempted(int cpu)
2102
+{
2103
+ return false;
2104
+}
18932105 #endif
18942106
18952107 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
....@@ -1963,12 +2175,10 @@
19632175 {
19642176 if (clone_flags & CLONE_VM) {
19652177 t->rseq = NULL;
1966
- t->rseq_len = 0;
19672178 t->rseq_sig = 0;
19682179 t->rseq_event_mask = 0;
19692180 } else {
19702181 t->rseq = current->rseq;
1971
- t->rseq_len = current->rseq_len;
19722182 t->rseq_sig = current->rseq_sig;
19732183 t->rseq_event_mask = current->rseq_event_mask;
19742184 }
....@@ -1977,7 +2187,6 @@
19772187 static inline void rseq_execve(struct task_struct *t)
19782188 {
19792189 t->rseq = NULL;
1980
- t->rseq_len = 0;
19812190 t->rseq_sig = 0;
19822191 t->rseq_event_mask = 0;
19832192 }
....@@ -2022,4 +2231,18 @@
20222231
20232232 #endif
20242233
2234
+const struct sched_avg *sched_trace_cfs_rq_avg(struct cfs_rq *cfs_rq);
2235
+char *sched_trace_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len);
2236
+int sched_trace_cfs_rq_cpu(struct cfs_rq *cfs_rq);
2237
+
2238
+const struct sched_avg *sched_trace_rq_avg_rt(struct rq *rq);
2239
+const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq);
2240
+const struct sched_avg *sched_trace_rq_avg_irq(struct rq *rq);
2241
+
2242
+int sched_trace_rq_cpu(struct rq *rq);
2243
+int sched_trace_rq_cpu_capacity(struct rq *rq);
2244
+int sched_trace_rq_nr_running(struct rq *rq);
2245
+
2246
+const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
2247
+
20252248 #endif