]> Git Repo - linux.git/commitdiff
Merge tag 'sched-urgent-2022-08-06' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Sun, 7 Aug 2022 00:34:06 +0000 (17:34 -0700)
committerLinus Torvalds <[email protected]>
Sun, 7 Aug 2022 00:34:06 +0000 (17:34 -0700)
Pull scheduler fixes from Ingo Molnar:
 "Various fixes: a deadline scheduler fix, a migration fix, a Sparse fix
  and a comment fix"

* tag 'sched-urgent-2022-08-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/core: Do not requeue task on CPU excluded from cpus_mask
  sched/rt: Fix Sparse warnings due to undefined rt.c declarations
  exit: Fix typo in comment: s/sub-theads/sub-threads
  sched, cpuset: Fix dl_cpu_busy() panic due to empty cs->cpus_allowed

1  2 
include/linux/sched.h
kernel/sched/core.c
kernel/sched/sched.h

diff --combined include/linux/sched.h
index 0bbfee0bb028c83ccd8941c93383112ebccb5d7d,6a060160f0db818413ef357368acd5a0d9ec865e..e7b2f8a5c711c1942abcdc6b2640f66bea868b25
@@@ -34,7 -34,6 +34,7 @@@
  #include <linux/rseq.h>
  #include <linux/seqlock.h>
  #include <linux/kcsan.h>
 +#include <linux/rv.h>
  #include <asm/kmap_size.h>
  
  /* task_struct member predeclarations (sorted alphabetically): */
@@@ -844,9 -843,8 +844,9 @@@ struct task_struct 
        int                             trc_reader_nesting;
        int                             trc_ipi_to_cpu;
        union rcu_special               trc_reader_special;
 -      bool                            trc_reader_checked;
        struct list_head                trc_holdout_list;
 +      struct list_head                trc_blkd_node;
 +      int                             trc_blkd_cpu;
  #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
  
        struct sched_info               sched_info;
        struct callback_head            l1d_flush_kill;
  #endif
  
 +#ifdef CONFIG_RV
 +      /*
 +       * Per-task RV monitor. Nowadays fixed in RV_PER_TASK_MONITORS.
 +       * If we find justification for more monitors, we can think
 +       * about adding more or developing a dynamic method. So far,
 +       * none of these are justified.
 +       */
 +      union rv_task_monitor           rv[RV_PER_TASK_MONITORS];
 +#endif
 +
        /*
         * New fields for task_struct should be added above here, so that
         * they are included in the randomized portion of task_struct.
@@@ -1825,7 -1813,7 +1825,7 @@@ current_restore_flags(unsigned long ori
  }
  
  extern int cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
- extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_cpus_allowed);
+ extern int task_can_attach(struct task_struct *p, const struct cpumask *cs_effective_cpus);
  #ifdef CONFIG_SMP
  extern void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask);
  extern int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask);
@@@ -2235,7 -2223,6 +2235,7 @@@ static inline void set_task_cpu(struct 
  
  extern bool sched_task_on_rq(struct task_struct *p);
  extern unsigned long get_wchan(struct task_struct *p);
 +extern struct task_struct *cpu_curr_snapshot(int cpu);
  
  /*
   * In order to reduce various lock holder preemption latencies provide an
diff --combined kernel/sched/core.c
index 189999007f327c27ceae655c527d8fec08dc92e9,02afa1cc3c8c364c4977d6321d387901a267cbd0..ee28253c9ac0c2ed4e602a9584b5e1a77c4f2825
@@@ -91,7 -91,7 +91,7 @@@
  #include "stats.h"
  
  #include "../workqueue_internal.h"
 -#include "../../fs/io-wq.h"
 +#include "../../io_uring/io-wq.h"
  #include "../smpboot.h"
  
  /*
@@@ -3802,7 -3802,7 +3802,7 @@@ bool cpus_share_cache(int this_cpu, in
        return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
  }
  
- static inline bool ttwu_queue_cond(int cpu)
+ static inline bool ttwu_queue_cond(struct task_struct *p, int cpu)
  {
        /*
         * Do not complicate things with the async wake_list while the CPU is
        if (!cpu_active(cpu))
                return false;
  
+       /* Ensure the task will still be allowed to run on the CPU. */
+       if (!cpumask_test_cpu(cpu, p->cpus_ptr))
+               return false;
        /*
         * If the CPU does not share cache, then queue the task on the
         * remote rqs wakelist to avoid accessing remote data.
  
  static bool ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags)
  {
-       if (sched_feat(TTWU_QUEUE) && ttwu_queue_cond(cpu)) {
+       if (sched_feat(TTWU_QUEUE) && ttwu_queue_cond(p, cpu)) {
                sched_clock_cpu(cpu); /* Sync clocks across CPUs */
                __ttwu_queue_wakelist(p, cpu, wake_flags);
                return true;
@@@ -4262,38 -4266,6 +4266,38 @@@ int task_call_func(struct task_struct *
        return ret;
  }
  
 +/**
 + * cpu_curr_snapshot - Return a snapshot of the currently running task
 + * @cpu: The CPU on which to snapshot the task.
 + *
 + * Returns the task_struct pointer of the task "currently" running on
 + * the specified CPU.  If the same task is running on that CPU throughout,
 + * the return value will be a pointer to that task's task_struct structure.
 + * If the CPU did any context switches even vaguely concurrently with the
 + * execution of this function, the return value will be a pointer to the
 + * task_struct structure of a randomly chosen task that was running on
 + * that CPU somewhere around the time that this function was executing.
 + *
 + * If the specified CPU was offline, the return value is whatever it
 + * is, perhaps a pointer to the task_struct structure of that CPU's idle
 + * task, but there is no guarantee.  Callers wishing a useful return
 + * value must take some action to ensure that the specified CPU remains
 + * online throughout.
 + *
 + * This function executes full memory barriers before and after fetching
 + * the pointer, which permits the caller to confine this function's fetch
 + * with respect to the caller's accesses to other shared variables.
 + */
 +struct task_struct *cpu_curr_snapshot(int cpu)
 +{
 +      struct task_struct *t;
 +
 +      smp_mb(); /* Pairing determined by caller's synchronization design. */
 +      t = rcu_dereference(cpu_curr(cpu));
 +      smp_mb(); /* Pairing determined by caller's synchronization design. */
 +      return t;
 +}
 +
  /**
   * wake_up_process - Wake up a specific process
   * @p: The process to be woken up.
@@@ -6595,7 -6567,7 +6599,7 @@@ void __sched schedule_idle(void
        } while (need_resched());
  }
  
 -#if defined(CONFIG_CONTEXT_TRACKING) && !defined(CONFIG_HAVE_CONTEXT_TRACKING_OFFSTACK)
 +#if defined(CONFIG_CONTEXT_TRACKING_USER) && !defined(CONFIG_HAVE_CONTEXT_TRACKING_USER_OFFSTACK)
  asmlinkage __visible void __sched schedule_user(void)
  {
        /*
@@@ -9012,7 -8984,7 +9016,7 @@@ int cpuset_cpumask_can_shrink(const str
  }
  
  int task_can_attach(struct task_struct *p,
-                   const struct cpumask *cs_cpus_allowed)
+                   const struct cpumask *cs_effective_cpus)
  {
        int ret = 0;
  
        }
  
        if (dl_task(p) && !cpumask_intersects(task_rq(p)->rd->span,
-                                             cs_cpus_allowed)) {
-               int cpu = cpumask_any_and(cpu_active_mask, cs_cpus_allowed);
+                                             cs_effective_cpus)) {
+               int cpu = cpumask_any_and(cpu_active_mask, cs_effective_cpus);
  
+               if (unlikely(cpu >= nr_cpu_ids))
+                       return -EINVAL;
                ret = dl_cpu_busy(cpu, p);
        }
  
diff --combined kernel/sched/sched.h
index a6f071b2acacf586f2322bf9f7f9a514d171f5ea,1429315610d981f7b360eb7b499a9432e0c9572c..e26688d387aebe3588b9175de20f3b646c7fd8e3
@@@ -27,7 -27,6 +27,7 @@@
  #include <linux/capability.h>
  #include <linux/cgroup_api.h>
  #include <linux/cgroup.h>
 +#include <linux/context_tracking.h>
  #include <linux/cpufreq.h>
  #include <linux/cpumask_api.h>
  #include <linux/ctype.h>
@@@ -481,9 -480,6 +481,6 @@@ extern void __refill_cfs_bandwidth_runt
  extern void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b);
  extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq);
  
- extern void unregister_rt_sched_group(struct task_group *tg);
- extern void free_rt_sched_group(struct task_group *tg);
- extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent);
  extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
                struct sched_rt_entity *rt_se, int cpu,
                struct sched_rt_entity *parent);
@@@ -521,6 -517,10 +518,10 @@@ struct cfs_bandwidth { }
  
  #endif        /* CONFIG_CGROUP_SCHED */
  
+ extern void unregister_rt_sched_group(struct task_group *tg);
+ extern void free_rt_sched_group(struct task_group *tg);
+ extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent);
  /*
   * u64_u32_load/u64_u32_store
   *
This page took 0.149783 seconds and 4 git commands to generate.