From: "tip-bot2 for Vincent Donnefort" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Jing-Ting Wu" <jing-ting.wu@mediatek.com>,
Vincent Donnefort <vincent.donnefort@arm.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Valentin Schneider <valentin.schneider@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/urgent] sched/core: Mitigate race cpus_share_cache()/update_top_cache_domain()
Date: Thu, 11 Nov 2021 12:22:28 -0000 [thread overview]
Message-ID: <163663334891.414.10793572232732655162.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20211104175120.857087-1-vincent.donnefort@arm.com>
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: 42dc938a590c96eeb429e1830123fef2366d9c80
Gitweb: https://git.kernel.org/tip/42dc938a590c96eeb429e1830123fef2366d9c80
Author: Vincent Donnefort <vincent.donnefort@arm.com>
AuthorDate: Thu, 04 Nov 2021 17:51:20
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 11 Nov 2021 13:09:32 +01:00
sched/core: Mitigate race cpus_share_cache()/update_top_cache_domain()
Nothing protects the access to the per_cpu variable sd_llc_id. When testing
the same CPU (i.e. this_cpu == that_cpu), a race condition exists with
update_top_cache_domain(). One scenario being:
CPU1 CPU2
==================================================================
per_cpu(sd_llc_id, CPUX) => 0
partition_sched_domains_locked()
detach_destroy_domains()
cpus_share_cache(CPUX, CPUX) update_top_cache_domain(CPUX)
per_cpu(sd_llc_id, CPUX) => 0
per_cpu(sd_llc_id, CPUX) = CPUX
per_cpu(sd_llc_id, CPUX) => CPUX
return false
ttwu_queue_cond() wouldn't catch smp_processor_id() == cpu and the result
is a warning triggered from ttwu_queue_wakelist().
Avoid a such race in cpus_share_cache() by always returning true when
this_cpu == that_cpu.
Fixes: 518cd6234178 ("sched: Only queue remote wakeups when crossing cache boundaries")
Reported-by: Jing-Ting Wu <jing-ting.wu@mediatek.com>
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20211104175120.857087-1-vincent.donnefort@arm.com
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 523fd60..cec173a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3726,6 +3726,9 @@ out:
bool cpus_share_cache(int this_cpu, int that_cpu)
{
+ if (this_cpu == that_cpu)
+ return true;
+
return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
}
next prev parent reply other threads:[~2021-11-11 12:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 17:51 [PATCH] " Vincent Donnefort
2021-11-05 15:08 ` Vincent Guittot
2021-11-08 11:19 ` Peter Zijlstra
2021-11-11 12:22 ` tip-bot2 for Vincent Donnefort [this message]
2021-11-15 10:46 ` Shinichiro Kawasaki
2021-11-15 18:33 ` Valentin Schneider
2021-11-16 8:02 ` Vincent Guittot
2021-11-16 8:45 ` Shinichiro Kawasaki
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=163663334891.414.10793572232732655162.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=jing-ting.wu@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=valentin.schneider@arm.com \
--cc=vincent.donnefort@arm.com \
--cc=vincent.guittot@linaro.org \
--cc=x86@kernel.org \
/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®