Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1642704ybv; Sun, 23 Feb 2020 11:30:12 -0800 (PST) X-Google-Smtp-Source: APXvYqy9qZqnt52QnFIkuYrDzgGAxpeE7FeU0wwe1qSKZs7XBs5DXgssUYQVYoApYOs/ybD9Syj1 X-Received: by 2002:a05:6830:95:: with SMTP id a21mr37606137oto.171.1582486211929; Sun, 23 Feb 2020 11:30:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582486211; cv=none; d=google.com; s=arc-20160816; b=Hr5Kuti1tpIUwTHy/h8fw8ne3zSJgpZW6B0frdB27rGUpFDD4A/HtxFdR5h6FRxjSN Nu5f9vIWYmQD+AY3ddbUjbyK9A0wlleMIzdcodbx3iG291wxbOzbjcwpKBHQD5O0LXDf EtfRMZ+FUtE83VBb00pnMvf3LuLBN3D4uPvdiulYeyV5C0bICJ7//NlbleVJ4vqpWD7P tmEajti8PjUB59DJPJpbb74vmHcGGia44gM4fmQk8nZ2EpbjOm90X7qDqKoxRkX1+MIa h0FkPK5xys97i3UU3wNYhhRBqYXCJL20JKIbrXI2nFXTlscN24rMZYjIkt+RKIYvtREX 4DTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=9fbMqKThP6TvUB+L/CJhSSt2UCOmkev1PcikP4YnN+c=; b=r6j9QLtwhkOVF6U0kJn2676bx5vbidFwiKcsacMOZWY2I9OM4SJ7YEq5DE8gGw1A/P ryR3tVta2QrxFsFXRGVEodAqmRQ8qegRWoGkJoHhc4B2JErXK99ahb/rxpw51DwfxNGz UejcITGTmJsw1b7hzjH+sYuVitrvit+otCpz80XBKI9spOFgUw0Ml5J4sF5dzczqvNMg SVTyLvRu/bcFjnwftDCyntjapTbv1GAV22MfNp6LsULLoZqmzm31pRKC2LtKAft4p3+U /UGb+/aykcSmeyTOMLT5ZfVaEN66RbuI+kvLjfhRlMw8DmviUMw6I5VK0KVq9v6thfA+ Zm3Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si4094245oih.187.2020.02.23.11.29.59; Sun, 23 Feb 2020 11:30:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgBWT3y (ORCPT + 99 others); Sun, 23 Feb 2020 14:29:54 -0500 Received: from foss.arm.com ([217.140.110.172]:51252 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgBWT3y (ORCPT ); Sun, 23 Feb 2020 14:29:54 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3D692101E; Sun, 23 Feb 2020 11:29:54 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 437293F6CF; Sun, 23 Feb 2020 11:29:52 -0800 (PST) From: Qais Yousef To: Thomas Gleixner Cc: "Paul E . McKenney" , Qais Yousef , Helge Deller , Michael Ellerman , "David S. Miller" , Juergen Gross , Mark Rutland , Lorenzo Pieralisi , xen-devel@lists.xenproject.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/15] cpu: Add new {add,remove}_cpu() functions Date: Sun, 23 Feb 2020 19:29:28 +0000 Message-Id: <20200223192942.18420-2-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223192942.18420-1-qais.yousef@arm.com> References: <20200223192942.18420-1-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new functions use device_{online,offline}() which are userspace safe. This is in preparation to move cpu_{up, down} kernel users to use a safer interface that is not racy with userspace. Suggested-by: "Paul E. McKenney" Signed-off-by: Qais Yousef CC: Thomas Gleixner CC: "Paul E. McKenney" CC: Helge Deller CC: Michael Ellerman CC: "David S. Miller" CC: Juergen Gross CC: Mark Rutland CC: Lorenzo Pieralisi CC: xen-devel@lists.xenproject.org CC: linux-parisc@vger.kernel.org CC: sparclinux@vger.kernel.org CC: linuxppc-dev@lists.ozlabs.org CC: linux-arm-kernel@lists.infradead.org CC: x86@kernel.org CC: linux-kernel@vger.kernel.org --- include/linux/cpu.h | 2 ++ kernel/cpu.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 1ca2baf817ed..cf8cf38dca43 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -89,6 +89,7 @@ extern ssize_t arch_cpu_release(const char *, size_t); #ifdef CONFIG_SMP extern bool cpuhp_tasks_frozen; int cpu_up(unsigned int cpu); +int add_cpu(unsigned int cpu); void notify_cpu_starting(unsigned int cpu); extern void cpu_maps_update_begin(void); extern void cpu_maps_update_done(void); @@ -118,6 +119,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); +int remove_cpu(unsigned int cpu); #else /* CONFIG_HOTPLUG_CPU */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 9c706af713fb..069802f7010f 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1057,6 +1057,18 @@ int cpu_down(unsigned int cpu) } EXPORT_SYMBOL(cpu_down); +int remove_cpu(unsigned int cpu) +{ + int ret; + + lock_device_hotplug(); + ret = device_offline(get_cpu_device(cpu)); + unlock_device_hotplug(); + + return ret; +} +EXPORT_SYMBOL_GPL(remove_cpu); + #else #define takedown_cpu NULL #endif /*CONFIG_HOTPLUG_CPU*/ @@ -1209,6 +1221,18 @@ int cpu_up(unsigned int cpu) } EXPORT_SYMBOL_GPL(cpu_up); +int add_cpu(unsigned int cpu) +{ + int ret; + + lock_device_hotplug(); + ret = device_online(get_cpu_device(cpu)); + unlock_device_hotplug(); + + return ret; +} +EXPORT_SYMBOL_GPL(add_cpu); + #ifdef CONFIG_PM_SLEEP_SMP static cpumask_var_t frozen_cpus; -- 2.17.1