From nobody Mon Feb 9 09:09:56 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 6D8EB18638 for ; Wed, 31 Jul 2024 03:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722394982; cv=none; b=FwjAW8zwWd0D2zvoZEJIE9vaMcQhyuUzmKSvqBQZx7oEhXpS1GFEpPYnh/WXI/ZxZhlF1osfQ0adO6XKApDoK8whatYmxRo4LSUrcPoSD5xvtC6/DPQhQuCoXcEwKCGBdgk6mGsg2Dm360+6Nf2HD0sltKZUud8K/D/JpahcI6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722394982; c=relaxed/simple; bh=5JSXHJAUu46lj6snCC04DzSX38aU2k16Nzif4AapOqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P9rdBjsj9n5AT5DfzLK4OuX8+3nOKDumOrtiExpEhgcgTZ2irNH/pm0W0JmPY8O0yvFx6o8Xvxu/HTOSwaKfY5w4tChMGxqU6ltvliGtgEWjD0TnX2EzZlffIay2XIsYSmqlBFHoHgb8Z1r2b4EZxMEdtostrd8M7FMO5vGSyfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=JuL0nWb3; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="JuL0nWb3" Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V2xnIa008747; Wed, 31 Jul 2024 03:02:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=vW5lsyIFWSZkq 9+WtC/JLBFyEtR2dLFJCqUMsgFyCqs=; b=JuL0nWb3qfVTsoJ38UVaATPGNvF0H 85aFLB6cHMpd/Lwl66YIQ5fju+XuS1EMG/s405b/2mllmw6k0ODyUNutfKlYxj7y 6/qUSZP8P6DOc6ZdKOjBsT/WAkGXZIyYpLoSQK6elkxXCh9EShdR9LWx3HVqktuw LLdf2d9hGejGMQNG2kbV4IOINig7PW5p/hpyCQ+A/5lc7zEu1GH+uyvd5nUAfr00 qvdRaisNdhVpkDPH6iFZ/MvUNC6EwprYALlyMI66JULPPwBOapwlUjfBVH+JCqwN 258Zk+iG/1LsLMCataySujItXYBVWJDe5owxR0+NweW5GyAo4Xe9oMCFA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40qcy180e3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 03:02:40 +0000 (GMT) Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46V32deg013582; Wed, 31 Jul 2024 03:02:39 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40qcy180e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 03:02:39 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46UNnJsO009211; Wed, 31 Jul 2024 03:02:38 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 40ndx30kpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 03:02:38 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46V32XLB57344362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jul 2024 03:02:35 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F146C20040; Wed, 31 Jul 2024 03:02:32 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 175372004E; Wed, 31 Jul 2024 03:02:27 +0000 (GMT) Received: from li-80eaad4c-2afd-11b2-a85c-af8123d033e3.ibm.com.com (unknown [9.43.68.49]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jul 2024 03:02:26 +0000 (GMT) From: "Nysal Jan K.A." To: Michael Ellerman , Thomas Gleixner Cc: Tyrel Datwyler , Michal Suchanek , "Nysal Jan K.A" , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Peter Zijlstra , Andrew Morton , Ard Biesheuvel , Stephen Rothwell , Eric DeVolder , Pawan Gupta , Laurent Dufour , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 2/2] powerpc/topology: Check if a core is online Date: Wed, 31 Jul 2024 08:31:13 +0530 Message-ID: <20240731030126.956210-3-nysal@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731030126.956210-1-nysal@linux.ibm.com> References: <20240731030126.956210-1-nysal@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Xvqq_yAgqupzlMV1tTs1McA_6OFRaHzD X-Proofpoint-ORIG-GUID: sdX2CuWGvOx2jdehsGJ6JxRRU7oJB6td X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-30_21,2024-07-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1011 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407310019 Content-Type: text/plain; charset="utf-8" From: "Nysal Jan K.A" topology_is_core_online() checks if the core a CPU belongs to is online. The core is online if at least one of the sibling CPUs is online. The first CPU of an online core is also online in the common case, so this should be fairly quick. Signed-off-by: Nysal Jan K.A Reviewed-by: Shrikanth Hegde --- arch/powerpc/include/asm/topology.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm= /topology.h index f4e6f2dd04b7..16bacfe8c7a2 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h @@ -145,6 +145,7 @@ static inline int cpu_to_coregroup_id(int cpu) =20 #ifdef CONFIG_HOTPLUG_SMT #include +#include #include =20 static inline bool topology_is_primary_thread(unsigned int cpu) @@ -156,6 +157,18 @@ static inline bool topology_smt_thread_allowed(unsigne= d int cpu) { return cpu_thread_in_core(cpu) < cpu_smt_num_threads; } + +#define topology_is_core_online topology_is_core_online +static inline bool topology_is_core_online(unsigned int cpu) +{ + int i, first_cpu =3D cpu_first_thread_sibling(cpu); + + for (i =3D first_cpu; i < first_cpu + threads_per_core; ++i) { + if (cpu_online(i)) + return true; + } + return false; +} #endif =20 #endif /* __KERNEL__ */ --=20 2.35.3