Re: [PATCH] sched: Fix rq nr_uninterruptible count

From: Bagas Sanjaya
Date: Tue Feb 28 2023 - 03:57:15 EST


On Tue, Feb 28, 2023 at 03:08:58PM +0800, zhenggy wrote:
> When an uninterrptable task is queue to a differect cpu as where
> it is dequeued, the rq nr_uninterruptible will be incorrent, so
> fix it.

tl;dr (too much typos above). Would you like to "massage" the commit
mesage?

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 25b582b..cd5ef6e 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4068,6 +4068,7 @@ bool ttwu_state_match(struct task_struct *p, unsigned int state, int *success)
> {
> unsigned long flags;
> int cpu, success = 0;
> + struct rq *src_rq, *dst_rq;
>
> preempt_disable();
> if (p == current) {
> @@ -4205,6 +4206,16 @@ bool ttwu_state_match(struct task_struct *p, unsigned int state, int *success)
> atomic_dec(&task_rq(p)->nr_iowait);
> }
>
> + if (p->sched_contributes_to_load) {
> + src_rq = cpu_rq(task_cpu(p));
> + dst_rq = cpu_rq(cpu);
> +
> + double_rq_lock(src_rq, dst_rq);
> + src_rq->nr_uninterruptible--;
> + dst_rq->nr_uninterruptible++;
> + double_rq_unlock(src_rq, dst_rq);
> + }
> +

Can you explain what the code above does to fix the problem you
mentioned above?

Thanks.

--
An old man doll... just what I always wanted! - Clara

Attachment: signature.asc
Description: PGP signature