[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d8e6aab-5258-494c-c4cd-1802eda34d59@arm.com>
Date: Mon, 23 Sep 2019 17:06:09 +0100
From: Valentin Schneider <valentin.schneider@....com>
To: Dietmar Eggemann <dietmar.eggemann@....com>,
shikemeng <shikemeng@...wei.com>, mingo@...hat.com,
peterz@...radead.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched: fix migration to invalid cpu in
__set_cpus_allowed_ptr
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
>
Powered by blists - more mailing lists