]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - include/linux/sched.h
sched: Add TASK_WAKING
[mirror_ubuntu-jammy-kernel.git] / include / linux / sched.h
index 379531c089757525a5829be14e2b946cef33f2b8..3b0ca66bd6cee1c577d0ee9751797ac47517afdc 100644 (file)
@@ -38,6 +38,8 @@
 #define SCHED_BATCH            3
 /* SCHED_ISO: reserved but not implemented yet */
 #define SCHED_IDLE             5
+/* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
+#define SCHED_RESET_ON_FORK     0x40000000
 
 #ifdef __KERNEL__
 
@@ -188,6 +190,7 @@ extern unsigned long long time_sync_thresh;
 /* in tsk->state again */
 #define TASK_DEAD              64
 #define TASK_WAKEKILL          128
+#define TASK_WAKING            256
 
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE          (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
@@ -796,18 +799,20 @@ enum cpu_idle_type {
 #define SCHED_LOAD_SCALE_FUZZ  SCHED_LOAD_SCALE
 
 #ifdef CONFIG_SMP
-#define SD_LOAD_BALANCE                1       /* Do load balancing on this domain. */
-#define SD_BALANCE_NEWIDLE     2       /* Balance when about to become idle */
-#define SD_BALANCE_EXEC                4       /* Balance on exec */
-#define SD_BALANCE_FORK                8       /* Balance on fork, clone */
-#define SD_WAKE_IDLE           16      /* Wake to idle CPU on task wakeup */
-#define SD_WAKE_AFFINE         32      /* Wake task to waking CPU */
-#define SD_WAKE_BALANCE                64      /* Perform balancing at task wakeup */
-#define SD_SHARE_CPUPOWER      128     /* Domain members share cpu power */
-#define SD_POWERSAVINGS_BALANCE        256     /* Balance for power savings */
-#define SD_SHARE_PKG_RESOURCES 512     /* Domain members share cpu pkg resources */
-#define SD_SERIALIZE           1024    /* Only a single load balancing instance */
-#define SD_WAKE_IDLE_FAR       2048    /* Gain latency sacrificing cache hit */
+#define SD_LOAD_BALANCE                0x0001  /* Do load balancing on this domain. */
+#define SD_BALANCE_NEWIDLE     0x0002  /* Balance when about to become idle */
+#define SD_BALANCE_EXEC                0x0004  /* Balance on exec */
+#define SD_BALANCE_FORK                0x0008  /* Balance on fork, clone */
+#define SD_WAKE_IDLE           0x0010  /* Wake to idle CPU on task wakeup */
+#define SD_WAKE_AFFINE         0x0020  /* Wake task to waking CPU */
+#define SD_WAKE_BALANCE                0x0040  /* Perform balancing at task wakeup */
+#define SD_SHARE_CPUPOWER      0x0080  /* Domain members share cpu power */
+#define SD_POWERSAVINGS_BALANCE        0x0100  /* Balance for power savings */
+#define SD_SHARE_PKG_RESOURCES 0x0200  /* Domain members share cpu pkg resources */
+#define SD_SERIALIZE           0x0400  /* Only a single load balancing instance */
+#define SD_WAKE_IDLE_FAR       0x0800  /* Gain latency sacrificing cache hit */
+#define SD_PREFER_SIBLING      0x1000  /* Prefer to place tasks in a sibling domain */
+#define SD_BALANCE_WAKE                0x2000  /* Balance on wakeup */
 
 enum powersavings_balance_level {
        POWERSAVINGS_BALANCE_NONE = 0,  /* No power saving load balance */
@@ -827,7 +832,7 @@ static inline int sd_balance_for_mc_power(void)
        if (sched_smt_power_savings)
                return SD_POWERSAVINGS_BALANCE;
 
-       return 0;
+       return SD_PREFER_SIBLING;
 }
 
 static inline int sd_balance_for_package_power(void)
@@ -835,7 +840,7 @@ static inline int sd_balance_for_package_power(void)
        if (sched_mc_power_savings | sched_smt_power_savings)
                return SD_POWERSAVINGS_BALANCE;
 
-       return 0;
+       return SD_PREFER_SIBLING;
 }
 
 /*
@@ -857,15 +862,9 @@ struct sched_group {
 
        /*
         * CPU power of this group, SCHED_LOAD_SCALE being max power for a
-        * single CPU. This is read only (except for setup, hotplug CPU).
-        * Note : Never change cpu_power without recompute its reciprocal
-        */
-       unsigned int __cpu_power;
-       /*
-        * reciprocal value of cpu_power to avoid expensive divides
-        * (see include/linux/reciprocal_div.h)
+        * single CPU.
         */
-       u32 reciprocal_cpu_power;
+       unsigned int cpu_power;
 
        /*
         * The CPUs this group covers.
@@ -918,6 +917,7 @@ struct sched_domain {
        unsigned int newidle_idx;
        unsigned int wake_idx;
        unsigned int forkexec_idx;
+       unsigned int smt_gain;
        int flags;                      /* See SD_* */
        enum sched_domain_level level;
 
@@ -1034,7 +1034,7 @@ struct sched_class {
        void (*put_prev_task) (struct rq *rq, struct task_struct *p);
 
 #ifdef CONFIG_SMP
-       int  (*select_task_rq)(struct task_struct *p, int sync);
+       int  (*select_task_rq)(struct task_struct *p, int flag, int sync);
 
        unsigned long (*load_balance) (struct rq *this_rq, int this_cpu,
                        struct rq *busiest, unsigned long max_load_move,
@@ -1045,7 +1045,6 @@ struct sched_class {
                              struct rq *busiest, struct sched_domain *sd,
                              enum cpu_idle_type idle);
        void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
-       int (*needs_post_schedule) (struct rq *this_rq);
        void (*post_schedule) (struct rq *this_rq);
        void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
 
@@ -1110,6 +1109,8 @@ struct sched_entity {
        u64                     wait_max;
        u64                     wait_count;
        u64                     wait_sum;
+       u64                     iowait_count;
+       u64                     iowait_sum;
 
        u64                     sleep_start;
        u64                     sleep_max;
@@ -1234,11 +1235,19 @@ struct task_struct {
        unsigned did_exec:1;
        unsigned in_execve:1;   /* Tell the LSMs that the process is doing an
                                 * execve */
+       unsigned in_iowait:1;
+
+
+       /* Revert to default priority/policy when forking */
+       unsigned sched_reset_on_fork:1;
+
        pid_t pid;
        pid_t tgid;
 
+#ifdef CONFIG_CC_STACKPROTECTOR
        /* Canary value for the -fstack-protector gcc feature */
        unsigned long stack_canary;
+#endif
 
        /* 
         * pointers to (original) parent process, youngest child, younger sibling,
@@ -1840,11 +1849,12 @@ extern unsigned int sysctl_sched_min_granularity;
 extern unsigned int sysctl_sched_wakeup_granularity;
 extern unsigned int sysctl_sched_shares_ratelimit;
 extern unsigned int sysctl_sched_shares_thresh;
-#ifdef CONFIG_SCHED_DEBUG
 extern unsigned int sysctl_sched_child_runs_first;
+#ifdef CONFIG_SCHED_DEBUG
 extern unsigned int sysctl_sched_features;
 extern unsigned int sysctl_sched_migration_cost;
 extern unsigned int sysctl_sched_nr_migrate;
+extern unsigned int sysctl_sched_time_avg;
 extern unsigned int sysctl_timer_migration;
 
 int sched_nr_latency_handler(struct ctl_table *table, int write,
@@ -2308,23 +2318,31 @@ static inline int need_resched(void)
  * cond_resched_softirq() will enable bhs before scheduling.
  */
 extern int _cond_resched(void);
-#ifdef CONFIG_PREEMPT_BKL
-static inline int cond_resched(void)
-{
-       return 0;
-}
+
+#define cond_resched() ({                      \
+       __might_sleep(__FILE__, __LINE__, 0);   \
+       _cond_resched();                        \
+})
+
+extern int __cond_resched_lock(spinlock_t *lock);
+
+#ifdef CONFIG_PREEMPT
+#define PREEMPT_LOCK_OFFSET    PREEMPT_OFFSET
 #else
-static inline int cond_resched(void)
-{
-       return _cond_resched();
-}
+#define PREEMPT_LOCK_OFFSET    0
 #endif
-extern int cond_resched_lock(spinlock_t * lock);
-extern int cond_resched_softirq(void);
-static inline int cond_resched_bkl(void)
-{
-       return _cond_resched();
-}
+
+#define cond_resched_lock(lock) ({                             \
+       __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
+       __cond_resched_lock(lock);                              \
+})
+
+extern int __cond_resched_softirq(void);
+
+#define cond_resched_softirq() ({                              \
+       __might_sleep(__FILE__, __LINE__, SOFTIRQ_OFFSET);      \
+       __cond_resched_softirq();                               \
+})
 
 /*
  * Does a critical section need to be broken due to another