lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7eb73676-7f65-4eb5-8735-559eff73e1cf@kernel.org>
Date: Tue, 22 Jul 2025 10:11:38 +0200
From: Jiri Slaby <jirislaby@...nel.org>
To: Yury Norov <yury.norov@...il.com>, Thomas Gleixner <tglx@...utronix.de>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] irq: simplify irq_im_handle_irq()

On 19. 07. 25, 23:18, Yury Norov wrote:
> From: Yury Norov (NVIDIA) <yury.norov@...il.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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