From nobody Wed Dec 17 15:38:25 2025 Received: from fout8-smtp.messagingengine.com (fout8-smtp.messagingengine.com [103.168.172.151]) (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 0BECA19B3D1 for ; Tue, 16 Jul 2024 14:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139313; cv=none; b=OQfPrvsSz3booegPQyinuDDBU1MPshcCngHteD0VD26UP8NejdnX1dHGG7m+FHic2DbiLKNyCrEOoVQbeuADO7nzX4uuLSXn/qqSwegm4I3aG8FVWMUjN2imwbk4l8irmsoy7ioG2lMVnOzmLdRSueIPggjMQFAloubYFGM+L5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139313; c=relaxed/simple; bh=ipsmsZYbAnzZ2nLzzwwb1hP9L5BCCXst27sn5MQXPoE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lGGGt+imnPIwTDR01YCNSgTquUuYsP5MZds7adZBpnkxaJODqtIMJkkoneFo6GgKaOGUPYikkUjNiwWIO6oR34vzvSVyXIfVTJUpHUC8//fBVcr19UMb5vJuHO78K3+X+LxceBtW3YvMVo9eozrKvPLy4hfLDDRB9xXenI5spS8= 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=JDRBCUG/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BjD+pOLu; arc=none smtp.client-ip=103.168.172.151 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="JDRBCUG/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BjD+pOLu" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 36F001388CB4; Tue, 16 Jul 2024 10:15:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 16 Jul 2024 10:15:11 -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=1721139311; x=1721225711; bh=80MXqoF8BPSn2t5IK17fPjbSuREk2f3XfiBkJXSaTeQ=; b= JDRBCUG/08sl74aGjVXKuI2/bqW41XFIdbIoiJWSOGK7cUaIOrbwIkD04B8fY6k/ VeJEBuICTREXHFSzaa5EavaBFiHlP6OdYtd6OmDiK6f9xJQCq/xqBj/2PUdvw/Bn b9owId7L71qbOAkYdiNMKL7OP0V8sB4jAD41p3tJHp6qH88KpthYSBxL6F1QLX1y aAha+WU91lM9pSXTO1rjUtr4rW+7mvI0onvuzjBOozsUljHFRLjMojRUAe4L5m6v p1NRwBl9LEBl98sO9RQEkHbbKKDg13iCYX4vCvwHqhH5eDhjz4BZJCdKqm0aDOPL 9v/8e96spVBaV8DPX++4VA== 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=1721139311; x= 1721225711; bh=80MXqoF8BPSn2t5IK17fPjbSuREk2f3XfiBkJXSaTeQ=; b=B jD+pOLuXbREnMvcpxwI1RKMnG7ViFyR9zCcPuxi6z2l9DDqAnpaNbxW7M/oHQ9Lq KypNRD41piK9u+8jriNC/br1xzD1jQceoI+wrivp6iFXmRGDJ4TXahTd2gLiM5oD glP0Wh3jdUv6VILmczVUFLS1JB0d1hySPBfRb5RqfCpH2nYYC1KCT4P2IoWq9GhM jxerG+ac33XNCAJRnD6b1/O27cYhMxOTccmmyLQZjvSHag6FMy/bzoHZ0V75qfiD d4orjeCMwEGUE6C3XFTJnnxEQa4D/T4gezDHCc8our3z/dAkFyWM+keIlcDrI/4/ uTFK3Xtn7Tj6CFo4Xxs2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeeggdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Jul 2024 10:15:08 -0400 (EDT) From: Jiaxun Yang Date: Tue, 16 Jul 2024 22:14:58 +0800 Subject: [PATCH v3 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: <20240716-loongarch-hotplug-v3-1-af59b3bb35c8@flygoat.com> References: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@flygoat.com> In-Reply-To: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@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=1139; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=ipsmsZYbAnzZ2nLzzwwb1hP9L5BCCXst27sn5MQXPoE=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrRpDenPv5gq+2X9T4xZtGGpdNW3iEuSD1UeHLlR9GSRV XJPYsiqjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZiIRR7DP7srZrbfGDadSAnQ nF+5YtlVjqOnqr40XfedpZpjNNP9lAXDfzfVF9elJuc8FuY1+j/n3MfPex65RljunV04//zyg/O WfOQEAA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Provide stub function for SMT related parallel bring up functions so that HOTPLUG_PARALLEL can work without HOTPLUG_SMT. Signed-off-by: Jiaxun Yang --- v2: Use stub function (tglx) v3: Improve commit message (tglx) --- kernel/cpu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 1209ddaec026..c89e0e91379a 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,16 @@ static inline const struct cpumask *cpuhp_get_primar= y_thread_mask(void) { return cpu_primary_thread_mask; } +#else +static inline bool cpuhp_smt_aware(void) +{ + return false; +} +static inline const struct cpumask *cpuhp_get_primary_thread_mask(void) +{ + return cpu_none_mask; +} +#endif =20 /* * On architectures which have enabled parallel bringup this invokes all BP --=20 2.45.2 From nobody Wed Dec 17 15:38:25 2025 Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (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 9188F19B59E for ; Tue, 16 Jul 2024 14:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139317; cv=none; b=iacREkTpESV8MVaekKsrTUxe8P5hfQbtUDegnCgNRDkLwDmnEEwNCbRE35Ev1rxm8ErJKdIUH6y1gJ24/urCkPv0FojTBaGuxW8DgoHfT+Z0c+HNa/sdu+PbOSPLX77jlpvgCiSi017c99iVcfanqPvoegLpdCVM3bPcABfej50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139317; c=relaxed/simple; bh=HlGdOd5dqkSqcrwCMdWmkz/K8kHNjKq9mNZ2Rtya5eA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BcLDkZvjboXKIw4rKOLblRn4T531ysWr1JTzrj4GiW8gKUzaV+3TSB1rv+LZDxCAi9AOjuyjHVVfY4aHa1lYSKlXyi1sHDppYztCIi7LjAmnTNiR5ZVCKGa+XtuEm0wrRljQiDKo/leLkyGlXLHBhE/wRLq8yS4yAyCEClbh47U= 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=jFeICd8j; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JoQvLheI; arc=none smtp.client-ip=103.168.172.156 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="jFeICd8j"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JoQvLheI" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B937911480AA; Tue, 16 Jul 2024 10:15:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 16 Jul 2024 10:15:14 -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=1721139314; x=1721225714; bh=8NNf6PSflYzXxqJ9whA2dYuWQM3qAulX8kNbAmc/R5c=; b= jFeICd8jAzm0zV9OJUfDJ9n7+4rOSCxUhk+EM5z8mZIlhdy9uC2l11epV2bFGlzJ dcGf19MeJ19+zkwJtB5GODZ6YvZPQsWuyLRrot+bFyJNKqKKyMI0QuqHsKJJVINl a3JNwqKmptwhmCv9Dk2Rs3dcfNBmYLih2DJSstCT6Zac0KSUdqmDTwNoXHitMI0W zSWlFo9WFkDt3WOcNQ4fNpltjJNASARMtVacfmZR4segCNVbHDeobf/pzeEpokW1 ifL8JJI7HGQAY8Hy6rDZFGpW8H6Lm/iAA59Zg9kH6RHuIswjc/x6xXaJ/Sgqguk0 2T8JNcNTZNV5+wYSXYEdJw== 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=1721139314; x= 1721225714; bh=8NNf6PSflYzXxqJ9whA2dYuWQM3qAulX8kNbAmc/R5c=; b=J oQvLheIeuwxxoFzyzCxWE7IqT1RjpR6Ow1mbH8Bic1WOrEZSuyR80snDWTHD42uV 3vXDXZs9zGA5CjVaIVpUUwRF/53+8wfnzh5N37yD7eODD1LyBt7vFNJU5GPOMyAQ W28CQgyg0Pu7KYYWwAxBJX9KqYhOG5FmlhqML0+DyyDFp0NyZzyPF8xmiH4eNvQO FSmNUaStL8JWi0hwInHWIOSG3ouOzArCmHeGgC171Jor07ti69DRz2f9bZv6faoF WB2YIHMTuPjom04dKitm/fJvLBwhDSmnP0Zz9N2dkqio4pBanQg2VHdaTcqDt48r 5rsZANDgu7/m9ZIIK/yjg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeeggdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Jul 2024 10:15:11 -0400 (EDT) From: Jiaxun Yang Date: Tue, 16 Jul 2024 22:14:59 +0800 Subject: [PATCH v3 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: <20240716-loongarch-hotplug-v3-2-af59b3bb35c8@flygoat.com> References: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@flygoat.com> In-Reply-To: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@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=1087; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=HlGdOd5dqkSqcrwCMdWmkz/K8kHNjKq9mNZ2Rtya5eA=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrRpDelTuJ/17SztVfxmv7UyVnLyltANExbmdIl94KgVc u2f/M6zo5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACayfRUjw3dDpqOrpELbQ3Xd Y42sb6z+HOy/d89SnUs3P5mH3BGUUmT4HyGvJzqrxMPkVF98ZaR78XT5v/8y63cIy1m2qesezn7 OBgA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 CONFIG_HOTPLUG_PARALLEL expects the architecture to implement arch_cpuhp_init_parallel_bringup() to decide whether paralllel hotplug is possible and to do the necessary architecture specific initialization. There are architectures which can enable it unconditionally and do not require architecture specific initialization. Provide a weak fallback for arch_cpuhp_init_parallel_bringup() so that such architectures are not forced to implement empty stub functions. 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 c89e0e91379a..16323610cd20 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1829,6 +1829,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 Wed Dec 17 15:38:25 2025 Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (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 4111E19CD0C for ; Tue, 16 Jul 2024 14:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139319; cv=none; b=PwPIQqTlIAykyoxlkFqazaTPxg/iKUAqC+1X+5ttSIdjvpJck13xRYdlyXYqrboNfbIs5M3Z+h65so0XfvfdPslDLFWYEf/jDC3wz/dGNvBBv8yfO5IeqVqZbLvOCWJbz7sqOvHXiqCcGWfn5LYMrUdKG4ZMXle24blWUsO7QRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139319; c=relaxed/simple; bh=GGxWrxkIuiB6pNabPRprOT7hoV6uxOIbhuzgpQUjGtc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WuQbFy/Un0v5iUXN5Be2p8PjnUEjc1VwrKPW/pgqhlja/LogyCTM+sMh2W7246r6TcXqLYeF05bLUflMCYFW0ans2m5VFNqyNYr9kFN7Mq7eFKGvdTvv8ap2Ca1TXY1+lS9tJXmfeLl/qJko24X6QxIjT227QPWjaKP5hMUsik4= 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=dQn+rEA6; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QwBZIgQD; arc=none smtp.client-ip=103.168.172.156 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="dQn+rEA6"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QwBZIgQD" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 70B8811479D5; Tue, 16 Jul 2024 10:15:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 16 Jul 2024 10:15:17 -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=1721139317; x=1721225717; bh=9P6k8vU9HH5Mx412/JWWGiX0r05o97rQ7dbH4Yr2Q24=; b= dQn+rEA6aJU0T88iGJXTGeOwlMBspzvhFrD7QRKnQITQnIT46cj0kMpzGzn7BISN etddLARYYKQ2nBAswEDRSFhDE948VsROhBEmnEIJp+XLO5+240c3R7gvodT+tiDh NSCwdkyDiVAU83jNnAa6LUvbO1K94Z/hpu/NirJSBRiTmEZH4xdAaePyeikMbL5D FSDWTP1PRV3hu5j8lZJPB5RNaGjZfFyk43enuPlZ+HxB2P1QyoZS3COQ9F8Npb6d NKSOhHQKx35wk6nqIc/u6Vt48vQY/pcbWWrxFq3r1dlSM7W/Cy2nOb/mTwYNWRJk Zfx6mi8dYNxExQ+u3kBfBw== 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=1721139317; x= 1721225717; bh=9P6k8vU9HH5Mx412/JWWGiX0r05o97rQ7dbH4Yr2Q24=; b=Q wBZIgQDd0A2hBSl1rjUhyhjlbfJHkUrXFvYQVI7A1IJuMOpSPy+wXbgRVKS6yB2D KsilXBVDUJ5McMr/Vg8NNpxwNoI6w+9S3MEAjH6+OAnj6AhG8l5H88wncUkT6Fzh HKV5ouaK4k/Xg9E6+DtAgjQKMIT+nrEXTllXHKZOhJNNcaMFqyoxPdfu9FfkMT3O qSe1v7uPqrj/gSKG+F7XdRIyvNOPxmWp4ziX74dOOln8J0rUGXYJy13W2hjmDmXT JQaS4Mo2ld7Dy4sQ15WDZ+pvqaQE/Pmel52pYdL1M/6/fgwjpmgtz/o7Ux5TJgPd X7o0hdE9UxS9Lua7aMinA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeeggdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpefgveeikefhgedufffggeduleejveehgfdvjeeivdeitdeiffel jefgvddvudetvdenucffohhmrghinhephhgvrggurdhssgenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhih ghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Jul 2024 10:15:15 -0400 (EDT) From: Jiaxun Yang Date: Tue, 16 Jul 2024 22:15:00 +0800 Subject: [PATCH v3 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: <20240716-loongarch-hotplug-v3-3-af59b3bb35c8@flygoat.com> References: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@flygoat.com> In-Reply-To: <20240716-loongarch-hotplug-v3-0-af59b3bb35c8@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=6105; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=GGxWrxkIuiB6pNabPRprOT7hoV6uxOIbhuzgpQUjGtc=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrRpDRk75waXxr62qvOMvncqIf7Fu6Zj+fLuy00ue/ZfP Pw2feHDjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZiI7y2G/0U12xXKv6kf7MgQ KLi3fqJtbZ8v2xRd33ctx984/NHJSGdkeOZx/Mby+XuebL36LPm4yZX1Gl8vGn7/erwh6q3Uac6 kW6wA 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 --- v3: Remove unecessary indirection (tglx) --- 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 | 44 ++++++++-------------------------= ---- 5 files changed, 14 insertions(+), 54 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..967bdc66217f 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 { @@ -338,19 +333,23 @@ void __init loongson_prepare_cpus(unsigned int max_cp= us) /* * Setup the PC, SP, and TP of a secondary processor and start it running! */ -void loongson_boot_secondary(int cpu, struct task_struct *idle) +int arch_cpuhp_kick_ap_alive(unsigned int cpu, struct task_struct *tidle) { - 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(tidle); + thread_info =3D (unsigned long)task_thread_info(tidle); =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); + + return 0; } =20 /* @@ -525,23 +524,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus) #endif } =20 -int __cpu_up(unsigned int cpu, struct task_struct *tidle) -{ - loongson_boot_secondary(cpu, tidle); - - /* 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; -} - /* * First C code run on the secondary CPUs after being started up by * the master. @@ -561,22 +543,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