Return-Path: Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w3VDw4ztDzDq7g for ; Thu, 13 Apr 2017 15:47:44 +1000 (AEST) From: Michael Ellerman To: Thomas Gleixner , LKML Cc: Peter Zijlstra , Ingo Molnar , Sebastian Siewior , Benjamin Herrenschmidt , "David S. Miller" , Fenghua Yu , Herbert Xu , Lai Jiangshan , Len Brown , "Rafael J. Wysocki" , Tejun Heo , Tony Luck , Viresh Kumar , Paul Mackerras , linuxppc-dev@lists.ozlabs.org Subject: Re: [patch 05/13] powerpc/smp: Replace open coded task affinity logic In-Reply-To: <20170412201042.518053336@linutronix.de> References: <20170412200726.941336635@linutronix.de> <20170412201042.518053336@linutronix.de> Date: Thu, 13 Apr 2017 15:47:44 +1000 Message-ID: <87fuhcamf3.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Thomas Gleixner writes: > Init task invokes smp_ops->setup_cpu() from smp_cpus_done(). Init task can > run on any online CPU at this point, but the setup_cpu() callback requires > to be invoked on the boot CPU. This is achieved by temporarily setting the > affinity of the calling user space thread to the requested CPU and reset it > to the original affinity afterwards. > > That's racy vs. CPU hotplug and concurrent affinity settings for that > thread resulting in code executing on the wrong CPU and overwriting the > new affinity setting. > > That's actually not a problem in this context as neither CPU hotplug nor > affinity settings can happen, but the access to task_struct::cpus_allowed > is about to restricted. > > Replace it with a call to work_on_cpu_safe() which achieves the same result. > > Signed-off-by: Thomas Gleixner > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: linuxppc-dev@lists.ozlabs.org > --- > arch/powerpc/kernel/smp.c | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) LGTM. Acked-by: Michael Ellerman (powerpc) cheers