On 2019-12-09 18:40:37 [-0600], Scott Wood wrote: > Actually it looks like we're saved from the false positives by the > following check for nr_cpus_allowed == 1, which should always be true on > UP. we currently don't. > If we want this check to be effective on UP we'd need some way to keep > track of whether a thread is forced by the kernel to be bound to one CPU, > rather than whether it just happens to have only one CPU in the mask. > Barring that, we should just stub out check_preemption_disabled() as a > whole on UP. > > > I didn't realize that smp_processor_id.c is only build with > > CONFIG_DEBUG_PREEMPT. It should be enough to add > > > > #if defined(CONFIG_SCHED_DEBUG) > > > > Did I get it finally correct? :) > > No, then we *would* get those false positives on SMP without > CONFIG_SCHED_DEBUG, and it wouldn't build without CONFIG_PREEMPT_RT_BASE. this should be enough -> From: Daniel Wagner <dwagner@xxxxxxx> Date: Mon, 16 Dec 2019 16:15:57 +0100 Subject: [PATCH] lib/smp_processor_id: Adjust check_preemption_disabled() The current->migrate_disable counter is not always defined leading to build failures with DEBUG_PREEMPT && !PREEMPT_RT_BASE. Restrict the access to ->migrate_disable to same set where ->migrate_disable is modified. Signed-off-by: Daniel Wagner <dwagner@xxxxxxx> [bigeasy: adjust condition + description] Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- lib/smp_processor_id.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c index 5f2618d346c42..c2f5b0f8cacd0 100644 --- a/lib/smp_processor_id.c +++ b/lib/smp_processor_id.c @@ -23,8 +23,10 @@ unsigned int check_preemption_disabled(const char *what1, const char *what2) * Kernel threads bound to a single CPU can safely use * smp_processor_id(): */ +#if defined(CONFIG_PREEMPT_RT_BASE) && (defined(CONFIG_SMP) || defined(CONFIG_SCHED_DEBUG)) if (current->migrate_disable) goto out; +#endif if (current->nr_cpus_allowed == 1) goto out; -- 2.24.0