From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCD77C432BE for ; Thu, 2 Sep 2021 15:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3189610A2 for ; Thu, 2 Sep 2021 15:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345982AbhIBP4N (ORCPT ); Thu, 2 Sep 2021 11:56:13 -0400 Received: from home.keithp.com ([63.227.221.253]:52850 "EHLO elaine.keithp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345970AbhIBP4L (ORCPT ); Thu, 2 Sep 2021 11:56:11 -0400 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 5D2893F30806; Thu, 2 Sep 2021 08:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630598089; bh=sKaMNUHjQ3yEirvOb9Xh+Di4q4WBqN5Br/NOaG4o3yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rQhsJjM9AK0StdMYmrOSg9L+I9AbakkSLxsMf8uqclHOllqgQ6WvYo3WjLQZg//N6 H38znQ2Shov5w6W9Czsp6M4J/cBj1hzbIVg2eGuu96/W6WxETret0FWCJRlGzh1grh tJVDjFlGNrBCPieybEYtmDAuNAP8Sx7FLVPINpqzMTq+MBQGUvbsm0MVeDV3uvPmPw emCJzJByZ4vIsaH14jJxhac9I9VQQrte675X7o92yaSb++RvTcxzJoODe0j+kgBBU4 ExK8gDr7ysbOnPfP764psSwOwZ8oFCWI3b1/74iDmJN4aYmhECZaOzsh295usVzrbA F766rSrfvbRcw== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Dk0ic6zy8LHw; Thu, 2 Sep 2021 08:54:44 -0700 (PDT) Received: from keithp.com (168-103-156-98.tukw.qwest.net [168.103.156.98]) by elaine.keithp.com (Postfix) with ESMTPSA id 6F9B33F30803; Thu, 2 Sep 2021 08:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630598084; bh=sKaMNUHjQ3yEirvOb9Xh+Di4q4WBqN5Br/NOaG4o3yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkLO9pbUhAr0o/4eaRHQY+AnJgnxrB4nQh3ukE+15Ut/2DmKwgvkR8gfv3/dWkoRy Y7i3QNHSxOr7ip2YdFx2rpMR3pt585hvsIOHqGgaKQy0cxfllwFEfedcnpGzviJ2DO OW7ZEFrVqEVod2gOTdmC1rd73tvvthjZHYMqMB9faj0TSeKIBxhuDiCZjoChCB+oO2 W3MxZBHa9JuFi/6Sd7Kmosmydl2RPLmy6U027cONLEQEPSpM3b27wKh9VUv8JRJf5/ GZdjw5cQVxc6kCHWbPY8RCChR2/U28J3+7faYlXkf2BjAISbfwwxdjLyRv9MENjiZm B95ED2a2WGYsg== Received: by keithp.com (Postfix, from userid 1000) id 9B42C1E60119; Thu, 2 Sep 2021 08:55:06 -0700 (PDT) From: Keith Packard To: linux-kernel@vger.kernel.org Cc: Abbott Liu , Alexander Sverdlin , Al Viro , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Arnd Bergmann , Bjorn Andersson , Florian Fainelli , Geert Uytterhoeven , Hartley Sweeten , Jens Axboe , Jian Cai , Joe Perches , Keith Packard , Linus Walleij , linux-arm-kernel@lists.infradead.org, Maninder Singh , Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Mike Rapoport , Nick Desaulniers , Nick Desaulniers , Nicolas Pitre , Peter Zijlstra , Russell King , Thomas Gleixner , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Valentin Schneider , Vaneet Narang , "Wolfram Sang (Renesas)" , YiFei Zhu , Keith Packard Subject: [PATCH 1/2] ARM: Add per-cpu variable holding cpu number Date: Thu, 2 Sep 2021 08:54:27 -0700 Message-Id: <20210902155429.3987201-2-keithp@keithp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210902155429.3987201-1-keithp@keithp.com> References: <20210902155429.3987201-1-keithp@keithp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To help move thread_info into task_struct, stop using the cpu number contained in the thread_info block in C code and use a per-cpu variable instead. This value will be initialized long before the task_struct cpu value for the various idle threads are set, which avoids ordering issues during CPU startup. Signed-off-by: Keith Packard --- arch/arm/include/asm/smp.h | 5 ++++- arch/arm/kernel/smp.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h index 5d508f5d56c4..3aca2c2089bc 100644 --- a/arch/arm/include/asm/smp.h +++ b/arch/arm/include/asm/smp.h @@ -15,7 +15,10 @@ # error " included in non-SMP build" #endif -#define raw_smp_processor_id() (current_thread_info()->cpu) +#define raw_smp_processor_id() this_cpu_read(cpu_number) +#define __smp_processor_id() __this_cpu_read(cpu_number) + +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number); struct seq_file; diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 74679240a9d8..0457e25109c6 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -51,6 +51,9 @@ #define CREATE_TRACE_POINTS #include +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number); +EXPORT_PER_CPU_SYMBOL(cpu_number); + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -495,6 +498,7 @@ void __init smp_prepare_boot_cpu(void) void __init smp_prepare_cpus(unsigned int max_cpus) { unsigned int ncores = num_possible_cpus(); + unsigned int cpu; init_cpu_topology(); @@ -505,6 +509,16 @@ void __init smp_prepare_cpus(unsigned int max_cpus) */ if (max_cpus > ncores) max_cpus = ncores; + + /* + * Initialize the cpu_number value for each cpu before we + * start it. This ensures that the value is valid during cpu + * initialization, even before the idle task_struct cpu member + * is set + */ + for_each_possible_cpu(cpu) + per_cpu(cpu_number, cpu) = cpu; + if (ncores > 1 && max_cpus) { /* * Initialise the present map, which describes the set of CPUs -- 2.33.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92974C4320A for ; Thu, 2 Sep 2021 15:58:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F93460F6C for ; Thu, 2 Sep 2021 15:58:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5F93460F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=keithp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m0dOC54iSTEeJo1M6J75EVyEPa/o/iNTcQsl6CUrMZ8=; b=b+zuPhjCVY9UbF mI0CX2gYbBvpzrGFG3bM8jigf9JbT1eTzctoB/Ggwn4wLbFNV+dXcz60HM7OSi/8Nqkjcg0BVhaAL MlscrsxFf1X15427br0gX5t8Hl5td4uZgFlre5FYI0soOH+FCHL/dXEAGSbDxTOrTXAo/lIOkPhad +X03xwsYC02mJrIeNobe+0u2ADhPmbOmHl0JjthNoeUtOy+lZ5VMkggC7uUJtZ82oPOckmvHERvrX DFEFdszzZUMCKEysNN7lfjgw0NiQq4kCK3yxRVZWqNkv+UfvhKTnnYQnLdOmp9hieOw4gZyPvy+se LPZSz4Fd2dDnm8dpGjHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLp3n-009vnO-F9; Thu, 02 Sep 2021 15:55:27 +0000 Received: from home.keithp.com ([63.227.221.253] helo=elaine.keithp.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLp3Z-009vlD-1d for linux-arm-kernel@lists.infradead.org; Thu, 02 Sep 2021 15:55:18 +0000 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 5D2893F30806; Thu, 2 Sep 2021 08:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630598089; bh=sKaMNUHjQ3yEirvOb9Xh+Di4q4WBqN5Br/NOaG4o3yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rQhsJjM9AK0StdMYmrOSg9L+I9AbakkSLxsMf8uqclHOllqgQ6WvYo3WjLQZg//N6 H38znQ2Shov5w6W9Czsp6M4J/cBj1hzbIVg2eGuu96/W6WxETret0FWCJRlGzh1grh tJVDjFlGNrBCPieybEYtmDAuNAP8Sx7FLVPINpqzMTq+MBQGUvbsm0MVeDV3uvPmPw emCJzJByZ4vIsaH14jJxhac9I9VQQrte675X7o92yaSb++RvTcxzJoODe0j+kgBBU4 ExK8gDr7ysbOnPfP764psSwOwZ8oFCWI3b1/74iDmJN4aYmhECZaOzsh295usVzrbA F766rSrfvbRcw== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Dk0ic6zy8LHw; Thu, 2 Sep 2021 08:54:44 -0700 (PDT) Received: from keithp.com (168-103-156-98.tukw.qwest.net [168.103.156.98]) by elaine.keithp.com (Postfix) with ESMTPSA id 6F9B33F30803; Thu, 2 Sep 2021 08:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630598084; bh=sKaMNUHjQ3yEirvOb9Xh+Di4q4WBqN5Br/NOaG4o3yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkLO9pbUhAr0o/4eaRHQY+AnJgnxrB4nQh3ukE+15Ut/2DmKwgvkR8gfv3/dWkoRy Y7i3QNHSxOr7ip2YdFx2rpMR3pt585hvsIOHqGgaKQy0cxfllwFEfedcnpGzviJ2DO OW7ZEFrVqEVod2gOTdmC1rd73tvvthjZHYMqMB9faj0TSeKIBxhuDiCZjoChCB+oO2 W3MxZBHa9JuFi/6Sd7Kmosmydl2RPLmy6U027cONLEQEPSpM3b27wKh9VUv8JRJf5/ GZdjw5cQVxc6kCHWbPY8RCChR2/U28J3+7faYlXkf2BjAISbfwwxdjLyRv9MENjiZm B95ED2a2WGYsg== Received: by keithp.com (Postfix, from userid 1000) id 9B42C1E60119; Thu, 2 Sep 2021 08:55:06 -0700 (PDT) From: Keith Packard To: linux-kernel@vger.kernel.org Cc: Abbott Liu , Alexander Sverdlin , Al Viro , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Arnd Bergmann , Bjorn Andersson , Florian Fainelli , Geert Uytterhoeven , Hartley Sweeten , Jens Axboe , Jian Cai , Joe Perches , Keith Packard , Linus Walleij , linux-arm-kernel@lists.infradead.org, Maninder Singh , Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Mike Rapoport , Nick Desaulniers , Nick Desaulniers , Nicolas Pitre , Peter Zijlstra , Russell King , Thomas Gleixner , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Valentin Schneider , Vaneet Narang , "Wolfram Sang (Renesas)" , YiFei Zhu , Keith Packard Subject: [PATCH 1/2] ARM: Add per-cpu variable holding cpu number Date: Thu, 2 Sep 2021 08:54:27 -0700 Message-Id: <20210902155429.3987201-2-keithp@keithp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210902155429.3987201-1-keithp@keithp.com> References: <20210902155429.3987201-1-keithp@keithp.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210902_085513_167946_5FE21CDD X-CRM114-Status: GOOD ( 20.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To help move thread_info into task_struct, stop using the cpu number contained in the thread_info block in C code and use a per-cpu variable instead. This value will be initialized long before the task_struct cpu value for the various idle threads are set, which avoids ordering issues during CPU startup. Signed-off-by: Keith Packard --- arch/arm/include/asm/smp.h | 5 ++++- arch/arm/kernel/smp.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h index 5d508f5d56c4..3aca2c2089bc 100644 --- a/arch/arm/include/asm/smp.h +++ b/arch/arm/include/asm/smp.h @@ -15,7 +15,10 @@ # error " included in non-SMP build" #endif -#define raw_smp_processor_id() (current_thread_info()->cpu) +#define raw_smp_processor_id() this_cpu_read(cpu_number) +#define __smp_processor_id() __this_cpu_read(cpu_number) + +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number); struct seq_file; diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 74679240a9d8..0457e25109c6 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -51,6 +51,9 @@ #define CREATE_TRACE_POINTS #include +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number); +EXPORT_PER_CPU_SYMBOL(cpu_number); + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -495,6 +498,7 @@ void __init smp_prepare_boot_cpu(void) void __init smp_prepare_cpus(unsigned int max_cpus) { unsigned int ncores = num_possible_cpus(); + unsigned int cpu; init_cpu_topology(); @@ -505,6 +509,16 @@ void __init smp_prepare_cpus(unsigned int max_cpus) */ if (max_cpus > ncores) max_cpus = ncores; + + /* + * Initialize the cpu_number value for each cpu before we + * start it. This ensures that the value is valid during cpu + * initialization, even before the idle task_struct cpu member + * is set + */ + for_each_possible_cpu(cpu) + per_cpu(cpu_number, cpu) = cpu; + if (ncores > 1 && max_cpus) { /* * Initialise the present map, which describes the set of CPUs -- 2.33.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel