From: Waiman Long <longman@redhat.com>
To: Daniel Jordan <daniel.m.jordan@oracle.com>,
Herbert Xu <herbert@gondor.apana.org.au>
Cc: steffen.klassert@secunet.com, akpm@linux-foundation.org,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] padata: Fix possible divide-by-0 panic in padata_mt_helper()
Date: Mon, 19 Aug 2024 20:07:45 -0400 [thread overview]
Message-ID: <0d8c956b-9397-4268-830b-2abe19ec3066@redhat.com> (raw)
In-Reply-To: <dgtppozpgkm2gtv7nnvranbkjudr7bwuvfe7hjbznipozcxyzd@3qcag7izn4fj>
On 8/19/24 18:29, Daniel Jordan wrote:
> On Sat, Aug 17, 2024 at 03:12:37PM GMT, Herbert Xu wrote:
>> On Mon, Aug 12, 2024 at 10:04:07AM -0400, Waiman Long wrote:
>>> Anyway, using DIV_ROUND_UP() is a slight change in behavior as chunk_size
>>> will be increased by 1 in most cases. I am a bit hesitant to make this
>>> change without looking into more detail about the rationale behind the
>>> current code.
>> I don't think it matters much. Just look at the two lines after
>> the division, they're both rounding the value up. So clearly this
>> is expected to handle the case where work gets bunched up into the
>> first N CPUs, potentially leaving some CPUs unused.
> Yeah, the caller is supposed to use min_chunk as a hint for what a
> reasonable amount of work is per thread and so avoid wasteful amounts of
> threads.
>
>> But Daniel wrote the code so he can have the last say of whether
>> we should round up after the division or after the other two ops.
> I think either way works fine with the three existing users and how they
> choose job->min_chunk and job->size.
>
> The DIV_ROUND_UP approach reads a bit nicer to me, but I can imagine
> oddball cases where rounding up is undesirable (say, near-zero values
> for size, min_chunk, and align; padata_work_alloc_mt returns many fewer
> works than requested; and a single unit of work is very expensive) so
> that rounding up makes a bigger difference. So, the way it now is seems
> ok.
>
>
> By the way, this bug must've happened coming from
> hugetlb_pages_alloc_boot(), right, Waiman? Because the other padata
> users have hardcoded min_chunk. I guess it was a case of
>
> h->max_huge_pages < num_node_state(N_MEMORY) * 2
>
Yes, I guess the hugetlbfs caller is the cause of this div-by-0 problem.
This is likely a bug that needs to be fixed. The current patch does
guarantee that padata won't crash like that even with rogue caller.
Cheers,
Longman
next prev parent reply other threads:[~2024-08-20 0:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 17:46 [PATCH] padata: Fix possible divide-by-0 panic in padata_mt_helper() Waiman Long
2024-08-10 4:05 ` Herbert Xu
2024-08-11 1:30 ` Waiman Long
2024-08-11 1:45 ` Herbert Xu
2024-08-11 3:11 ` Waiman Long
2024-08-11 3:13 ` Herbert Xu
2024-08-11 3:27 ` Waiman Long
2024-08-11 3:41 ` Herbert Xu
[not found] ` <c5cc5ea9-1135-4ac6-a38f-652ed07dae17@redhat.com>
2024-08-17 7:12 ` Herbert Xu
2024-08-19 22:29 ` Daniel Jordan
2024-08-20 0:07 ` Waiman Long [this message]
2024-08-20 4:06 ` Herbert Xu
2024-08-20 21:24 ` Daniel Jordan
2024-08-21 8:10 ` [EXTERNAL] " Kamlesh Gurudasani
2024-08-21 21:10 ` Kamlesh Gurudasani
2024-08-23 0:45 ` Daniel Jordan
2024-08-10 17:44 ` Kamlesh Gurudasani
2024-08-11 3:33 ` Waiman Long
2024-08-11 5:44 ` Kamlesh Gurudasani
2024-08-13 18:28 ` Waiman Long
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=0d8c956b-9397-4268-830b-2abe19ec3066@redhat.com \
--to=longman@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=daniel.m.jordan@oracle.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steffen.klassert@secunet.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 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.