Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp76528lqp; Sun, 9 Jun 2024 17:39:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuAd05V6yXCAJrvjQf6HbpMEBRRyvLKkg/QrDNYQOzFIEdcbU4kp+1EDmVcmS35ECYA65qZTtKOn4YvNjHIQfVfdKQw7m81ooeDOE9Qg== X-Google-Smtp-Source: AGHT+IGd++vnxuJC5ib0q0ymoT2xVNiCb91syl6T3zyLieM5tw30kUX3DYjXUzKplQORTLK2M0Kw X-Received: by 2002:a19:381d:0:b0:52c:823f:2a10 with SMTP id 2adb3069b0e04-52c823f2b09mr2783259e87.1.1717979990899; Sun, 09 Jun 2024 17:39:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717979990; cv=pass; d=google.com; s=arc-20160816; b=AQDfZp1YeWMZCwe1L8/UhErQRtMsgYP5+oGw9md76HGKGpjjMn/jxWr1KksF3XTrUq Qurha2j/Hlj24/FKwNGncIPsTV9DCyFB4IgrBZCM3+U44Uyk7nKFQxMOsiJrrjsR2maQ ZpPdADCs6qilDT6Fs5c3Vt5qB9llJzEH74mg+8pzOPrN4eAxAKuY7J8PrR1yHCwP7BKG jOu2HwcbonNlP4MBHSsnMjHgVRgqy0Hqnfoq7vhF2ilyr9NRHdl9/QLxZpSbls9iTCGR K/zKaJIzvDVnq6bOFNdRBWZ7vqogRapzR9noIT2zm6iyBFFTKRXryypG6KHACD7Dkvgr wWfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tbzDVBlC3LJHAmruRLk1mnU1rQSHBvqQIpizZu1gaRg=; fh=zrVDlrC06DAIec5BvDl2IM9WrZzuc2uxw+nPFYRCHpQ=; b=1JTBnK/10tIPNuQwkV6BUCuMM55AE/JosM1kdlb7fy9sgvlJ3ruClKeQhsBo8DoPkn xpcjdTx21otuczQ9ThYfHYDrZC8pm50mZVu4H9AKNn3GiN+Dib0OljD4hYloN8ljheX+ KMSOUS2VZE2FrvOhkKuPjuevl1epy5hA7dQPdllaehfPJv84DLKJUQdtCor0n5xtXDAE iNNH1MfKGewnYxf4mRP/TQmqDOFIY8ZqIdhClpJ9m96duJg9CVL9y+/GKoDFsOYc4FMK SHMIbQ6zuFS+Tt/NnM8ghSs0ZufQG+1PQwh/2dx3mgm7FPkRdripUuaBrJ5Jt+B7GJea 05FQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iWiVSvC3; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-207573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f01d3aac0si195330766b.879.2024.06.09.17.39.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 17:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iWiVSvC3; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-207573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 670F21F21BE8 for ; Mon, 10 Jun 2024 00:39:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BA204687; Mon, 10 Jun 2024 00:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iWiVSvC3" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFBF715CE for ; Mon, 10 Jun 2024 00:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717979978; cv=none; b=ZuhIY1LbrAUAhX51ODTNkEeoUg1NbTCPCZoADIK4WrRhMZKN9rMHefRtQuYAlharYaklITNo3cypUvkkh6hkyqloa0IJYnqoPK7MZ+3QfSicoF2JSUASpVwZ4cY7uG+R2epnyUg+p7c4AcPPGx7izJWq3qctx2Hii/ea3bwoYmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717979978; c=relaxed/simple; bh=KrgBmWQXmMI5ZHOl1JgRcgR4CFvwj+D+f1AyQNCY1ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WERo0o21nELDtUu1EYTsKCwPv/IGJ0p4ju4TBgJBEXzPgHmDbZiOs04Xx6vNOoHvdPx1MUJCdlc36MOhNPvFWBADSpXcD/x7ec6OOogz2yhesxtH411/+LPx0+gMAt4NuCGDgNlK27Gzmx3rtcCF1BTRWz6GOZNGBo1O1x0peBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iWiVSvC3; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717979977; x=1749515977; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KrgBmWQXmMI5ZHOl1JgRcgR4CFvwj+D+f1AyQNCY1ys=; b=iWiVSvC3CMWTGMRwAjtL/LqoEd8NkY6injUh9I7N8j6hD0gatf1C7/0n hSb8Jfd3JzVyL1rqsy4B0seExMTaH5gjceBa1myTCfSTU/MhEFJPxdE5X /YKW3dPAPMovU86S1NNpH8U3cLNHtAKETkujntclYwxPeeZ6iNG6OPo0s 9c8BtGb7Tw93FePv65el27Oe8+R36WuCoItCaE9haxSgpnlr4+lvyZ2ej LOmGCNS4fuzYXPua/BhSSbM8ks57DTu5b54qWUfr7+yledjKi/SjNjOEG o+3ImQbHGFvn6Qo2lXhTX2fQ7Vvne/vuJoxPvP+h96aC2RZFagzg7G/er g==; X-CSE-ConnectionGUID: QQpEXxpXR+SBMxA5/MSHKA== X-CSE-MsgGUID: YkX/8Cm8Qr2HEQ1hmD5wag== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="37154962" X-IronPort-AV: E=Sophos;i="6.08,226,1712646000"; d="scan'208";a="37154962" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 17:39:35 -0700 X-CSE-ConnectionGUID: JaP/M0FfTe+VNnklssA+cw== X-CSE-MsgGUID: BHrBrcuFTY6GWYbyn2sMVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,226,1712646000"; d="scan'208";a="38829877" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 17:39:36 -0700 From: Tony Luck To: Borislav Petkov Cc: x86@kernel.org, Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v4 1/4] cpu: Move CPU hotplug function declarations into their own header Date: Sun, 9 Jun 2024 17:39:24 -0700 Message-ID: <20240610003927.341707-2-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240610003927.341707-1-tony.luck@intel.com> References: <20240610003927.341707-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Avoid upcoming #include hell when wants to use lockdep_assert_cpus_held() and creates a #include loop that would break the build for arch/riscv. Signed-off-by: Tony Luck --- include/linux/cpu.h | 33 +-------------------------- include/linux/cpuhplock.h | 47 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 include/linux/cpuhplock.h diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 861c3bfc5f17..a8926d0a28cd 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -18,6 +18,7 @@ #include #include #include +#include #include struct device; @@ -132,38 +133,6 @@ static inline int add_cpu(unsigned int cpu) { return 0;} #endif /* CONFIG_SMP */ extern const struct bus_type cpu_subsys; -extern int lockdep_is_cpus_held(void); - -#ifdef CONFIG_HOTPLUG_CPU -extern void cpus_write_lock(void); -extern void cpus_write_unlock(void); -extern void cpus_read_lock(void); -extern void cpus_read_unlock(void); -extern int cpus_read_trylock(void); -extern void lockdep_assert_cpus_held(void); -extern void cpu_hotplug_disable(void); -extern void cpu_hotplug_enable(void); -void clear_tasks_mm_cpumask(int cpu); -int remove_cpu(unsigned int cpu); -int cpu_device_down(struct device *dev); -extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu); - -#else /* CONFIG_HOTPLUG_CPU */ - -static inline void cpus_write_lock(void) { } -static inline void cpus_write_unlock(void) { } -static inline void cpus_read_lock(void) { } -static inline void cpus_read_unlock(void) { } -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 int remove_cpu(unsigned int cpu) { return -EPERM; } -static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { } -#endif /* !CONFIG_HOTPLUG_CPU */ - -DEFINE_LOCK_GUARD_0(cpus_read_lock, cpus_read_lock(), cpus_read_unlock()) - #ifdef CONFIG_PM_SLEEP_SMP extern int freeze_secondary_cpus(int primary); extern void thaw_secondary_cpus(void); diff --git a/include/linux/cpuhplock.h b/include/linux/cpuhplock.h new file mode 100644 index 000000000000..d42d2434dab6 --- /dev/null +++ b/include/linux/cpuhplock.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * include/linux/cpuhplock.h - cpu hotplug locking + * + * Locking functions for CPU hot plug. + */ +#ifndef _LINUX_CPUHPLOCK_H_ +#define _LINUX_CPUHPLOCK_H_ + +#include +#include + +struct device; + +extern int lockdep_is_cpus_held(void); + +#ifdef CONFIG_HOTPLUG_CPU +extern void cpus_write_lock(void); +extern void cpus_write_unlock(void); +extern void cpus_read_lock(void); +extern void cpus_read_unlock(void); +extern int cpus_read_trylock(void); +extern void lockdep_assert_cpus_held(void); +extern void cpu_hotplug_disable(void); +extern void cpu_hotplug_enable(void); +void clear_tasks_mm_cpumask(int cpu); +int remove_cpu(unsigned int cpu); +int cpu_device_down(struct device *dev); +extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu); + +#else /* CONFIG_HOTPLUG_CPU */ + +static inline void cpus_write_lock(void) { } +static inline void cpus_write_unlock(void) { } +static inline void cpus_read_lock(void) { } +static inline void cpus_read_unlock(void) { } +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 int remove_cpu(unsigned int cpu) { return -EPERM; } +static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { } +#endif /* !CONFIG_HOTPLUG_CPU */ + +DEFINE_LOCK_GUARD_0(cpus_read_lock, cpus_read_lock(), cpus_read_unlock()) + +#endif /* _LINUX_CPUHPLOCK_H_ */ -- 2.45.0