Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3901507ybl; Tue, 21 Jan 2020 09:06:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxUABiVp6BUowMpq+45gSDOa8U/+izsTu/3kGb52qd0D4Ox8Amzu/YQ93MkE/81JcxCJC4i X-Received: by 2002:a9d:7090:: with SMTP id l16mr4425139otj.187.1579626403922; Tue, 21 Jan 2020 09:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579626403; cv=none; d=google.com; s=arc-20160816; b=FVd6bKKrx6B75niz6hh4AXFMH3wl2XfC8urRn8bZsIv8uMNEfuRiATk+rCSsHISxwQ dHnO8KUTppwgVv31fOV/EBgZGAwUP5tPiTo5BtnpV2QNe1WPaOMMGVSfKQ410WAjCTEH Fkl8ge/8Tx5PeqguhDpUP7KrDoMsYhH6Aj3n7imdMU+ElmLmZQZutIoDl/hpyt/fj9s3 4RFd34yCfr8ntm+1efHmu4q9vx12HgJFa0JdENj+4S8dQX1HBMURnA1u3Sh68TgPIP5n koX/czCOCUZKRvYQtMPHynEExTg0SjLAGMnnsnl5KeoHYRpsmDaF0MtprOm8KETmXb0Q xl7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4w5j2rjvzCBD7QP4k4t3Wl1ksmz9OpCbbWqDD9X7AkI=; b=qD7p97mJDvA+fkpf6jHz+1UtgTns5kIR4dGmEUNDul21oTcGl7kiKfQhr6q2YbiDPl sOdgmGw/i7xKHoeC+7QBJdQ18NaFjjV5a67gdcvbvIxR/Kw5ZUffPrGOd8jQ8xD0xXNn j+R5Fu/2FCSld8fBGKbFRHDGoLJW5fJt7aEbLiMD9yLWrmCuz4dtCWD/c0GnwygOgZJb XWMOueF79P8flbHD0BidW6hcLK+l5ai6gvu4sy4BGegNuH5KBQaGNrgGNud8WHuXAjIR l6j8FVw4CakHs1kKt+qrYx1FQpeHkNn3ITje1SS0YPbeEOnsqymB85T0j4T151qhbsfO OxrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=zxhkliAt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si21371662oth.15.2020.01.21.09.06.26; Tue, 21 Jan 2020 09:06:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=zxhkliAt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729159AbgAUREu (ORCPT + 99 others); Tue, 21 Jan 2020 12:04:50 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:54232 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbgAUREt (ORCPT ); Tue, 21 Jan 2020 12:04:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4w5j2rjvzCBD7QP4k4t3Wl1ksmz9OpCbbWqDD9X7AkI=; b=zxhkliAtxRtYVF3GY5sKaRMGD qU0uMjAz7S8MJ6YeX85an8ipGfQt/WswXErZHKHH1L0HmTNbYodIRx78KUIuLuRO9E/kuBmGVCVrL ohOMmLlCbfSRgCDyKZ6R2m/dkj/W+oqFmS9+e1Ik5qqJs0oI3brlY70Qwv48TioYUmM7MPUd/g+Bo qWfGyZ026BWQnmhJv85aEqnNY/jXDin3D1U0yYnDmXxvAUwvmjiripA3NCtSYGnBguPR6QA6U271P SyB7LlND2mzj3pixI6qRNa6z7jHFyJB4po2i9pIwbWtO2R4VKsCAKDpTIykWo0DG9vTA1IBJHEv+K o1FWYIv8A==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:37250) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1itwwV-00061k-7C; Tue, 21 Jan 2020 17:03:55 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1itwwQ-0003zI-Oi; Tue, 21 Jan 2020 17:03:50 +0000 Date: Tue, 21 Jan 2020 17:03:50 +0000 From: Russell King - ARM Linux admin To: Qais Yousef Cc: Thomas Gleixner , Greg Kroah-Hartman , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Jiri Kosina , Nicholas Piggin , Daniel Lezcano , Ingo Molnar , Eiichi Tsukata , Zhenzhong Duan , Nadav Amit , "Rafael J. Wysocki" , Tony Luck , Fenghua Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/14] smp: Create a new function to shutdown nonboot cpus Message-ID: <20200121170350.GC18808@shell.armlinux.org.uk> References: <20191125112754.25223-1-qais.yousef@arm.com> <20191125112754.25223-2-qais.yousef@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191125112754.25223-2-qais.yousef@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 25, 2019 at 11:27:41AM +0000, Qais Yousef wrote: > This function will be used later in machine_shutdown() for some archs. > > Signed-off-by: Qais Yousef > CC: Thomas Gleixner > CC: Josh Poimboeuf > CC: "Peter Zijlstra (Intel)" > CC: Jiri Kosina > CC: Nicholas Piggin > CC: Daniel Lezcano > CC: Ingo Molnar > CC: Eiichi Tsukata > CC: Zhenzhong Duan > CC: Nadav Amit > CC: Greg Kroah-Hartman > CC: "Rafael J. Wysocki" > CC: Tony Luck > CC: Fenghua Yu > CC: Russell King > CC: Catalin Marinas > CC: Will Deacon > CC: linux-arm-kernel@lists.infradead.org > CC: linux-ia64@vger.kernel.org > CC: linux-kernel@vger.kernel.org > --- > include/linux/cpu.h | 2 ++ > kernel/cpu.c | 17 +++++++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/include/linux/cpu.h b/include/linux/cpu.h > index bc6c879bd110..8229932fb053 100644 > --- a/include/linux/cpu.h > +++ b/include/linux/cpu.h > @@ -118,6 +118,7 @@ extern void cpu_hotplug_disable(void); > extern void cpu_hotplug_enable(void); > void clear_tasks_mm_cpumask(int cpu); > int cpu_down(unsigned int cpu); > +extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu); > > #else /* CONFIG_HOTPLUG_CPU */ > > @@ -129,6 +130,7 @@ static inline int cpus_read_trylock(void) { return true; } > static inline void lockdep_assert_cpus_held(void) { } > static inline void cpu_hotplug_disable(void) { } > static inline void cpu_hotplug_enable(void) { } > +static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { } > #endif /* !CONFIG_HOTPLUG_CPU */ > > /* Wrappers which go away once all code is converted */ > diff --git a/kernel/cpu.c b/kernel/cpu.c > index e2cad3ee2ead..94055a0d989e 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -1058,6 +1058,23 @@ int cpu_down(unsigned int cpu) > } > EXPORT_SYMBOL(cpu_down); > > +void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) > +{ > + unsigned int cpu; > + > + if (!cpu_online(primary_cpu)) { > + pr_info("Attempting to shutdodwn nonboot cpus while boot cpu is offline!\n"); > + cpu_online(primary_cpu); > + } > + > + for_each_present_cpu(cpu) { > + if (cpu == primary_cpu) > + continue; > + if (cpu_online(cpu)) > + cpu_down(cpu); > + } How does this avoid racing with userspace attempting to restart CPUs that have already been taken down by this function? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up