From nobody Sun Feb 8 07:21:32 2026 Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (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 428D7405F8 for ; Fri, 5 Jul 2024 03:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150189; cv=none; b=HnYSLZQoehZ9nvjelrZVkGn9fsgGrrb4JFWDd4X2huLEYME/X15anGovn3mh4/p/vvNTrWGl0dvsVAYXxQIDNpz5gOIPsnC2X7a6GpZ7zWnENGwMnCBmQDvpDDcg2j3zq5PratqGHC8TR1rbYkp+vlchZ1BsP3g3NJdDxF3ni3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150189; c=relaxed/simple; bh=BRkcuXQ3cJedwbfmLvfBW1dIeZpS3I+xSxBwfNpvU48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SpxME+AeQ8m7HhTlss7p1+syYc+Xi6osvmAmhKsIdZyD+fcUZ8yCobZjifEdI+TAfqQoQf3JqXqVOc3O1BHHSfD9V/uSfVuTe33TfXNbahVRdWQVOqa7BapO7YKxHEmEiPayMAKKzsStQ7sfIbGM3RmlQll1QkguJ1MgNEok/o4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=YnjnmISl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VuZUgkzs; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="YnjnmISl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VuZUgkzs" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 77BC21380285; Thu, 4 Jul 2024 23:29:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 04 Jul 2024 23:29:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720150186; x=1720236586; bh=41JX6fqLDkWKOiBrUjt2FO4XbxsPy1jqYEouFQLlknE=; b= YnjnmISlnGwkZdblviCIlIpW85K23nuqraJ5FpuqHpgKbZHTtS2yno4R6DmXyqaj /7R7cp00uhh3cn4ZsXX+hCqqwAcLTAG6+P5Q/NXDuENbBlHGrEuv1m9/8f97ANFq ORuO5KRSucOXCF0m6fDPMHvBWiSkK2vKRVjNh+Xab1DAIHqi0HjLpVGN4P5ce6Xq N/q8E9Xk+3RDrH9RCEkNomW3Y35jyvrO+6B7egVkHIgBGVhcs3wzRtx+h7l4dkfJ LN7goc7VxYrcOYlZQPpxRmBS6Zu2L1M84xXn4RZoLyZIT1NyYwaJlKq7az30Ng9S hWAmQQNey4gn38FN7zXjeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720150186; x= 1720236586; bh=41JX6fqLDkWKOiBrUjt2FO4XbxsPy1jqYEouFQLlknE=; b=V uZUgkzs+OVT5KuiNF5Ik4trvvZ3buDPVAkyzWmGlN1m98B9Q/m+6QOt/2NI9enYr TvDQUEsrBcFmPTYUQeGxnp/MizJk3D0wnNeEpOTaYrmhsunD6ceemsDfoQDuf7en f44NUocp1N141m63XLzN+xoDwQPmK/B0ycMlBoBTfVpAPwBdDZzVag8E32fVaiq9 Thod8QCZTezFyyMXiUmkvb/qHFNB8Ovp9vkwtmBp35k9rP7hSuutXn7ZvJFKhG5b aBcZAjQR/ReuL+wv+pmKcN09F8kjf/gDztZXfwe/V6iXYMpbNKNnfrmTmxyQHzAF I+4QSWdW0ksVx0p8BnRrQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jul 2024 23:29:43 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 11:29:37 +0800 Subject: [PATCH 1/3] cpu/hotplug: Make HOTPLUG_PARALLEL independent of HOTPLUG_SMT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240705-loongarch-hotplug-v1-1-67d9c4709aa9@flygoat.com> References: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> In-Reply-To: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> To: Thomas Gleixner , Peter Zijlstra , Huacai Chen , WANG Xuerui Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1463; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=BRkcuXQ3cJedwbfmLvfBW1dIeZpS3I+xSxBwfNpvU48=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrT2jCX5mVHtJSa8tf9tjkdxrA2YVyd13oZDKCss44b1D 5EzTw52lLIwiHExyIopsoQIKPVtaLy44PqDrD8wc1iZQIYwcHEKwERCrjL8M18la9TmaasySfHl nnUXF72+fO3tJa0FK/9uMN1n8VlKcwHDP4PvP94d+xVufE3unIqu09n74Y5d63zuxtaxJj07c/D oND4A X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Use ifdef to guard reference to HOTPLUG_SMT symbols so HOTPLUG_PARALLEL can be enabled without HOTPLUG_SMT being selected. Signed-off-by: Jiaxun Yang --- kernel/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 1209ddaec026..2ab3f68a1bb1 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1808,6 +1808,7 @@ static int __init parallel_bringup_parse_param(char *= arg) } early_param("cpuhp.parallel", parallel_bringup_parse_param); =20 +#ifdef CONFIG_HOTPLUG_SMT static inline bool cpuhp_smt_aware(void) { return cpu_smt_max_threads > 1; @@ -1817,6 +1818,7 @@ static inline const struct cpumask *cpuhp_get_primary= _thread_mask(void) { return cpu_primary_thread_mask; } +#endif =20 /* * On architectures which have enabled parallel bringup this invokes all BP @@ -1837,6 +1839,7 @@ static bool __init cpuhp_bringup_cpus_parallel(unsign= ed int ncpus) if (!__cpuhp_parallel_bringup) return false; =20 +#ifdef CONFIG_HOTPLUG_SMT if (cpuhp_smt_aware()) { const struct cpumask *pmask =3D cpuhp_get_primary_thread_mask(); static struct cpumask tmp_mask __initdata; @@ -1857,6 +1860,7 @@ static bool __init cpuhp_bringup_cpus_parallel(unsign= ed int ncpus) cpumask_andnot(&tmp_mask, mask, pmask); mask =3D &tmp_mask; } +#endif =20 /* Bring the not-yet started CPUs up */ cpuhp_bringup_mask(mask, ncpus, CPUHP_BP_KICK_AP); --=20 2.45.2 From nobody Sun Feb 8 07:21:32 2026 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 1D68061FE8 for ; Fri, 5 Jul 2024 03:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150193; cv=none; b=XVI71MZ8tHfNTbPI84S+ghXaZNfLlLJlF5ikNhBlDNGvUSP0SfZpZryPrrLpok/bW00QJff2cR65Ksv0AHS0EFr5DK3gbzqdr+4IozYuXKBNGu/1dbhtaxGJTDT9Lis1SxHAZmAzyJat0d+qF3MUAMkpU2kluZKsg2kLOlbNj0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150193; c=relaxed/simple; bh=ap83z2hao5ETB7IMT4XYK+cshK5GthXc5rVQQe+DQWk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g/Vnpf1uoLof8QYTyOiXKWDnqnrVQgYiIVlkf+DmyckXj9/0K5TNs2O2kTgYwvNExGvdspKvuOWRyyk2mhUROAKR6wtWwm2sw9slaKLuVN4IpGGVloc/tKQw9CUAT1dqIiLCu+i90AY/JFMIB8vCPA4G6csbWHpTuk5ur/z9ApM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=FrgP9JBX; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=g4imL+Gs; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="FrgP9JBX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g4imL+Gs" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5109E1140218; Thu, 4 Jul 2024 23:29:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 04 Jul 2024 23:29:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720150189; x=1720236589; bh=YFSpt6RnR2teXj06bgCnF95X5poqchuWW1uKJeAlhRo=; b= FrgP9JBXFSyzHnjPZERoD4Taxem/BWt5mZQ7IOxdusi9syXkaxc77SCvX0qhbJTO Kbd4VuVmThvJhp2SY0oDBqIcriZFBfpUFGbJ2i0MoqTk7GZ1MP5vOEKTe0q/IBzd /3g7XyvUjfpldYUytv+Ikyf3PpzpKef1mO0MA/2qLJHjE1LoIVw8hIDzrwIi5GQy 3jkFqPPSuIKRJECjq26tcHcyhuFoM+N4+xwR2zG6N1miYNXQleP9n49n14JrltdQ Bi0Tq7zge9pybZZPnHN+F5n1oWd+2xdkAyawZifQW8OlBJvYlwbdn7cTsdgL10HR IWwnsfqgwL8AuWzDaScSng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720150189; x= 1720236589; bh=YFSpt6RnR2teXj06bgCnF95X5poqchuWW1uKJeAlhRo=; b=g 4imL+GsO23B9OVVgepuHaPEJs+PmmGK96bf7xPr7psL5s9wGKtu7KT73wOQYCgx6 Yj4zqMlkqMFpFiUH2tWub6mvwyJkNdeaqV9IveUI025xrQTqbO1Hm8Kl4+PkRUkn VaXxXHljgRcj6W2PnfV/dW8aSyjGfyAXZWiFMCB0AQ5hi4/GqhSE7DOuXkhRg+yl ZxvmGR/6Q0/kQXax9bfbM3U9m7vJykRQEcb8ol731LKTKRyCQ9wclWyf+9eNwVG0 s9QSXg4BzOHC+36xYLJEomETNe0i6B8f8WRp4AGD03GHuT3JrzhTsKPR9GksYmzb VWS58iMkw+Uwxnub0DcSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jul 2024 23:29:46 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 11:29:38 +0800 Subject: [PATCH 2/3] cpu/hotplug: Weak fallback for arch_cpuhp_init_parallel_bringup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240705-loongarch-hotplug-v1-2-67d9c4709aa9@flygoat.com> References: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> In-Reply-To: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> To: Thomas Gleixner , Peter Zijlstra , Huacai Chen , WANG Xuerui Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=858; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=ap83z2hao5ETB7IMT4XYK+cshK5GthXc5rVQQe+DQWk=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrT2jCWlx9xF7tRkWK7ZKiEZ8muHlVTnisuZHa3zz335P X0Nr/7EjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZgI2zVGhskf9HUOXb9td0lk 5aQp2z875/qYvdK15v2+RPrkNvN2pcMM/9S7Lv55tSVJf6qKX/hiQc0qppTFNlMf97y5q/PO3Nd tCRsA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 It is a general assumption that architectures entitled to parallel bringup with CONFIG_HOTPLUG_PARALLEL do expect parallel bringup to be available. Provide a weak fallback arch_cpuhp_init_parallel_bringup function to match this assumption. Signed-off-by: Jiaxun Yang --- kernel/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 2ab3f68a1bb1..c925d0f4b0c8 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1820,6 +1820,11 @@ static inline const struct cpumask *cpuhp_get_primar= y_thread_mask(void) } #endif =20 +bool __weak arch_cpuhp_init_parallel_bringup(void) +{ + return true; +} + /* * On architectures which have enabled parallel bringup this invokes all BP * prepare states for each of the to be onlined APs first. The last state --=20 2.45.2 From nobody Sun Feb 8 07:21:32 2026 Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (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 B09A57344F for ; Fri, 5 Jul 2024 03:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150195; cv=none; b=TszVKDanU+oLdr7UKVfwUpRdJDmELcJFpQ7zn60FdZ5oG3APzjH1xAcViFoX42c//HJx9oavJxcQ6/L/nuPhe/rTI1RE+DynVmJG5JiVgmQ61jxFBc3OJOpUB7lH4Zmeqg5rN+yL4Y4koLgAswONIq3NOIyumGosLs/H3kGADKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720150195; c=relaxed/simple; bh=D2mqxCRzQvs1HI/FO9ROzuiLua0L8frnlc80PUjQ/tM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p6GX0vXGIj1GywHMEElYzDM1hip/0njverKQO5cDDSB4WtwevD9rccH/7McJiJHKnJL9AGPDwdMLSaYJCCO4mIpuAhaD97qLaw7m/WUlC8hPgmOk7sNJLKtv+ctwdkHVMvTE1gsEUjvTKBdxQ248I5YXozIZGZRvcQBXE8Oy/Gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=QDkKCy5f; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FLzJmZu3; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="QDkKCy5f"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FLzJmZu3" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id E81B11380289; Thu, 4 Jul 2024 23:29:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 04 Jul 2024 23:29:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720150191; x=1720236591; bh=HeqE0UK1T7UO6X2hOhXYyZrlSpcrQ0WC48brT+ZdXlU=; b= QDkKCy5foSyTpYtIC9cKQ/4EZsUmrlc2MxXvKhcNRHIbxSOOLBbwG1HF0c9AmnVS Y65gx7kDysi/HjIhw5jugKMOEhnfGNxa6zHehxXgsPSpYCbr8+1XO8wINvtmUx0I bjY9gemW6Z6ZJ6W0UyQZSt7dNqHmlprNJwepRH6AEBIFAfXsCHZlaZ2bims4FtwE DFsArGjiYF666FKnyGJG0nXTYwXpTucHWrzs0SGinLCSpCFDggmVXgf3pBBOlHLo hAuMLl0PVFiUMPiRcFu4vCTJY0FDUa0PkyN9aCVKJkihVZAYU2zUuWAqi/5AmYYe LL130km7vI4yCb+lHTQ/Gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720150191; x= 1720236591; bh=HeqE0UK1T7UO6X2hOhXYyZrlSpcrQ0WC48brT+ZdXlU=; b=F LzJmZu3birrPfDLIt4i4aHaEZJih1wSD52Ez9+oOQxYBJXWqJEFOL48kGhTO1Jl2 gH922ZPKpbIiSidYeP7TvR1vxQGV1HMadfbtIIHTzsAmhcpQRexV5zmK05EpOFUu d4SsKHd1KYZC0sgFju0po1a9aGW2aRJdslBmC67f/XAD3CiZJX3sbbwUHned7TSX 4OrbLtNFo8GS2qGOh5+GK8uxlVhwdnABKrOKFKG9hBE/J+9AfKbeiAH9zis09Ab/ s0/1AWunIk674WuQzteCvBQkSL3uQ2Of1p5odo400h45TFwhiqhp0/E8r7Czf46C ieXdyDDnmxRXU6HoFUlFQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpefgveeikefhgedufffggeduleejveehgfdvjeeivdeitdeiffel jefgvddvudetvdenucffohhmrghinhephhgvrggurdhssgenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhih ghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jul 2024 23:29:49 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 11:29:39 +0800 Subject: [PATCH 3/3] LoongArch: SMP: Implement parallel CPU bring up Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240705-loongarch-hotplug-v1-3-67d9c4709aa9@flygoat.com> References: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> In-Reply-To: <20240705-loongarch-hotplug-v1-0-67d9c4709aa9@flygoat.com> To: Thomas Gleixner , Peter Zijlstra , Huacai Chen , WANG Xuerui Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5856; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=D2mqxCRzQvs1HI/FO9ROzuiLua0L8frnlc80PUjQ/tM=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrT2jCWW/yKfLjLlCDzgyqokFXDnbdHDUtEJf2wPJq74K Zc/K4mzo5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACayZCEjw62JnVlnbl9d/+mE 3E6nKZoLOGZX32OYIlJyPnv3hbb+07MZGU7v8l5ouXbFB9GDVf6KMhrlpipmAk4eR8IztjO+/P5 FmxUA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Implement parallel CPU bring up for LoongArch to reduce boot time consumption on bring up CPUs. On my Loongson-3A5000 ~120ms boot time improvement is observed. tp, sp register values are passed by MBUF now to avoid racing cpuboot_data global struct. cpu_running completion is handled by HOTPLUG_CORE_SYNC_FULL. Signed-off-by: Jiaxun Yang --- arch/loongarch/Kconfig | 1 + arch/loongarch/include/asm/smp.h | 6 ------ arch/loongarch/kernel/asm-offsets.c | 10 ---------- arch/loongarch/kernel/head.S | 7 ++++--- arch/loongarch/kernel/smp.c | 35 +++++++--------------------------= -- 5 files changed, 12 insertions(+), 47 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index ddc042895d01..656435c1dbd5 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -162,6 +162,7 @@ config LOONGARCH select HAVE_SYSCALL_TRACEPOINTS select HAVE_TIF_NOHZ select HAVE_VIRT_CPU_ACCOUNTING_GEN if !SMP + select HOTPLUG_PARALLEL if SMP select IRQ_FORCED_THREADING select IRQ_LOONGARCH_CPU select LOCK_MM_AND_FIND_VMA diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/= smp.h index 50db503f44e3..f6953cb16492 100644 --- a/arch/loongarch/include/asm/smp.h +++ b/arch/loongarch/include/asm/smp.h @@ -75,12 +75,6 @@ extern int __cpu_logical_map[NR_CPUS]; #define SMP_CALL_FUNCTION BIT(ACTION_CALL_FUNCTION) #define SMP_IRQ_WORK BIT(ACTION_IRQ_WORK) =20 -struct secondary_data { - unsigned long stack; - unsigned long thread_info; -}; -extern struct secondary_data cpuboot_data; - extern asmlinkage void smpboot_entry(void); extern asmlinkage void start_secondary(void); =20 diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/as= m-offsets.c index bee9f7a3108f..598498f47a4c 100644 --- a/arch/loongarch/kernel/asm-offsets.c +++ b/arch/loongarch/kernel/asm-offsets.c @@ -257,16 +257,6 @@ static void __used output_signal_defines(void) BLANK(); } =20 -#ifdef CONFIG_SMP -static void __used output_smpboot_defines(void) -{ - COMMENT("Linux smp cpu boot offsets."); - OFFSET(CPU_BOOT_STACK, secondary_data, stack); - OFFSET(CPU_BOOT_TINFO, secondary_data, thread_info); - BLANK(); -} -#endif - #ifdef CONFIG_HIBERNATION static void __used output_pbe_defines(void) { diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index fdb831dc64df..8dd8fb450f46 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -136,9 +136,10 @@ SYM_CODE_START(smpboot_entry) li.w t0, 0x00 # FPE=3D0, SXE=3D0, ASXE=3D0, BTE=3D0 csrwr t0, LOONGARCH_CSR_EUEN =20 - la.pcrel t0, cpuboot_data - ld.d sp, t0, CPU_BOOT_STACK - ld.d tp, t0, CPU_BOOT_TINFO + li.w t0, LOONGARCH_IOCSR_MBUF1 + iocsrrd.d sp, t0 + li.w t0, LOONGARCH_IOCSR_MBUF2 + iocsrrd.d tp, t0 =20 bl start_secondary ASM_BUG() diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index ca405ab86aae..ca6a95a0280d 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -48,10 +48,6 @@ EXPORT_SYMBOL(cpu_sibling_map); /* Representing the core map of multi-core chips of each logical CPU */ cpumask_t cpu_core_map[NR_CPUS] __read_mostly; EXPORT_SYMBOL(cpu_core_map); - -static DECLARE_COMPLETION(cpu_starting); -static DECLARE_COMPLETION(cpu_running); - /* * A logcal cpu mask containing only one VPE per core to * reduce the number of IPIs on large MT systems. @@ -65,7 +61,6 @@ static cpumask_t cpu_sibling_setup_map; /* representing cpus for which core maps can be computed */ static cpumask_t cpu_core_setup_map; =20 -struct secondary_data cpuboot_data; static DEFINE_PER_CPU(int, cpu_state); =20 static const char *ipi_types[NR_IPI] __tracepoint_string =3D { @@ -340,14 +335,16 @@ void __init loongson_prepare_cpus(unsigned int max_cp= us) */ void loongson_boot_secondary(int cpu, struct task_struct *idle) { - unsigned long entry; + unsigned long entry, stack, thread_info; =20 pr_info("Booting CPU#%d...\n", cpu); =20 entry =3D __pa_symbol((unsigned long)&smpboot_entry); - cpuboot_data.stack =3D (unsigned long)__KSTK_TOS(idle); - cpuboot_data.thread_info =3D (unsigned long)task_thread_info(idle); + stack =3D (unsigned long)__KSTK_TOS(idle); + thread_info =3D (unsigned long)task_thread_info(idle); =20 + csr_mail_send(thread_info, cpu_logical_map(cpu), 2); + csr_mail_send(stack, cpu_logical_map(cpu), 1); csr_mail_send(entry, cpu_logical_map(cpu), 0); =20 loongson_send_ipi_single(cpu, ACTION_BOOT_CPU); @@ -525,20 +522,10 @@ void __init smp_prepare_cpus(unsigned int max_cpus) #endif } =20 -int __cpu_up(unsigned int cpu, struct task_struct *tidle) +int arch_cpuhp_kick_ap_alive(unsigned int cpu, struct task_struct *tidle) { loongson_boot_secondary(cpu, tidle); =20 - /* Wait for CPU to start and be ready to sync counters */ - if (!wait_for_completion_timeout(&cpu_starting, - msecs_to_jiffies(5000))) { - pr_crit("CPU%u: failed to start\n", cpu); - return -EIO; - } - - /* Wait for CPU to finish startup & mark itself online before return */ - wait_for_completion(&cpu_running); - return 0; } =20 @@ -561,22 +548,14 @@ asmlinkage void start_secondary(void) set_cpu_sibling_map(cpu); set_cpu_core_map(cpu); =20 + cpuhp_ap_sync_alive(); notify_cpu_starting(cpu); =20 - /* Notify boot CPU that we're starting */ - complete(&cpu_starting); - /* The CPU is running, now mark it online */ set_cpu_online(cpu, true); =20 calculate_cpu_foreign_map(); =20 - /* - * Notify boot CPU that we're up & online and it can safely return - * from __cpu_up() - */ - complete(&cpu_running); - /* * irq will be enabled in loongson_smp_finish(), enabling it too * early is dangerous. --=20 2.45.2