From nobody Tue Feb 10 03:39:57 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1582486258; cv=none; d=zohomail.com; s=zohoarc; b=eU/P6QObNCyq245mICKQzEVenFdLJ7x6A6X6dzbZnFhEIl0w7anerkx9Ku0QLduW5jGOggWmTeHdJTNpDuo/TleTJVOzrVkBmN7T06XE0a/KJJeqoWWmmxpYI6CSYCMkUiwBV5n1078mB5FD8IVFIP+msHII/MVMx8KZDsEgpcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582486258; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9gJM7LbJs/Q7N/pA5c079JPyd8ClVQqCPxkWHxvpCE4=; b=a8Fxn9jmHFYgNTHZE253hL1Ut8HYQpTddK4NmoMDwO/uyEimkiSjbtj2+J2Dghd9uZwDJxaQ/k5GHKnDlKyyRFN2dIrZGYIqE6pVdeX8mwvYGk2Up1ITnu+iTgtUXsGSkzka0QsqbnSLQgxqOZIA8ZrwYxe2efj0PSp2ZN2igMA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1582486257981959.4781431508433; Sun, 23 Feb 2020 11:30:57 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j5wwy-0003cn-K6; Sun, 23 Feb 2020 19:30:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j5wwx-0003bA-R7 for xen-devel@lists.xenproject.org; Sun, 23 Feb 2020 19:29:59 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id de5c013c-5672-11ea-b0fd-bc764e2007e4; Sun, 23 Feb 2020 19:29:54 +0000 (UTC) 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) X-Inumbo-ID: de5c013c-5672-11ea-b0fd-bc764e2007e4 From: Qais Yousef To: Thomas Gleixner 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> Subject: [Xen-devel] [PATCH v3 01/15] cpu: Add new {add, remove}_cpu() functions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Mark Rutland , Lorenzo Pieralisi , linux-parisc@vger.kernel.org, "Paul E . McKenney" , Michael Ellerman , Helge Deller , x86@kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org, linuxppc-dev@lists.ozlabs.org, Qais Yousef , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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); =20 #else /* CONFIG_HOTPLUG_CPU */ =20 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); =20 +int remove_cpu(unsigned int cpu) +{ + int ret; + + lock_device_hotplug(); + ret =3D 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); =20 +int add_cpu(unsigned int cpu) +{ + int ret; + + lock_device_hotplug(); + ret =3D 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; =20 --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel