Subject: linux-next: manual merge of the sched-ext tree with the tip tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 1 Aug 2024 12:45:45 +1000

Hi all,

Today's linux-next merge of the sched-ext tree got a conflict in:

  kernel/sched/core.c

between commits:

  c245910049d0 ("sched/core: Add clearing of ->dl_server in put_prev_task_balance()")
  31b164e2e4af ("sched/smt: Introduce sched_smt_present_inc/dec() helper")

from the tip tree and commits:

  60c27fb59f6c ("sched_ext: Implement sched_ext_ops.cpu_online/offline()")
  a7a9fc549293 ("sched_ext: Add boilerplate for extensible scheduler class")

from the sched-ext tree.

I fixed it up (I think, see below) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc kernel/sched/core.c
index 73fa0290fd8f,22f86d5e9231..000000000000
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@@ -5878,10 -5901,23 +5947,15 @@@ __pick_next_task(struct rq *rq, struct 
  restart:
  	put_prev_task_balance(rq, prev, rf);
  
- 	for_each_class(class) {
 -	/*
 -	 * We've updated @prev and no longer need the server link, clear it.
 -	 * Must be done before ->pick_next_task() because that can (re)set
 -	 * ->dl_server.
 -	 */
 -	if (prev->dl_server)
 -		prev->dl_server = NULL;
 -
+ 	for_each_active_class(class) {
  		p = class->pick_next_task(rq);
- 		if (p)
+ 		if (p) {
+ 			const struct sched_class *prev_class = prev->sched_class;
+ 
+ 			if (class != prev_class && prev_class->switch_class)
+ 				prev_class->switch_class(rq, p);
  			return p;
+ 		}
  	}
  
  	BUG(); /* The idle class should always have a runnable task. */
@@@ -8040,8 -8056,16 +8122,10 @@@ int sched_cpu_deactivate(unsigned int c
  	 */
  	synchronize_rcu();
  
 -	rq_lock_irqsave(rq, &rf);
 -	if (rq->rd) {
 -		BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
 -		set_rq_offline(rq);
 -	}
 -	rq_unlock_irqrestore(rq, &rf);
 +	sched_set_rq_offline(rq, cpu);
  
+ 	scx_rq_deactivate(rq);
+ 
 -#ifdef CONFIG_SCHED_SMT
  	/*
  	 * When going down, decrement the number of cores with SMT present.
  	 */