mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valentin Schneider <valentin.schneider@arm.com>
To: 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: Sun, 15 Sep 2019 15:33:29 +0100	[thread overview]
Message-ID: <5dfd4844-6c36-3b8d-203b-564d7ad7103d@arm.com> (raw)
In-Reply-To: <1568535662-14956-1-git-send-email-shikemeng@huawei.com>

On 15/09/2019 09:21, shikemeng wrote:
>> It's more thoughtful to add check in cpumask_test_cpu.It can solve this problem and can prevent other potential bugs.I will test it and resend
>> a new patch.
>>
> 
> Think again and again. As cpumask_check will fire a warning if cpu >= nr_cpu_ids, it seems that cpumask_check only expects cpu < nr_cpu_ids and it's
> caller's responsibility to very cpu is in valid range. Interfaces like cpumask_test_and_set_cpu, cpumask_test_and_clear_cpu and so on are not checking
> cpu < nr_cpu_ids either and may cause demage if cpu is out of range.
> 

cpumask operations clearly should never be fed CPU numbers > nr_cpu_ids,
but we can get some sneaky mishaps like the one you're fixing. The answer
might just be to have more folks turn on DEBUG_PER_CPU_MAPS in their test
runs (I don't for instance - will do from now on), since I get the feeling
people like to be able to disable these checks for producty kernels.

In any case, don't feel like you have to fix this globally - your fix is
fine on its own.

  reply	other threads:[~2019-09-15 14:33 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 [this message]
2019-09-23 15:43       ` Dietmar Eggemann
2019-09-23 16:06         ` Valentin Schneider
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=5dfd4844-6c36-3b8d-203b-564d7ad7103d@arm.com \
    --to=valentin.schneider@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®