hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/sched.h
....@@ -18,25 +18,31 @@
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>
33
-#include <asm/kmap_types.h>
3439
3540 /* task_struct member predeclarations (sorted alphabetically): */
3641 struct audit_context;
3742 struct backing_dev_info;
3843 struct bio_list;
3944 struct blk_plug;
45
+struct capture_control;
4046 struct cfs_rq;
4147 struct fs_struct;
4248 struct futex_pi_state;
....@@ -50,6 +56,8 @@
5056 struct rcu_node;
5157 struct reclaim_state;
5258 struct robust_list_head;
59
+struct root_domain;
60
+struct rq;
5361 struct sched_attr;
5462 struct sched_param;
5563 struct seq_file;
....@@ -57,6 +65,7 @@
5765 struct signal_struct;
5866 struct task_delay_info;
5967 struct task_group;
68
+struct io_uring_task;
6069
6170 /*
6271 * Task state bitmask. NOTE! These bits are also
....@@ -104,11 +113,11 @@
104113 __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
105114 TASK_PARKED)
106115
116
+#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
117
+
107118 #define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
108119
109
-#define task_contributes_to_load(task) ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
110
- (task->flags & PF_FROZEN) == 0 && \
111
- (task->state & TASK_NOLOAD) == 0)
120
+#define task_is_stopped_or_traced(task) ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
112121
113122 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
114123
....@@ -133,9 +142,6 @@
133142 smp_store_mb(current->state, (state_value)); \
134143 } while (0)
135144
136
-#define __set_current_state_no_track(state_value) \
137
- current->state = (state_value);
138
-
139145 #define set_special_state(state_value) \
140146 do { \
141147 unsigned long flags; /* may shadow */ \
....@@ -145,7 +151,6 @@
145151 current->state = (state_value); \
146152 raw_spin_unlock_irqrestore(&current->pi_lock, flags); \
147153 } while (0)
148
-
149154 #else
150155 /*
151156 * set_current_state() includes a barrier so that the write of current->state
....@@ -154,31 +159,31 @@
154159 *
155160 * for (;;) {
156161 * set_current_state(TASK_UNINTERRUPTIBLE);
157
- * if (!need_sleep)
158
- * break;
162
+ * if (CONDITION)
163
+ * break;
159164 *
160165 * schedule();
161166 * }
162167 * __set_current_state(TASK_RUNNING);
163168 *
164169 * If the caller does not need such serialisation (because, for instance, the
165
- * condition test and condition change and wakeup are under the same lock) then
170
+ * CONDITION test and condition change and wakeup are under the same lock) then
166171 * use __set_current_state().
167172 *
168173 * The above is typically ordered against the wakeup, which does:
169174 *
170
- * need_sleep = false;
175
+ * CONDITION = 1;
171176 * wake_up_state(p, TASK_UNINTERRUPTIBLE);
172177 *
173
- * where wake_up_state() executes a full memory barrier before accessing the
174
- * task state.
178
+ * where wake_up_state()/try_to_wake_up() executes a full memory barrier before
179
+ * accessing p->state.
175180 *
176181 * Wakeup will do: if (@state & p->state) p->state = TASK_RUNNING, that is,
177182 * once it observes the TASK_UNINTERRUPTIBLE store the waking CPU can issue a
178183 * TASK_RUNNING store which can collide with __set_current_state(TASK_RUNNING).
179184 *
180185 * However, with slightly different timing the wakeup TASK_RUNNING store can
181
- * also collide with the TASK_UNINTERRUPTIBLE store. Loosing that store is not
186
+ * also collide with the TASK_UNINTERRUPTIBLE store. Losing that store is not
182187 * a problem either because that will result in one extra go around the loop
183188 * and our @cond test will save the day.
184189 *
....@@ -189,9 +194,6 @@
189194
190195 #define set_current_state(state_value) \
191196 smp_store_mb(current->state, (state_value))
192
-
193
-#define __set_current_state_no_track(state_value) \
194
- __set_current_state(state_value)
195197
196198 /*
197199 * set_special_state() should be used for those states when the blocking task
....@@ -223,13 +225,12 @@
223225 extern long schedule_timeout_idle(long timeout);
224226 asmlinkage void schedule(void);
225227 extern void schedule_preempt_disabled(void);
228
+asmlinkage void preempt_schedule_irq(void);
226229
227230 extern int __must_check io_schedule_prepare(void);
228231 extern void io_schedule_finish(int token);
229232 extern long io_schedule_timeout(long timeout);
230233 extern void io_schedule(void);
231
-
232
-int cpu_nr_pinned(int cpu);
233234
234235 /**
235236 * struct prev_cputime - snapshot of system and user cputime
....@@ -248,40 +249,24 @@
248249 #endif
249250 };
250251
251
-/**
252
- * struct task_cputime - collected CPU time counts
253
- * @utime: time spent in user mode, in nanoseconds
254
- * @stime: time spent in kernel mode, in nanoseconds
255
- * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
256
- *
257
- * This structure groups together three kinds of CPU time that are tracked for
258
- * threads and thread groups. Most things considering CPU time want to group
259
- * these counts together and treat all three of them in parallel.
260
- */
261
-struct task_cputime {
262
- u64 utime;
263
- u64 stime;
264
- unsigned long long sum_exec_runtime;
265
-};
266
-
267
-/* Alternate field names when used on cache expirations: */
268
-#define virt_exp utime
269
-#define prof_exp stime
270
-#define sched_exp sum_exec_runtime
271
-
272252 enum vtime_state {
273253 /* Task is sleeping or running in a CPU with VTIME inactive: */
274254 VTIME_INACTIVE = 0,
275
- /* Task runs in userspace in a CPU with VTIME active: */
276
- VTIME_USER,
255
+ /* Task is idle */
256
+ VTIME_IDLE,
277257 /* Task runs in kernelspace in a CPU with VTIME active: */
278258 VTIME_SYS,
259
+ /* Task runs in userspace in a CPU with VTIME active: */
260
+ VTIME_USER,
261
+ /* Task runs as guests in a CPU with VTIME active: */
262
+ VTIME_GUEST,
279263 };
280264
281265 struct vtime {
282266 seqcount_t seqcount;
283267 unsigned long long starttime;
284268 enum vtime_state state;
269
+ unsigned int cpu;
285270 u64 utime;
286271 u64 stime;
287272 u64 gtime;
....@@ -298,6 +283,11 @@
298283 UCLAMP_MAX,
299284 UCLAMP_CNT
300285 };
286
+
287
+#ifdef CONFIG_SMP
288
+extern struct root_domain def_root_domain;
289
+extern struct mutex sched_domains_mutex;
290
+#endif
301291
302292 struct sched_info {
303293 #ifdef CONFIG_SCHED_INFO
....@@ -360,36 +350,46 @@
360350 * Only for tasks we track a moving average of the past instantaneous
361351 * estimated utilization. This allows to absorb sporadic drops in utilization
362352 * of an otherwise almost periodic task.
353
+ *
354
+ * The UTIL_AVG_UNCHANGED flag is used to synchronize util_est with util_avg
355
+ * updates. When a task is dequeued, its util_est should not be updated if its
356
+ * util_avg has not been updated in the meantime.
357
+ * This information is mapped into the MSB bit of util_est.enqueued at dequeue
358
+ * time. Since max value of util_est.enqueued for a task is 1024 (PELT util_avg
359
+ * for a task) it is safe to use MSB.
363360 */
364361 struct util_est {
365362 unsigned int enqueued;
366363 unsigned int ewma;
367364 #define UTIL_EST_WEIGHT_SHIFT 2
365
+#define UTIL_AVG_UNCHANGED 0x80000000
368366 } __attribute__((__aligned__(sizeof(u64))));
369367
370368 /*
371
- * The load_avg/util_avg accumulates an infinite geometric series
372
- * (see __update_load_avg() in kernel/sched/fair.c).
369
+ * The load/runnable/util_avg accumulates an infinite geometric series
370
+ * (see __update_load_avg_cfs_rq() in kernel/sched/pelt.c).
373371 *
374372 * [load_avg definition]
375373 *
376374 * load_avg = runnable% * scale_load_down(load)
377375 *
378
- * where runnable% is the time ratio that a sched_entity is runnable.
379
- * For cfs_rq, it is the aggregated load_avg of all runnable and
380
- * blocked sched_entities.
376
+ * [runnable_avg definition]
377
+ *
378
+ * runnable_avg = runnable% * SCHED_CAPACITY_SCALE
381379 *
382380 * [util_avg definition]
383381 *
384382 * util_avg = running% * SCHED_CAPACITY_SCALE
385383 *
386
- * where running% is the time ratio that a sched_entity is running on
387
- * a CPU. For cfs_rq, it is the aggregated util_avg of all runnable
388
- * and blocked sched_entities.
384
+ * where runnable% is the time ratio that a sched_entity is runnable and
385
+ * running% the time ratio that a sched_entity is running.
389386 *
390
- * load_avg and util_avg don't direcly factor frequency scaling and CPU
391
- * capacity scaling. The scaling is done through the rq_clock_pelt that
392
- * is used for computing those signals (see update_rq_clock_pelt())
387
+ * For cfs_rq, they are the aggregated values of all runnable and blocked
388
+ * sched_entities.
389
+ *
390
+ * The load/runnable/util_avg doesn't directly factor frequency scaling and CPU
391
+ * capacity scaling. The scaling is done through the rq_clock_pelt that is used
392
+ * for computing those signals (see update_rq_clock_pelt())
393393 *
394394 * N.B., the above ratios (runnable% and running%) themselves are in the
395395 * range of [0, 1]. To do fixed point arithmetics, we therefore scale them
....@@ -413,11 +413,11 @@
413413 struct sched_avg {
414414 u64 last_update_time;
415415 u64 load_sum;
416
- u64 runnable_load_sum;
416
+ u64 runnable_sum;
417417 u32 util_sum;
418418 u32 period_contrib;
419419 unsigned long load_avg;
420
- unsigned long runnable_load_avg;
420
+ unsigned long runnable_avg;
421421 unsigned long util_avg;
422422 struct util_est util_est;
423423 } ____cacheline_aligned;
....@@ -461,7 +461,6 @@
461461 struct sched_entity {
462462 /* For load-balancing: */
463463 struct load_weight load;
464
- unsigned long runnable_weight;
465464 struct rb_node run_node;
466465 struct list_head group_node;
467466 unsigned int on_rq;
....@@ -482,6 +481,8 @@
482481 struct cfs_rq *cfs_rq;
483482 /* rq "owned" by this entity/group: */
484483 struct cfs_rq *my_q;
484
+ /* cached value of my_q->h_nr_running */
485
+ unsigned long runnable_weight;
485486 #endif
486487
487488 #ifdef CONFIG_SMP
....@@ -539,7 +540,7 @@
539540
540541 /*
541542 * Actual scheduling parameters. Initialized with the values above,
542
- * they are continously updated during task execution. Note that
543
+ * they are continuously updated during task execution. Note that
543544 * the remaining runtime could be < 0 in case we are in overrun.
544545 */
545546 s64 runtime; /* Remaining runtime for this instance */
....@@ -552,10 +553,6 @@
552553 * @dl_throttled tells if we exhausted the runtime. If so, the
553554 * task has to wait for a replenishment to be performed at the
554555 * next firing of dl_timer.
555
- *
556
- * @dl_boosted tells if we are boosted due to DI. If so we are
557
- * outside bandwidth enforcement mechanism (but only until we
558
- * exit the critical section);
559556 *
560557 * @dl_yielded tells if task gave up the CPU before consuming
561558 * all its available runtime during the last job.
....@@ -571,7 +568,6 @@
571568 * overruns.
572569 */
573570 unsigned int dl_throttled : 1;
574
- unsigned int dl_boosted : 1;
575571 unsigned int dl_yielded : 1;
576572 unsigned int dl_non_contending : 1;
577573 unsigned int dl_overrun : 1;
....@@ -590,6 +586,15 @@
590586 * time.
591587 */
592588 struct hrtimer inactive_timer;
589
+
590
+#ifdef CONFIG_RT_MUTEXES
591
+ /*
592
+ * Priority Inheritance. When a DEADLINE scheduling entity is boosted
593
+ * pi_se points to the donor, otherwise points to the dl_se it belongs
594
+ * to (the original one/itself).
595
+ */
596
+ struct sched_dl_entity *pi_se;
597
+#endif
593598 };
594599
595600 #ifdef CONFIG_UCLAMP_TASK
....@@ -631,10 +636,8 @@
631636 struct {
632637 u8 blocked;
633638 u8 need_qs;
634
- u8 exp_need_qs;
635
-
636
- /* Otherwise the compiler can store garbage here: */
637
- u8 pad;
639
+ u8 exp_hint; /* Hint for performance. */
640
+ u8 need_mb; /* Readers need smp_mb(). */
638641 } b; /* Bits. */
639642 u32 s; /* Set of bits. */
640643 };
....@@ -660,8 +663,6 @@
660663 #endif
661664 /* -1 unrunnable, 0 runnable, >0 stopped: */
662665 volatile long state;
663
- /* saved state for "spinlock sleepers" */
664
- volatile long saved_state;
665666
666667 /*
667668 * This begins the randomizable portion of task_struct. Only
....@@ -670,14 +671,14 @@
670671 randomized_struct_fields_start
671672
672673 void *stack;
673
- atomic_t usage;
674
+ refcount_t usage;
674675 /* Per task flags (PF_*), defined further below: */
675676 unsigned int flags;
676677 unsigned int ptrace;
677678
678679 #ifdef CONFIG_SMP
679
- struct llist_node wake_entry;
680680 int on_cpu;
681
+ struct __call_single_node wake_entry;
681682 #ifdef CONFIG_THREAD_INFO_IN_TASK
682683 /* Current CPU: */
683684 unsigned int cpu;
....@@ -706,23 +707,26 @@
706707 const struct sched_class *sched_class;
707708 struct sched_entity se;
708709 struct sched_rt_entity rt;
709
-
710
- /* task boost vendor fields */
711
- u64 last_sleep_ts;
712
- int boost;
713
- u64 boost_period;
714
- u64 boost_expires;
715
-
716710 #ifdef CONFIG_CGROUP_SCHED
717711 struct task_group *sched_task_group;
718712 #endif
719713 struct sched_dl_entity dl;
720714
721715 #ifdef CONFIG_UCLAMP_TASK
722
- /* Clamp values requested for a scheduling entity */
716
+ /*
717
+ * Clamp values requested for a scheduling entity.
718
+ * Must be updated with task_rq_lock() held.
719
+ */
723720 struct uclamp_se uclamp_req[UCLAMP_CNT];
724
- /* Effective clamp values used for a scheduling entity */
721
+ /*
722
+ * Effective clamp values used for a scheduling entity.
723
+ * Must be updated with task_rq_lock() held.
724
+ */
725725 struct uclamp_se uclamp[UCLAMP_CNT];
726
+#endif
727
+
728
+#ifdef CONFIG_HOTPLUG_CPU
729
+ struct list_head percpu_kthread_node;
726730 #endif
727731
728732 #ifdef CONFIG_PREEMPT_NOTIFIERS
....@@ -736,24 +740,8 @@
736740
737741 unsigned int policy;
738742 int nr_cpus_allowed;
739
-// cpumask_t cpus_allowed;
740
- cpumask_t cpus_requested;
741743 const cpumask_t *cpus_ptr;
742744 cpumask_t cpus_mask;
743
-#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
744
- int migrate_disable;
745
- bool migrate_disable_scheduled;
746
-# ifdef CONFIG_SCHED_DEBUG
747
- int pinned_on_cpu;
748
-# endif
749
-#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
750
-# ifdef CONFIG_SCHED_DEBUG
751
- int migrate_disable;
752
-# endif
753
-#endif
754
-#ifdef CONFIG_PREEMPT_RT_FULL
755
- int sleeping_lock;
756
-#endif
757745
758746 #ifdef CONFIG_PREEMPT_RCU
759747 int rcu_read_lock_nesting;
....@@ -769,6 +757,14 @@
769757 int rcu_tasks_idle_cpu;
770758 struct list_head rcu_tasks_holdout_list;
771759 #endif /* #ifdef CONFIG_TASKS_RCU */
760
+
761
+#ifdef CONFIG_TASKS_TRACE_RCU
762
+ int trc_reader_nesting;
763
+ int trc_ipi_to_cpu;
764
+ union rcu_special trc_reader_special;
765
+ bool trc_reader_checked;
766
+ struct list_head trc_holdout_list;
767
+#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
772768
773769 struct sched_info sched_info;
774770
....@@ -802,7 +798,6 @@
802798 unsigned sched_reset_on_fork:1;
803799 unsigned sched_contributes_to_load:1;
804800 unsigned sched_migrated:1;
805
- unsigned sched_remote_wakeup:1;
806801 #ifdef CONFIG_PSI
807802 unsigned sched_psi_wake_requeue:1;
808803 #endif
....@@ -812,6 +807,21 @@
812807
813808 /* Unserialized, strictly 'current' */
814809
810
+ /*
811
+ * This field must not be in the scheduler word above due to wakelist
812
+ * queueing no longer being serialized by p->on_cpu. However:
813
+ *
814
+ * p->XXX = X; ttwu()
815
+ * schedule() if (p->on_rq && ..) // false
816
+ * smp_mb__after_spinlock(); if (smp_load_acquire(&p->on_cpu) && //true
817
+ * deactivate_task() ttwu_queue_wakelist())
818
+ * p->on_rq = 0; p->sched_remote_wakeup = Y;
819
+ *
820
+ * guarantees all stores of 'current' are visible before
821
+ * ->sched_remote_wakeup gets used, so it can be in this word.
822
+ */
823
+ unsigned sched_remote_wakeup:1;
824
+
815825 /* Bit to tell LSMs we're in execve(): */
816826 unsigned in_execve:1;
817827 unsigned in_iowait:1;
....@@ -820,9 +830,6 @@
820830 #endif
821831 #ifdef CONFIG_MEMCG
822832 unsigned in_user_fault:1;
823
-#ifdef CONFIG_MEMCG_KMEM
824
- unsigned memcg_kmem_skip_account:1;
825
-#endif
826833 #endif
827834 #ifdef CONFIG_COMPAT_BRK
828835 unsigned brk_randomized:1;
....@@ -830,10 +837,15 @@
830837 #ifdef CONFIG_CGROUPS
831838 /* disallow userland-initiated cgroup migration */
832839 unsigned no_cgroup_migration:1;
840
+ /* task is frozen/stopped (used by the cgroup freezer) */
841
+ unsigned frozen:1;
833842 #endif
834843 #ifdef CONFIG_BLK_CGROUP
835
- /* to be used once the psi infrastructure lands upstream. */
836844 unsigned use_memdelay:1;
845
+#endif
846
+#ifdef CONFIG_PSI
847
+ /* Stalled due to lack of memory */
848
+ unsigned in_memstall:1;
837849 #endif
838850
839851 unsigned long atomic_flags; /* Flags requiring atomic access. */
....@@ -916,18 +928,17 @@
916928 u64 start_time;
917929
918930 /* Boot based time in nsecs: */
919
- u64 real_start_time;
931
+ u64 start_boottime;
920932
921933 /* MM fault and swap info: this can arguably be seen as either mm-specific or thread-specific: */
922934 unsigned long min_flt;
923935 unsigned long maj_flt;
924936
925
-#ifdef CONFIG_POSIX_TIMERS
926
- struct task_cputime cputime_expires;
927
- struct list_head cpu_timers[3];
928
-#ifdef CONFIG_PREEMPT_RT_BASE
929
- struct task_struct *posix_timer_list;
930
-#endif
937
+ /* Empty if CONFIG_POSIX_CPUTIMERS=n */
938
+ struct posix_cputimers posix_cputimers;
939
+
940
+#ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK
941
+ struct posix_cputimers_work posix_cputimers_work;
931942 #endif
932943
933944 /* Process credentials: */
....@@ -940,6 +951,11 @@
940951
941952 /* Effective (overridable) subjective task credentials (COW): */
942953 const struct cred __rcu *cred;
954
+
955
+#ifdef CONFIG_KEYS
956
+ /* Cached requested key. */
957
+ struct key *cached_requested_key;
958
+#endif
943959
944960 /*
945961 * executable name, excluding path.
....@@ -966,31 +982,31 @@
966982 /* Open file information: */
967983 struct files_struct *files;
968984
985
+#ifdef CONFIG_IO_URING
986
+ struct io_uring_task *io_uring;
987
+#endif
988
+
969989 /* Namespaces: */
970990 struct nsproxy *nsproxy;
971991
972992 /* Signal handlers: */
973993 struct signal_struct *signal;
974
- struct sighand_struct *sighand;
975
- struct sigqueue *sigqueue_cache;
976
-
994
+ struct sighand_struct __rcu *sighand;
977995 sigset_t blocked;
978996 sigset_t real_blocked;
979997 /* Restored if set_restore_sigmask() was used: */
980998 sigset_t saved_sigmask;
981999 struct sigpending pending;
982
-#ifdef CONFIG_PREEMPT_RT_FULL
983
- /* TODO: move me into ->restart_block ? */
984
- struct siginfo forced_info;
985
-#endif
9861000 unsigned long sas_ss_sp;
9871001 size_t sas_ss_size;
9881002 unsigned int sas_ss_flags;
9891003
9901004 struct callback_head *task_works;
9911005
992
- struct audit_context *audit_context;
1006
+#ifdef CONFIG_AUDIT
9931007 #ifdef CONFIG_AUDITSYSCALL
1008
+ struct audit_context *audit_context;
1009
+#endif
9941010 kuid_t loginuid;
9951011 unsigned int sessionid;
9961012 #endif
....@@ -1007,7 +1023,7 @@
10071023 raw_spinlock_t pi_lock;
10081024
10091025 struct wake_q_node wake_q;
1010
- struct wake_q_node wake_q_sleeper;
1026
+ int wake_q_count;
10111027
10121028 #ifdef CONFIG_RT_MUTEXES
10131029 /* PI waiters blocked on a rt_mutex held by this task: */
....@@ -1017,29 +1033,23 @@
10171033 /* Deadlock detection and priority inheritance handling: */
10181034 struct rt_mutex_waiter *pi_blocked_on;
10191035 #endif
1020
-#ifdef CONFIG_MM_EVENT_STAT
1021
- struct mm_event_task mm_event[MM_TYPE_NUM];
1022
- unsigned long next_period;
1023
-#endif
1036
+
10241037 #ifdef CONFIG_DEBUG_MUTEXES
10251038 /* Mutex deadlock detection: */
10261039 struct mutex_waiter *blocked_on;
10271040 #endif
10281041
1042
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
1043
+ int non_block_count;
1044
+#endif
1045
+
10291046 #ifdef CONFIG_TRACE_IRQFLAGS
1030
- unsigned int irq_events;
1031
- unsigned long hardirq_enable_ip;
1032
- unsigned long hardirq_disable_ip;
1033
- unsigned int hardirq_enable_event;
1034
- unsigned int hardirq_disable_event;
1035
- int hardirqs_enabled;
1036
- int hardirq_context;
1037
- unsigned long softirq_disable_ip;
1038
- unsigned long softirq_enable_ip;
1039
- unsigned int softirq_disable_event;
1040
- unsigned int softirq_enable_event;
1047
+ struct irqtrace_events irqtrace;
1048
+ unsigned int hardirq_threaded;
1049
+ u64 hardirq_chain_key;
10411050 int softirqs_enabled;
10421051 int softirq_context;
1052
+ int irq_config;
10431053 #endif
10441054
10451055 #ifdef CONFIG_LOCKDEP
....@@ -1050,7 +1060,7 @@
10501060 struct held_lock held_locks[MAX_LOCK_DEPTH];
10511061 #endif
10521062
1053
-#ifdef CONFIG_UBSAN
1063
+#if defined(CONFIG_UBSAN) && !defined(CONFIG_UBSAN_TRAP)
10541064 unsigned int in_ubsan;
10551065 #endif
10561066
....@@ -1072,9 +1082,12 @@
10721082
10731083 struct io_context *io_context;
10741084
1085
+#ifdef CONFIG_COMPACTION
1086
+ struct capture_control *capture_control;
1087
+#endif
10751088 /* Ptrace state: */
10761089 unsigned long ptrace_message;
1077
- siginfo_t *last_siginfo;
1090
+ kernel_siginfo_t *last_siginfo;
10781091
10791092 struct task_io_accounting ioac;
10801093 #ifdef CONFIG_PSI
....@@ -1093,7 +1106,7 @@
10931106 /* Protected by ->alloc_lock: */
10941107 nodemask_t mems_allowed;
10951108 /* Seqence number to catch updates: */
1096
- seqcount_t mems_allowed_seq;
1109
+ seqcount_spinlock_t mems_allowed_seq;
10971110 int cpuset_mem_spread_rotor;
10981111 int cpuset_slab_spread_rotor;
10991112 #endif
....@@ -1103,7 +1116,7 @@
11031116 /* cg_list protected by css_set_lock and tsk->alloc_lock: */
11041117 struct list_head cg_list;
11051118 #endif
1106
-#ifdef CONFIG_INTEL_RDT
1119
+#ifdef CONFIG_X86_CPU_RESCTRL
11071120 u32 closid;
11081121 u32 rmid;
11091122 #endif
....@@ -1114,6 +1127,8 @@
11141127 #endif
11151128 struct list_head pi_state_list;
11161129 struct futex_pi_state *pi_state_cache;
1130
+ struct mutex futex_exit_mutex;
1131
+ unsigned int futex_state;
11171132 #endif
11181133 #ifdef CONFIG_PERF_EVENTS
11191134 struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
....@@ -1181,7 +1196,6 @@
11811196
11821197 #ifdef CONFIG_RSEQ
11831198 struct rseq __user *rseq;
1184
- u32 rseq_len;
11851199 u32 rseq_sig;
11861200 /*
11871201 * RmW on rseq_event_mask must be performed atomically
....@@ -1192,7 +1206,10 @@
11921206
11931207 struct tlbflush_unmap_batch tlb_ubc;
11941208
1195
- struct rcu_head rcu;
1209
+ union {
1210
+ refcount_t rcu_users;
1211
+ struct rcu_head rcu;
1212
+ };
11961213
11971214 /* Cache last used pipe for splice(): */
11981215 struct pipe_inode_info *splice_pipe;
....@@ -1227,8 +1244,19 @@
12271244 u64 timer_slack_ns;
12281245 u64 default_timer_slack_ns;
12291246
1230
-#ifdef CONFIG_KASAN
1247
+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
12311248 unsigned int kasan_depth;
1249
+#endif
1250
+
1251
+#ifdef CONFIG_KCSAN
1252
+ struct kcsan_ctx kcsan_ctx;
1253
+#ifdef CONFIG_TRACE_IRQFLAGS
1254
+ struct irqtrace_events kcsan_save_irqtrace;
1255
+#endif
1256
+#endif
1257
+
1258
+#if IS_ENABLED(CONFIG_KUNIT)
1259
+ struct kunit *kunit_test;
12321260 #endif
12331261
12341262 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
....@@ -1280,6 +1308,9 @@
12801308
12811309 /* KCOV sequence number: */
12821310 int kcov_sequence;
1311
+
1312
+ /* Collect coverage from softirq context: */
1313
+ unsigned int kcov_softirq;
12831314 #endif
12841315
12851316 #ifdef CONFIG_MEMCG
....@@ -1305,22 +1336,8 @@
13051336 unsigned int sequential_io;
13061337 unsigned int sequential_io_avg;
13071338 #endif
1308
-#ifdef CONFIG_PREEMPT_RT_BASE
1309
- struct rcu_head put_rcu;
1310
- int softirq_nestcnt;
1311
- unsigned int softirqs_raised;
1312
-#endif
1313
-#ifdef CONFIG_PREEMPT_RT_FULL
1314
-# if defined CONFIG_HIGHMEM || defined CONFIG_X86_32
1315
- int kmap_idx;
1316
- pte_t kmap_pte[KM_TYPE_NR];
1317
-# endif
1318
-#endif
13191339 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
13201340 unsigned long task_state_change;
1321
-#endif
1322
-#ifdef CONFIG_PREEMPT_RT_FULL
1323
- int xmit_recursion;
13241341 #endif
13251342 int pagefault_disabled;
13261343 #ifdef CONFIG_MMU
....@@ -1331,7 +1348,7 @@
13311348 #endif
13321349 #ifdef CONFIG_THREAD_INFO_IN_TASK
13331350 /* A live task holds one reference: */
1334
- atomic_t stack_refcount;
1351
+ refcount_t stack_refcount;
13351352 #endif
13361353 #ifdef CONFIG_LIVEPATCH
13371354 int patch_state;
....@@ -1340,27 +1357,33 @@
13401357 /* Used by LSM modules for access restriction: */
13411358 void *security;
13421359 #endif
1343
- /* task is frozen/stopped (used by the cgroup freezer) */
1344
- ANDROID_KABI_USE(1, unsigned frozen:1);
13451360
1346
- /* 095444fad7e3 ("futex: Replace PF_EXITPIDONE with a state") */
1347
- ANDROID_KABI_USE(2, unsigned int futex_state);
1361
+#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
1362
+ unsigned long lowest_stack;
1363
+ unsigned long prev_lowest_stack;
1364
+#endif
13481365
1349
- /*
1350
- * f9b0c6c556db ("futex: Add mutex around futex exit")
1351
- * A struct mutex takes 32 bytes, or 4 64bit entries, so pick off
1352
- * 4 of the reserved members, and replace them with a struct mutex.
1353
- * Do the GENKSYMS hack to work around the CRC issues
1354
- */
1355
-#ifdef __GENKSYMS__
1366
+#ifdef CONFIG_X86_MCE
1367
+ void __user *mce_vaddr;
1368
+ __u64 mce_kflags;
1369
+ u64 mce_addr;
1370
+ __u64 mce_ripv : 1,
1371
+ mce_whole_page : 1,
1372
+ __mce_reserved : 62;
1373
+ struct callback_head mce_kill_me;
1374
+ int mce_count;
1375
+#endif
1376
+ ANDROID_VENDOR_DATA_ARRAY(1, 64);
1377
+ ANDROID_OEM_DATA_ARRAY(1, 32);
1378
+
1379
+ /* PF_IO_WORKER */
1380
+ ANDROID_KABI_USE(1, void *pf_io_worker);
1381
+
1382
+ ANDROID_KABI_RESERVE(2);
13561383 ANDROID_KABI_RESERVE(3);
13571384 ANDROID_KABI_RESERVE(4);
13581385 ANDROID_KABI_RESERVE(5);
13591386 ANDROID_KABI_RESERVE(6);
1360
-#else
1361
- struct mutex futex_exit_mutex;
1362
-#endif
1363
-
13641387 ANDROID_KABI_RESERVE(7);
13651388 ANDROID_KABI_RESERVE(8);
13661389
....@@ -1538,10 +1561,10 @@
15381561 /*
15391562 * Per process flags
15401563 */
1541
-#define PF_IN_SOFTIRQ 0x00000001 /* Task is serving softirq */
1564
+#define PF_VCPU 0x00000001 /* I'm a virtual CPU */
15421565 #define PF_IDLE 0x00000002 /* I am an IDLE thread */
15431566 #define PF_EXITING 0x00000004 /* Getting shut down */
1544
-#define PF_VCPU 0x00000010 /* I'm a virtual CPU */
1567
+#define PF_IO_WORKER 0x00000010 /* Task is an IO worker */
15451568 #define PF_WQ_WORKER 0x00000020 /* I'm a workqueue worker */
15461569 #define PF_FORKNOEXEC 0x00000040 /* Forked but didn't exec */
15471570 #define PF_MCE_PROCESS 0x00000080 /* Process policy on mce errors */
....@@ -1556,14 +1579,14 @@
15561579 #define PF_KSWAPD 0x00020000 /* I am kswapd */
15571580 #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
15581581 #define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */
1559
-#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
1582
+#define PF_LOCAL_THROTTLE 0x00100000 /* Throttle writes only against the bdi I write to,
1583
+ * I am cleaning dirty pages from some other bdi. */
15601584 #define PF_KTHREAD 0x00200000 /* I am a kernel thread */
15611585 #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */
15621586 #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
1563
-#define PF_MEMSTALL 0x01000000 /* Stalled due to lack of memory */
1564
-#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
1587
+#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */
15651588 #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1566
-#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
1589
+#define PF_MEMALLOC_NOCMA 0x10000000 /* All allocation request will have _GFP_MOVABLE cleared */
15671590 #define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
15681591 #define PF_SUSPEND_TASK 0x80000000 /* This thread called freeze_processes() and should not be frozen */
15691592
....@@ -1613,6 +1636,7 @@
16131636 #define PFA_SPEC_SSB_FORCE_DISABLE 4 /* Speculative Store Bypass force disabled*/
16141637 #define PFA_SPEC_IB_DISABLE 5 /* Indirect branch speculation restricted */
16151638 #define PFA_SPEC_IB_FORCE_DISABLE 6 /* Indirect branch speculation permanently restricted */
1639
+#define PFA_SPEC_SSB_NOEXEC 7 /* Speculative Store Bypass clear on execve() */
16161640
16171641 #define TASK_PFA_TEST(name, func) \
16181642 static inline bool task_##func(struct task_struct *p) \
....@@ -1641,6 +1665,10 @@
16411665 TASK_PFA_SET(SPEC_SSB_DISABLE, spec_ssb_disable)
16421666 TASK_PFA_CLEAR(SPEC_SSB_DISABLE, spec_ssb_disable)
16431667
1668
+TASK_PFA_TEST(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1669
+TASK_PFA_SET(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1670
+TASK_PFA_CLEAR(SPEC_SSB_NOEXEC, spec_ssb_noexec)
1671
+
16441672 TASK_PFA_TEST(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable)
16451673 TASK_PFA_SET(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable)
16461674
....@@ -1659,10 +1687,21 @@
16591687 }
16601688
16611689 extern int cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
1662
-extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_cpus_allowed);
1690
+extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_effective_cpus);
1691
+
1692
+#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
1693
+extern bool cpupri_check_rt(void);
1694
+#else
1695
+static inline bool cpupri_check_rt(void)
1696
+{
1697
+ return false;
1698
+}
1699
+#endif
1700
+
16631701 #ifdef CONFIG_SMP
16641702 extern void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask);
16651703 extern int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask);
1704
+extern void force_compatible_cpus_allowed_ptr(struct task_struct *p);
16661705 #else
16671706 static inline void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
16681707 {
....@@ -1673,10 +1712,6 @@
16731712 return -EINVAL;
16741713 return 0;
16751714 }
1676
-#endif
1677
-
1678
-#ifndef cpu_relax_yield
1679
-#define cpu_relax_yield() cpu_relax()
16801715 #endif
16811716
16821717 extern int yield_to(struct task_struct *p, bool preempt);
....@@ -1700,6 +1735,9 @@
17001735 extern int available_idle_cpu(int cpu);
17011736 extern int sched_setscheduler(struct task_struct *, int, const struct sched_param *);
17021737 extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *);
1738
+extern void sched_set_fifo(struct task_struct *p);
1739
+extern void sched_set_fifo_low(struct task_struct *p);
1740
+extern void sched_set_normal(struct task_struct *p, int nice);
17031741 extern int sched_setattr(struct task_struct *, const struct sched_attr *);
17041742 extern int sched_setattr_nocheck(struct task_struct *, const struct sched_attr *);
17051743 extern struct task_struct *idle_task(int cpu);
....@@ -1710,7 +1748,7 @@
17101748 *
17111749 * Return: 1 if @p is an idle task. 0 otherwise.
17121750 */
1713
-static inline bool is_idle_task(const struct task_struct *p)
1751
+static __always_inline bool is_idle_task(const struct task_struct *p)
17141752 {
17151753 return !!(p->flags & PF_IDLE);
17161754 }
....@@ -1766,7 +1804,6 @@
17661804
17671805 extern int wake_up_state(struct task_struct *tsk, unsigned int state);
17681806 extern int wake_up_process(struct task_struct *tsk);
1769
-extern int wake_up_lock_sleeper(struct task_struct *tsk);
17701807 extern void wake_up_new_task(struct task_struct *tsk);
17711808
17721809 #ifdef CONFIG_SMP
....@@ -1789,7 +1826,15 @@
17891826 })
17901827
17911828 #ifdef CONFIG_SMP
1792
-void scheduler_ipi(void);
1829
+static __always_inline void scheduler_ipi(void)
1830
+{
1831
+ /*
1832
+ * Fold TIF_NEED_RESCHED into the preempt_count; anybody setting
1833
+ * TIF_NEED_RESCHED remotely (for the first time) will also send
1834
+ * this IPI.
1835
+ */
1836
+ preempt_fold_need_resched();
1837
+}
17931838 extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
17941839 #else
17951840 static inline void scheduler_ipi(void) { }
....@@ -1849,96 +1894,13 @@
18491894 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
18501895 }
18511896
1852
-#ifdef CONFIG_PREEMPT_LAZY
1853
-static inline void set_tsk_need_resched_lazy(struct task_struct *tsk)
1854
-{
1855
- set_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY);
1856
-}
1857
-
1858
-static inline void clear_tsk_need_resched_lazy(struct task_struct *tsk)
1859
-{
1860
- clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY);
1861
-}
1862
-
1863
-static inline int test_tsk_need_resched_lazy(struct task_struct *tsk)
1864
-{
1865
- return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED_LAZY));
1866
-}
1867
-
1868
-static inline int need_resched_lazy(void)
1869
-{
1870
- return test_thread_flag(TIF_NEED_RESCHED_LAZY);
1871
-}
1872
-
1873
-static inline int need_resched_now(void)
1874
-{
1875
- return test_thread_flag(TIF_NEED_RESCHED);
1876
-}
1877
-
1878
-#else
1879
-static inline void clear_tsk_need_resched_lazy(struct task_struct *tsk) { }
1880
-static inline int need_resched_lazy(void) { return 0; }
1881
-
1882
-static inline int need_resched_now(void)
1883
-{
1884
- return test_thread_flag(TIF_NEED_RESCHED);
1885
-}
1886
-
1887
-#endif
1888
-
1889
-
1890
-static inline bool __task_is_stopped_or_traced(struct task_struct *task)
1891
-{
1892
- if (task->state & (__TASK_STOPPED | __TASK_TRACED))
1893
- return true;
1894
-#ifdef CONFIG_PREEMPT_RT_FULL
1895
- if (task->saved_state & (__TASK_STOPPED | __TASK_TRACED))
1896
- return true;
1897
-#endif
1898
- return false;
1899
-}
1900
-
1901
-static inline bool task_is_stopped_or_traced(struct task_struct *task)
1902
-{
1903
- bool traced_stopped;
1904
-
1905
-#ifdef CONFIG_PREEMPT_RT_FULL
1906
- unsigned long flags;
1907
-
1908
- raw_spin_lock_irqsave(&task->pi_lock, flags);
1909
- traced_stopped = __task_is_stopped_or_traced(task);
1910
- raw_spin_unlock_irqrestore(&task->pi_lock, flags);
1911
-#else
1912
- traced_stopped = __task_is_stopped_or_traced(task);
1913
-#endif
1914
- return traced_stopped;
1915
-}
1916
-
1917
-static inline bool task_is_traced(struct task_struct *task)
1918
-{
1919
- bool traced = false;
1920
-
1921
- if (task->state & __TASK_TRACED)
1922
- return true;
1923
-#ifdef CONFIG_PREEMPT_RT_FULL
1924
- /* in case the task is sleeping on tasklist_lock */
1925
- raw_spin_lock_irq(&task->pi_lock);
1926
- if (task->state & __TASK_TRACED)
1927
- traced = true;
1928
- else if (task->saved_state & __TASK_TRACED)
1929
- traced = true;
1930
- raw_spin_unlock_irq(&task->pi_lock);
1931
-#endif
1932
- return traced;
1933
-}
1934
-
19351897 /*
19361898 * cond_resched() and cond_resched_lock(): latency reduction via
19371899 * explicit rescheduling in places that are safe. The return
19381900 * value indicates whether a reschedule was done in fact.
19391901 * cond_resched_lock() will drop the spinlock before scheduling,
19401902 */
1941
-#ifndef CONFIG_PREEMPT
1903
+#ifndef CONFIG_PREEMPTION
19421904 extern int _cond_resched(void);
19431905 #else
19441906 static inline int _cond_resched(void) { return 0; }
....@@ -1967,12 +1929,12 @@
19671929
19681930 /*
19691931 * Does a critical section need to be broken due to another
1970
- * task waiting?: (technically does not depend on CONFIG_PREEMPT,
1932
+ * task waiting?: (technically does not depend on CONFIG_PREEMPTION,
19711933 * but a general need for low latency)
19721934 */
19731935 static inline int spin_needbreak(spinlock_t *lock)
19741936 {
1975
-#ifdef CONFIG_PREEMPT
1937
+#ifdef CONFIG_PREEMPTION
19761938 return spin_is_contended(lock);
19771939 #else
19781940 return 0;
....@@ -1983,23 +1945,6 @@
19831945 {
19841946 return unlikely(tif_need_resched());
19851947 }
1986
-
1987
-#ifdef CONFIG_PREEMPT_RT_FULL
1988
-static inline void sleeping_lock_inc(void)
1989
-{
1990
- current->sleeping_lock++;
1991
-}
1992
-
1993
-static inline void sleeping_lock_dec(void)
1994
-{
1995
- current->sleeping_lock--;
1996
-}
1997
-
1998
-#else
1999
-
2000
-static inline void sleeping_lock_inc(void) { }
2001
-static inline void sleeping_lock_dec(void) { }
2002
-#endif
20031948
20041949 /*
20051950 * Wrappers for p->thread_info->cpu access. No-op on UP.
....@@ -2039,7 +1984,10 @@
20391984 * running or not.
20401985 */
20411986 #ifndef vcpu_is_preempted
2042
-# define vcpu_is_preempted(cpu) false
1987
+static inline bool vcpu_is_preempted(int cpu)
1988
+{
1989
+ return false;
1990
+}
20431991 #endif
20441992
20451993 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
....@@ -2113,12 +2061,10 @@
21132061 {
21142062 if (clone_flags & CLONE_VM) {
21152063 t->rseq = NULL;
2116
- t->rseq_len = 0;
21172064 t->rseq_sig = 0;
21182065 t->rseq_event_mask = 0;
21192066 } else {
21202067 t->rseq = current->rseq;
2121
- t->rseq_len = current->rseq_len;
21222068 t->rseq_sig = current->rseq_sig;
21232069 t->rseq_event_mask = current->rseq_event_mask;
21242070 }
....@@ -2127,7 +2073,6 @@
21272073 static inline void rseq_execve(struct task_struct *t)
21282074 {
21292075 t->rseq = NULL;
2130
- t->rseq_len = 0;
21312076 t->rseq_sig = 0;
21322077 t->rseq_event_mask = 0;
21332078 }
....@@ -2172,6 +2117,18 @@
21722117
21732118 #endif
21742119
2175
-extern struct task_struct *takedown_cpu_task;
2120
+const struct sched_avg *sched_trace_cfs_rq_avg(struct cfs_rq *cfs_rq);
2121
+char *sched_trace_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len);
2122
+int sched_trace_cfs_rq_cpu(struct cfs_rq *cfs_rq);
2123
+
2124
+const struct sched_avg *sched_trace_rq_avg_rt(struct rq *rq);
2125
+const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq);
2126
+const struct sched_avg *sched_trace_rq_avg_irq(struct rq *rq);
2127
+
2128
+int sched_trace_rq_cpu(struct rq *rq);
2129
+int sched_trace_rq_cpu_capacity(struct rq *rq);
2130
+int sched_trace_rq_nr_running(struct rq *rq);
2131
+
2132
+const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
21762133
21772134 #endif