]> Git Repo - linux.git/commitdiff
Merge tag 'sched_ext-for-6.14-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Fri, 14 Feb 2025 19:14:24 +0000 (11:14 -0800)
committerLinus Torvalds <[email protected]>
Fri, 14 Feb 2025 19:14:24 +0000 (11:14 -0800)
Pull sched_ext fixes from Tejun Heo:

 - Fix lock imbalance in a corner case of dispatch_to_local_dsq()

 - Migration disabled tasks were confusing some BPF schedulers and its
   handling had a bug. Fix it and simplify the default behavior by
   dispatching them automatically

 - ops.tick(), ops.disable() and ops.exit_task() were incorrectly
   disallowing kfuncs that require the task argument to be the rq
   operation is currently operating on and thus is rq-locked.
   Allow them.

 - Fix autogroup migration handling bug which was occasionally
   triggering a warning in the cgroup migration path

 - tools/sched_ext, selftest and other misc updates

* tag 'sched_ext-for-6.14-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext:
  sched_ext: Use SCX_CALL_OP_TASK in task_tick_scx
  sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h.
  sched_ext: selftests: Fix grammar in tests description
  sched_ext: Fix incorrect assumption about migration disabled tasks in task_can_run_on_remote_rq()
  sched_ext: Fix migration disabled handling in targeted dispatches
  sched_ext: Implement auto local dispatching of migration disabled tasks
  sched_ext: Fix incorrect time delta calculation in time_delta()
  sched_ext: Fix lock imbalance in dispatch_to_local_dsq()
  sched_ext: selftests/dsp_local_on: Fix selftest on UP systems
  tools/sched_ext: Add helper to check task migration state
  sched_ext: Fix incorrect autogroup migration detection
  sched_ext: selftests/dsp_local_on: Fix sporadic failures
  selftests/sched_ext: Fix enum resolution
  sched_ext: Include task weight in the error state dump
  sched_ext: Fixes typos in comments

1  2 
kernel/sched/autogroup.c
kernel/sched/core.c

