From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756062AbdDMFrs (ORCPT ); Thu, 13 Apr 2017 01:47:48 -0400 Received: from ozlabs.org ([103.22.144.67]:45311 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751491AbdDMFrq (ORCPT ); Thu, 13 Apr 2017 01:47:46 -0400 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> User-Agent: Notmuch/0.21 (https://notmuchmail.org) 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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