mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org, Sam Sun <samsun1006219@gmail.com>,
	xingwei lee <xrivendell7@gmail.com>,
	syzkaller-bugs@googlegroups.com,
	Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] workqueue: Fix divide error in wq_update_node_max_active()
Date: Tue, 23 Apr 2024 06:10:37 -1000	[thread overview]
Message-ID: <ZifdfQ_vjqGqNdPk@slm.duckdns.org> (raw)
In-Reply-To: <20240423124548.1253842-1-jiangshanlai@gmail.com>

Hello, Lai.

On Tue, Apr 23, 2024 at 08:45:48PM +0800, Lai Jiangshan wrote:
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 0066c8f6c154..b31cd7faeb9f 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -1591,7 +1591,7 @@ static void wq_update_node_max_active(struct workqueue_struct *wq, int off_cpu)
>  		off_cpu = -1;
>  
>  	total_cpus = cpumask_weight_and(effective, cpu_online_mask);
> -	if (off_cpu >= 0)
> +	if (off_cpu >= 0 && total_cpus > 1)
>  		total_cpus--;

Can we do this explicitly instead? ie. test total_cpus before using it as
divisor and use max_active explicitly if it's zero.

Thanks.

-- 
tejun

  reply	other threads:[~2024-04-23 16:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 10:10 [Linux kernel bug] divide error in wq_update_node_max_active Sam Sun
2024-04-23 12:45 ` [PATCH] workqueue: Fix divide error in wq_update_node_max_active() Lai Jiangshan
2024-04-23 16:10   ` Tejun Heo [this message]
2024-04-24 13:51 ` [PATCH V2] " Lai Jiangshan
2024-04-24 17:33   ` Tejun Heo

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=ZifdfQ_vjqGqNdPk@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samsun1006219@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xrivendell7@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®