From: Jiri Slaby <jirislaby@kernel.org>
To: Yury Norov <yury.norov@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irq: simplify irq_im_handle_irq()
Date: Tue, 22 Jul 2025 10:11:38 +0200 [thread overview]
Message-ID: <7eb73676-7f65-4eb5-8735-559eff73e1cf@kernel.org> (raw)
In-Reply-To: <20250719211818.402115-1-yury.norov@gmail.com>
On 19. 07. 25, 23:18, Yury Norov wrote:
> From: Yury Norov (NVIDIA) <yury.norov@gmail.com>
>
> Hi Thomas,
This does not belong to a commit log ^^.
> The function calls bitmap_empty() for potentially every bit in
> work_ctx->pending, which makes a simple bitmap traverse O(N^2).
> Fix it by switching to the dedicated for_each_set_bit().
Looks good.
> While there, fix using atomic clear_bit() in a context where atomicity
> cannot be guaranteed.
What does this mean? __clear_bit() can corrupt the bitmap when there is
an in-flight set_bit(), right?
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> ---
> kernel/irq/irq_sim.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> index ae4c9cbd1b4b..e05904da7e3d 100644
> --- a/kernel/irq/irq_sim.c
> +++ b/kernel/irq/irq_sim.c
> @@ -128,15 +128,13 @@ static struct irq_chip irq_sim_irqchip = {
> static void irq_sim_handle_irq(struct irq_work *work)
> {
> struct irq_sim_work_ctx *work_ctx;
> - unsigned int offset = 0;
> + unsigned int offset;
> int irqnum;
>
> work_ctx = container_of(work, struct irq_sim_work_ctx, work);
>
> - while (!bitmap_empty(work_ctx->pending, work_ctx->irq_count)) {
> - offset = find_next_bit(work_ctx->pending,
> - work_ctx->irq_count, offset);
> - clear_bit(offset, work_ctx->pending);
> + for_each_set_bit(offset, work_ctx->pending, work_ctx->irq_count) {
> + __clear_bit(offset, work_ctx->pending);
> irqnum = irq_find_mapping(work_ctx->domain, offset);
> handle_simple_irq(irq_to_desc(irqnum));
> }
--
js
suse labs
prev parent reply other threads:[~2025-07-22 8:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-19 21:18 Yury Norov
2025-07-21 14:07 ` Thomas Gleixner
2025-07-21 14:27 ` Yury Norov
2025-07-21 15:44 ` Thomas Gleixner
2025-07-31 8:02 ` Jiri Slaby
2025-07-22 8:11 ` Jiri Slaby [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=7eb73676-7f65-4eb5-8735-559eff73e1cf@kernel.org \
--to=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=yury.norov@gmail.com \
/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
all inboxes | Powered by JetHome®