All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] softirq: Provide a handshake for canceling tasklets via polling on PREEMPT_RT
Date: Thu, 21 Aug 2025 07:10:42 -1000	[thread overview]
Message-ID: <aKdTEkK5MBz_Fj47@slm.duckdns.org> (raw)
In-Reply-To: <20250821092827.zcFpdnNy@linutronix.de>

Hello, Sebastian.

On Thu, Aug 21, 2025 at 11:28:27AM +0200, Sebastian Andrzej Siewior wrote:
...
> It is not wrong as in something will explode. The priority-inheritance
> boost is meant to give the lower priority task runtime in order to leave
> its critical section. So the task with the higher priority can continue
> to make progress instead of sitting around. Spinning while waiting for
> completion will not succeed.
> In this case "leaving the critical section" would mean complete the one
> work item. But instead we flush all of them. It is more of semantics in
> this case. That is why the looping-cancel in tasklet cancels just that
> one workitem.

Understood. However, given that these pools are per-cpu, BHs are usually not
heavily contended and canceling itself is a low frequency operation, the
practical difference likely won't be noticeable.

> > I think the main focus is keeping the
> > semantics matching on RT, right?
> 
> Yes, but having the semantics with busy waiting on a BH work is kind of
> the problem. And there is no need for it which makes it a bit difficult.
> The previous patch would match the !RT bits but we flush all work, have
> and the lock for no reason. That is why I don't like it. The majority of
> tasklet users don't need it. It is in my opinion bad semantics.
> 
> But if you insist on it, the previous patch will make it work and has
> been tested. There is not much I can do.

Oh, I'm not insisting, don't know enough to do so. Just trying to understand
the situation.

> > I'm most likely missing something about RT but wouldn't the above still lead
> > to deadlocks if the caller is non-hardirq but higher priority thread?
> 
> Not sure what you refer to. Right now there is this lock in
> local_bh_disable() which forces PI.
> Removing the whole section for RT as in this snippet gets us to the
> wait_for_completion() below. It lets the task with higher priority
> schedule out allowing task with lower priority to run. Eventually the
> barrier item completes and with the wakeup the high priority task will
> continue.
> So the high-priority task will lose runtime (allowing task with lower
> priority to run). I don't think it will be a problem because it is
> mostly used in "quit" scenarios (not during normal workload) and matches
> tasklet_disable().

Okay, so, on !RT, that busy loop section is there to allow
cancel_work_sync() to be called from BH-disabled contexts and the caller is
responsible for ensuring there's no recursion. It's not great but matches
the existing behavior. Obviously, in !RT, we can't go to
wait_for_completion() there because we can be in a non-sleepable context.

Are you saying that, in RT, it'd be fine to call wait_for_completion()
inside local_bh_disable() and won't trip any of the context warnings? If so,
yeah, we don't need any of the looping.

Thanks.

-- 
tejun

  reply	other threads:[~2025-08-21 17:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 14:39 [PATCH] softirq: Provide a handshake for canceling tasklets via polling on PREEMPT_RT Sebastian Andrzej Siewior
2025-08-12 14:53 ` Sebastian Andrzej Siewior
2025-08-12 19:38   ` Tejun Heo
2025-08-13  6:33     ` Sebastian Andrzej Siewior
2025-08-13 18:05       ` Tejun Heo
2025-08-18 12:52         ` Sebastian Andrzej Siewior
2025-08-18 17:41           ` Tejun Heo
2025-08-19 15:01             ` Sebastian Andrzej Siewior
2025-08-20 10:36               ` Sebastian Andrzej Siewior
2025-08-20 10:55                 ` Sebastian Andrzej Siewior
2025-08-20 19:44                   ` Tejun Heo
2025-08-21  9:28                     ` Sebastian Andrzej Siewior
2025-08-21 17:10                       ` Tejun Heo [this message]
2025-08-22  9:48                         ` Sebastian Andrzej Siewior
2025-08-22 18:07                           ` Tejun Heo
2025-08-26 15:49                             ` Sebastian Andrzej Siewior
2025-08-26 16:27                               ` Tejun Heo
2025-08-28 16:04                                 ` Sebastian Andrzej Siewior
2025-08-29 19:34                                   ` Tejun Heo
2025-08-13  8:20 ` 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=aKdTEkK5MBz_Fj47@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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.