diff --combined kernel/sched/autogroup.c
index 83d46b9b8ec8c0f2fc329889d8ee68ab3ea1b71a,c4a3ccf6a8ace490effae08c2268b69a10a6ea5a..2b331822c7e7705218eedc0060412623470947d1
@@@ -9,7 -9,7 +9,7 @@@ static struct autogroup autogroup_defau
  static atomic_t autogroup_seq_nr;
  
  #ifdef CONFIG_SYSCTL
 -static struct ctl_table sched_autogroup_sysctls[] = {
 +static const struct ctl_table sched_autogroup_sysctls[] = {
        {
                .procname       = "sched_autogroup_enabled",
                .data           = &sysctl_sched_autogroup_enabled,
@@@ -150,7 -150,7 +150,7 @@@ void sched_autogroup_exit_task(struct t
         * see this thread after that: we can no longer use signal->autogroup.
         * See the PF_EXITING check in task_wants_autogroup().
         */
-       sched_move_task(p);
+       sched_move_task(p, true);
  }
  
  static void
@@@ -182,7 -182,7 +182,7 @@@ autogroup_move_group(struct task_struc
         * sched_autogroup_exit_task().
         */
        for_each_thread(p, t)
-               sched_move_task(t);
+               sched_move_task(t, true);
  
        unlock_task_sighand(p, &flags);
        autogroup_kref_put(prev);
diff --combined kernel/sched/core.c
index 165c90ba64ea93b65e4db83f7b0d411553e4fdc0,e77897a62442e2eecc603f24f2b9a7e473f4a451..5404a303199d925ab37f8ad17d2a8aa8cddf29ec
@@@ -4654,7 -4654,7 +4654,7 @@@ static int sysctl_schedstats(const stru
  #endif /* CONFIG_SCHEDSTATS */
  
  #ifdef CONFIG_SYSCTL
 -static struct ctl_table sched_core_sysctls[] = {
 +static const struct ctl_table sched_core_sysctls[] = {
  #ifdef CONFIG_SCHEDSTATS
        {
                .procname       = "sched_schedstats",
@@@ -7709,9 -7709,9 +7709,9 @@@ void sched_show_task(struct task_struc
        if (pid_alive(p))
                ppid = task_pid_nr(rcu_dereference(p->real_parent));
        rcu_read_unlock();
 -      pr_cont(" stack:%-5lu pid:%-5d tgid:%-5d ppid:%-6d flags:0x%08lx\n",
 +      pr_cont(" stack:%-5lu pid:%-5d tgid:%-5d ppid:%-6d task_flags:0x%04x flags:0x%08lx\n",
                free, task_pid_nr(p), task_tgid_nr(p),
 -              ppid, read_task_thread_flags(p));
 +              ppid, p->flags, read_task_thread_flags(p));
  
        print_worker_info(KERN_INFO, p);
        print_stop_info(KERN_INFO, p);
@@@ -7938,26 -7938,19 +7938,26 @@@ void sched_setnuma(struct task_struct *
  
  #ifdef CONFIG_HOTPLUG_CPU
  /*
 - * Ensure that the idle task is using init_mm right before its CPU goes
 - * offline.
 + * Invoked on the outgoing CPU in context of the CPU hotplug thread
 + * after ensuring that there are no user space tasks left on the CPU.
 + *
 + * If there is a lazy mm in use on the hotplug thread, drop it and
 + * switch to init_mm.
 + *
 + * The reference count on init_mm is dropped in finish_cpu().
   */
 -void idle_task_exit(void)
 +static void sched_force_init_mm(void)
  {
        struct mm_struct *mm = current->active_mm;
  
 -      BUG_ON(cpu_online(smp_processor_id()));
 -      BUG_ON(current != this_rq()->idle);
 -
        if (mm != &init_mm) {
 -              switch_mm(mm, &init_mm, current);
 +              mmgrab_lazy_tlb(&init_mm);
 +              local_irq_disable();
 +              current->active_mm = &init_mm;
 +              switch_mm_irqs_off(mm, &init_mm, current);
 +              local_irq_enable();
                finish_arch_post_lock_switch();
 +              mmdrop_lazy_tlb(mm);
        }
  
        /* finish_cpu(), as ran on the BP, will clean up the active_mm state */
@@@ -8351,7 -8344,6 +8351,7 @@@ int sched_cpu_starting(unsigned int cpu
  int sched_cpu_wait_empty(unsigned int cpu)
  {
        balance_hotplug_wait();
 +      sched_force_init_mm();
        return 0;
  }
  
@@@ -9050,7 -9042,7 +9050,7 @@@ static void sched_change_group(struct t
   * now. This function just updates tsk->se.cfs_rq and tsk->se.parent to reflect
   * its new group.
   */
- void sched_move_task(struct task_struct *tsk)
+ void sched_move_task(struct task_struct *tsk, bool for_autogroup)
  {
        int queued, running, queue_flags =
                DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
                put_prev_task(rq, tsk);
  
        sched_change_group(tsk, group);
-       scx_move_task(tsk);
+       if (!for_autogroup)
+               scx_cgroup_move_task(tsk);
  
        if (queued)
                enqueue_task(rq, tsk, queue_flags);
@@@ -9180,7 -9173,7 +9181,7 @@@ static void cpu_cgroup_attach(struct cg
        struct cgroup_subsys_state *css;
  
        cgroup_taskset_for_each(task, css, tset)
-               sched_move_task(task);
+               sched_move_task(task, false);
  
        scx_cgroup_finish_attach();
  }
@@@ -10598,7 -10591,7 +10599,7 @@@ void task_tick_mm_cid(struct rq *rq, st
                return;
  
        /* No page allocation under rq lock */
 -      task_work_add(curr, work, TWA_RESUME | TWAF_NO_ALLOC);
 +      task_work_add(curr, work, TWA_RESUME);
  }
  
  void sched_mm_cid_exit_signals(struct task_struct *t)
This page took 0.147125 seconds and 4 git commands to generate.