Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp545849ybb; Wed, 25 Mar 2020 05:07:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuM7xlGYqNOWbB3q/WQaMd3p2lm/DI7sad9QVAqCHuesgXQ6gpxcca+NruvSGEfWZ3I5oUm X-Received: by 2002:aca:b308:: with SMTP id c8mr2252849oif.131.1585138054140; Wed, 25 Mar 2020 05:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585138054; cv=none; d=google.com; s=arc-20160816; b=jYDUnEUpwdWkx70SjpeEkr4KWqo601IJC5rL5N6H01avAoWB0luqQusAO9ZbLLNtqc jqvqCIwgPFGbCfmY6DZzk6pulSFq/XHFy7/RP2RT9A2RsdnuqdVQXcYZctZVm/xMOByy tAusHK+KqvX4rPVAYmWqZrhMF3Z0wZAw7ZsaMRl0tbK5dUB+UK5uZMhen4Tj5AimaicQ bDu19ZhqNNmpmJX15rTB/B54U2nqRIqjs+w8+xCb9qHiNyRmR0NxYuSWfMpFtiw3hzk5 CkdRpBbFTMtgXD0wyrktNbQvRolSDlmlaFYZ6Hje2ooaHfWsS7fbI/F+FCVCBoqAC5j9 fLLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=IU8S3inQ3lOcutWiHdBNqkAv7ok0meIM09V6bC6r99M=; b=eqUxv2osGK9/p4P2GhuvP/m/D+Jr+LmnccQbKlgQd8aw6LTbvvh9+EeFI6kyJbN9Ii pA+s0Qe/cCc0oB1gh3fKvI1iAhWOrpESTxVJTRpxnu3FzVOkUlVBD4i2nqv6vNln+dG8 Wn6BxB9+Xx1XiDdFoHln3Z7ZyYaGbXvWX8xnAJck+qLSmscaDv0feFP9C3mdH/bmazq3 Adg7JKO57RV5tyGYtioCckrfHXfOdkI0JZYIpwcKOric0HOei5JkrZGHVqsCwk16sriE BjWYdkTJgkQGs7PgJQL+WLj99bfyfEmwHkILCnbatFkRvuMukRWPJavqTJHFz8ISeSN8 Evvg== 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 v128si381418oig.68.2020.03.25.05.07.18; Wed, 25 Mar 2020 05:07:34 -0700 (PDT) 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 S1727708AbgCYMGe (ORCPT + 99 others); Wed, 25 Mar 2020 08:06:34 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47773 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727579AbgCYMGP (ORCPT ); Wed, 25 Mar 2020 08:06:15 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jH4nS-0000n7-JN; Wed, 25 Mar 2020 13:06:10 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id D6DFC1C0494; Wed, 25 Mar 2020 13:06:07 +0100 (CET) Date: Wed, 25 Mar 2020 12:06:07 -0000 From: "tip-bot2 for Qais Yousef" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Add new {add,remove}_cpu() functions Cc: "Paul E. McKenney" , Qais Yousef , Thomas Gleixner , x86 , LKML In-Reply-To: <20200323135110.30522-2-qais.yousef@arm.com> References: <20200323135110.30522-2-qais.yousef@arm.com> MIME-Version: 1.0 Message-ID: <158513796741.28353.9870731979863465160.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: 93ef1429e556f739a208e3968883ed51480580e8 Gitweb: https://git.kernel.org/tip/93ef1429e556f739a208e3968883ed51480580e8 Author: Qais Yousef AuthorDate: Mon, 23 Mar 2020 13:50:54 Committer: Thomas Gleixner CommitterDate: Wed, 25 Mar 2020 12:59:31 +01:00 cpu/hotplug: Add new {add,remove}_cpu() functions 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 Signed-off-by: Thomas Gleixner Reviewed-by: Paul E. McKenney Link: https://lkml.kernel.org/r/20200323135110.30522-2-qais.yousef@arm.com --- 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 1ca2baf..cf8cf38 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 9c706af..069802f 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;