All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Euan Bourke" <euan@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	linux-s390@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH] s390/hiperdispatch: use system_dfl_wq to reschedule hd_capacity_work
Date: Thu, 10 Sep 2026 08:09:20 +0000	[thread overview]
Message-ID: <20260910080920.983591F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910075746.1233706-1-euan@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Replacing `schedule_delayed_work()` with `mod_delayed_work()` introduces a race condition that can inadvertently overwrite the longer initial delay set by `hd_enable_hiperdispatch()`.
--

commit 2fd466459ccefd111b375205c56ee7b3c6f6c69b
Author: Euan Bourke <euan@linux.ibm.com>

s390/hiperdispatch: use system_dfl_wq to reschedule hd_capacity_work

This commit updates hd_capacity_work to be rescheduled on system_dfl_wq
instead of system_percpu_wq. It accomplishes this by replacing
schedule_delayed_work() with mod_delayed_work().

> diff --git a/arch/s390/kernel/hiperdispatch.c b/arch/s390/kernel/hiperdispatch.c
> index 2172065222661..2b9187e472170 100644
> --- a/arch/s390/kernel/hiperdispatch.c
> +++ b/arch/s390/kernel/hiperdispatch.c
> @@ -265,7 +265,7 @@ static void hd_capacity_work_fn(struct work_struct *work)
>  	}
>  	trace_s390_hd_work_fn(steal_percentage, hd_entitled_cores, hd_high_capacity_cores);
>  	mutex_unlock(&smp_cpu_state_mutex);
> -	schedule_delayed_work(&hd_capacity_work, HD_DELAY_INTERVAL);
> +	mod_delayed_work(system_dfl_wq, &hd_capacity_work, HD_DELAY_INTERVAL);

[Severity: Medium]
Does replacing schedule_delayed_work() with mod_delayed_work() introduce a
race condition that could inadvertently overwrite the initial delay set by
hd_enable_hiperdispatch()?

If hd_capacity_work_fn() drops smp_cpu_state_mutex, and a concurrent CPU
topology update runs arch_update_cpu_topology() and acquires the mutex:

CPU 1:
hd_capacity_work_fn()
    mutex_unlock(&smp_cpu_state_mutex);
    <preempted or delayed>

CPU 2:
arch_update_cpu_topology()
    mutex_lock(&smp_cpu_state_mutex);
    hd_enable_hiperdispatch()
        mod_delayed_work(..., &hd_capacity_work, 1 second timer);

CPU 1:
    mod_delayed_work(system_dfl_wq, &hd_capacity_work, HD_DELAY_INTERVAL);

Could CPU 1 overwrite the longer 1-second delay set by CPU 2 with its
shorter 250ms timer (HD_DELAY_INTERVAL)?

The original schedule_delayed_work() internally uses queue_delayed_work(),
which safely ignores the queue request if the work is already pending,
preserving the longer interval. By switching to mod_delayed_work(), we now
unconditionally modify the timer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910075746.1233706-1-euan@linux.ibm.com?part=1

      reply	other threads:[~2026-09-10  8:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  7:57 [PATCH] s390/hiperdispatch: use system_dfl_wq to reschedule hd_capacity_work Euan Bourke
2026-09-10  8:09 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260910080920.983591F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=euan@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.