Skip to content

Commit 7528960

Browse files
committed
Merge: sched: Fix migrate_swap() vs. hotplug
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7236 JIRA: https://issues.redhat.com/browse/RHEL-107437 Two fixes from upstream are needed for commits we have in the rhel9 tree. Signed-off-by: Phil Auld <[email protected]> Approved-by: Herton R. Krzesinski <[email protected]> Approved-by: Waiman Long <[email protected]> Approved-by: Juri Lelli <[email protected]> Approved-by: Rafael Aquini <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Jarod Wilson <[email protected]>
2 parents 2b9439b + 4855fea commit 7528960

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

kernel/sched/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,6 +3830,11 @@ bool cpus_share_resources(int this_cpu, int that_cpu)
38303830

38313831
static inline bool ttwu_queue_cond(struct task_struct *p, int cpu)
38323832
{
3833+
#ifdef CONFIG_SMP
3834+
if (p->sched_class == &stop_sched_class)
3835+
return false;
3836+
#endif
3837+
38333838
/*
38343839
* Do not complicate things with the async wake_list while the CPU is
38353840
* in hotplug state.

kernel/sched/loadavg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ long calc_load_fold_active(struct rq *this_rq, long adjust)
8080
long nr_active, delta = 0;
8181

8282
nr_active = this_rq->nr_running - adjust;
83-
nr_active += (int)this_rq->nr_uninterruptible;
83+
nr_active += (long)this_rq->nr_uninterruptible;
8484

8585
if (nr_active != this_rq->calc_load_active) {
8686
delta = nr_active - this_rq->calc_load_active;

kernel/sched/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ struct rq {
10791079
* one CPU and if it got migrated afterwards it may decrease
10801080
* it on another CPU. Always updated under the runqueue lock:
10811081
*/
1082-
unsigned int nr_uninterruptible;
1082+
unsigned long nr_uninterruptible;
10831083

10841084
struct task_struct __rcu *curr;
10851085
struct task_struct *idle;

kernel/stop_machine.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,29 @@ static void cpu_stop_signal_done(struct cpu_stop_done *done)
8282
}
8383

8484
static void __cpu_stop_queue_work(struct cpu_stopper *stopper,
85-
struct cpu_stop_work *work,
86-
struct wake_q_head *wakeq)
85+
struct cpu_stop_work *work)
8786
{
8887
list_add_tail(&work->list, &stopper->works);
89-
wake_q_add(wakeq, stopper->thread);
9088
}
9189

9290
/* queue @work to @stopper. if offline, @work is completed immediately */
9391
static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
9492
{
9593
struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
96-
DEFINE_WAKE_Q(wakeq);
9794
unsigned long flags;
9895
bool enabled;
9996

10097
preempt_disable();
10198
raw_spin_lock_irqsave(&stopper->lock, flags);
10299
enabled = stopper->enabled;
103100
if (enabled)
104-
__cpu_stop_queue_work(stopper, work, &wakeq);
101+
__cpu_stop_queue_work(stopper, work);
105102
else if (work->done)
106103
cpu_stop_signal_done(work->done);
107104
raw_spin_unlock_irqrestore(&stopper->lock, flags);
108105

109-
wake_up_q(&wakeq);
106+
if (enabled)
107+
wake_up_process(stopper->thread);
110108
preempt_enable();
111109

112110
return enabled;
@@ -263,7 +261,6 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
263261
{
264262
struct cpu_stopper *stopper1 = per_cpu_ptr(&cpu_stopper, cpu1);
265263
struct cpu_stopper *stopper2 = per_cpu_ptr(&cpu_stopper, cpu2);
266-
DEFINE_WAKE_Q(wakeq);
267264
int err;
268265

269266
retry:
@@ -299,8 +296,8 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
299296
}
300297

301298
err = 0;
302-
__cpu_stop_queue_work(stopper1, work1, &wakeq);
303-
__cpu_stop_queue_work(stopper2, work2, &wakeq);
299+
__cpu_stop_queue_work(stopper1, work1);
300+
__cpu_stop_queue_work(stopper2, work2);
304301

305302
unlock:
306303
raw_spin_unlock(&stopper2->lock);
@@ -315,7 +312,10 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
315312
goto retry;
316313
}
317314

318-
wake_up_q(&wakeq);
315+
if (!err) {
316+
wake_up_process(stopper1->thread);
317+
wake_up_process(stopper2->thread);
318+
}
319319
preempt_enable();
320320

321321
return err;

0 commit comments

Comments
 (0)