public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Davis <goldside000@outlook.com>, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org,
	Steven Davis <goldside000@outlook.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ankur Arora <ankur.a.arora@oracle.com>,
	Frederic Weisbecker <frederic@kernel.org>
Subject: Re: [PATCH] irq_work: Improve CPU Responsiveness in irq_work_sync with cond_resched()
Date: Thu, 19 Sep 2024 15:54:21 +0200	[thread overview]
Message-ID: <87frpv21gy.ffs@tglx> (raw)
In-Reply-To: <SJ2P223MB10263844181902531B671FB6F7622@SJ2P223MB1026.NAMP223.PROD.OUTLOOK.COM>

On Wed, Sep 18 2024 at 11:23, Steven Davis wrote:
> Add cond_resched() to the busy-wait loop in irq_work_sync to improve
> CPU responsiveness and prevent starvation of other tasks.
>
> Previously, the busy-wait loop used cpu_relax() alone, which, while
> reducing power consumption, could still lead to excessive CPU
> monopolization in scenarios where IRQ work remains busy for extended
> periods. By incorporating cond_resched(), the CPU is periodically yielded
> to the scheduler, allowing other tasks to execute and enhancing overall
> system responsiveness.
>  
> -	while (irq_work_is_busy(work))
> +	int retry_count = 0;
> +
> +	while (irq_work_is_busy(work)) {
>  		cpu_relax();
> +
> +	if (retry_count++ > 1000) {
> +		cond_resched();
> +		retry_count = 0;
> +	}

Did you verify that all callers are actually calling from preemptible
context?

If so, then we should just get rid of the loop waiting completely and
use the rcu_wait mechanism which RT uses.

Thanks,

        tglx

  reply	other threads:[~2024-09-19 13:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 15:23 [PATCH] irq_work: Improve CPU Responsiveness in irq_work_sync with cond_resched() Steven Davis
2024-09-19 13:54 ` Thomas Gleixner [this message]
2024-09-19 15:25   ` Steven Davis
2024-09-21 14:42 ` kernel test robot
2024-09-21 15:13 ` kernel test robot

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=87frpv21gy.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=frederic@kernel.org \
    --cc=goldside000@outlook.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox