From: Valentin Schneider <valentin.schneider@arm.com>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>,
shikemeng <shikemeng@huawei.com>,
mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: fix migration to invalid cpu in __set_cpus_allowed_ptr
Date: Mon, 23 Sep 2019 17:06:09 +0100 [thread overview]
Message-ID: <1d8e6aab-5258-494c-c4cd-1802eda34d59@arm.com> (raw)
In-Reply-To: <40680310-60b3-589a-d0e8-b4dd723db10a@arm.com>
On 23/09/2019 16:43, Dietmar Eggemann wrote:
> I'm not sure that CONFIG_DEBUG_PER_CPU_MAPS=y will help you here.
>
> __set_cpus_allowed_ptr(...)
> {
> ...
> dest_cpu = cpumask_any_and(...)
> ...
> }
>
> With:
>
> #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
> #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p),
> (src2p))
>
> cpumask_next_and() is called with n = -1 and in this case does not
> invoke cpumask_check().
>
It won't warn here because it's still a valid return value, but it should
warn in the cpumask_test_cpu() that follows (in is_cpu_allowed()) because
it would be passed a value >= nr_cpu_ids. So at the very least this config
does catch cpumask_any*() return values being blindly passed to
cpumask_test_cpu().
Calls to cpumask_any*() without relevant return value check can easily be
spotted by the coccinelle snippet I sent earlier. If this one fix gets
merged, I'll go and stare at / fixup the others (and maybe add the semantic
patch to coccicheck).
> ---
>
> BTW, I can recreate the issue quite easily with:
>
> qemu-system-x86_64 ... -smp cores=64 ... -enable-kvm
>
> with the default kernel config.
>
>
Might want to send your tested-by to [1] then :)
[1]: https://lkml.kernel.org/r/1568616808-16808-1-git-send-email-shikemeng@huawei.com
>
next prev parent reply other threads:[~2019-09-23 16:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 1:55 shikemeng
2019-09-12 22:09 ` Valentin Schneider
2019-09-15 6:13 ` shikemeng
2019-09-15 8:21 ` shikemeng
2019-09-15 14:33 ` Valentin Schneider
2019-09-23 15:43 ` Dietmar Eggemann
2019-09-23 16:06 ` Valentin Schneider [this message]
2019-09-24 14:09 ` Dietmar Eggemann
2019-09-24 16:12 ` Valentin Schneider
2019-09-15 3:07 shikemeng
2019-09-15 17:00 ` Valentin Schneider
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=1d8e6aab-5258-494c-c4cd-1802eda34d59@arm.com \
--to=valentin.schneider@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shikemeng@huawei.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®