linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Pingfan Liu <kernelfans@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Baoquan He <bhe@redhat.com>, Pingfan Liu <piliu@redhat.com>,
	kexec@lists.infradead.org,
	Mahesh Salgaonkar <mahesh@linux.ibm.com>,
	Ming Lei <ming.lei@redhat.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Sourabh Jain <sourabhjain@linux.ibm.com>,
	Hari Bathini <hbathini@linux.ibm.com>,
	Wen Xiong <wenxiong@us.ibm.com>
Subject: [PATCHv10 2/3] powerpc/kernel: Extend arrays' size to make room for a hole in cpu_possible_mask
Date: Wed, 27 Dec 2023 10:41:26 +0800	[thread overview]
Message-ID: <20231227024126.12424-1-kernelfans@gmail.com> (raw)
In-Reply-To: <20231227023934.12299-1-kernelfans@gmail.com>

From: Pingfan Liu <piliu@redhat.com>

This patch aims to mark all the arrays which size is decided by
nr_cpu_ids or num_possible_cpus().  Later if a hole is allowed in
cpu_possible_mask, the corresponding array should extend to hold the
last bit number in cpu_possible_mask.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Wen Xiong <wenxiong@us.ibm.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: kexec@lists.infradead.org
To: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/paca.h    | 2 ++
 arch/powerpc/kernel/paca.c         | 8 ++++----
 arch/powerpc/kernel/setup-common.c | 2 +-
 arch/powerpc/kernel/smp.c          | 3 ++-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index e667d455ecb4..a577d98dd0d8 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -299,5 +299,7 @@ static inline void free_unused_pacas(void) { }
 
 #endif /* CONFIG_PPC64 */
 
+extern int paca_last_cpu_num;
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_PACA_H */
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index 760f371cf096..840c74dd17d6 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -236,15 +236,15 @@ void setup_paca(struct paca_struct *new_paca)
 
 }
 
-static int __initdata paca_nr_cpu_ids;
+int __initdata paca_last_cpu_num;
 static int __initdata paca_ptrs_size;
 static int __initdata paca_struct_size;
 
 void __init allocate_paca_ptrs(void)
 {
-	paca_nr_cpu_ids = nr_cpu_ids;
+	paca_last_cpu_num = nr_cpu_ids;
 
-	paca_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids;
+	paca_ptrs_size = sizeof(struct paca_struct *) * paca_last_cpu_num;
 	paca_ptrs = memblock_alloc_raw(paca_ptrs_size, SMP_CACHE_BYTES);
 	if (!paca_ptrs)
 		panic("Failed to allocate %d bytes for paca pointers\n",
@@ -258,7 +258,7 @@ void __init allocate_paca(int cpu)
 	u64 limit;
 	struct paca_struct *paca;
 
-	BUG_ON(cpu >= paca_nr_cpu_ids);
+	BUG_ON(cpu >= paca_last_cpu_num);
 
 #ifdef CONFIG_PPC_BOOK3S_64
 	/*
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 2f1026fba00d..f9f5f313abf0 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -453,7 +453,7 @@ void __init smp_setup_cpu_maps(void)
 
 	DBG("smp_setup_cpu_maps()\n");
 
-	cpu_to_phys_id = memblock_alloc(nr_cpu_ids * sizeof(u32),
+	cpu_to_phys_id = memblock_alloc(paca_last_cpu_num * sizeof(u32),
 					__alignof__(u32));
 	if (!cpu_to_phys_id)
 		panic("%s: Failed to allocate %zu bytes align=0x%zx\n",
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 5826f5108a12..6fefe22fd118 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1140,7 +1140,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	}
 
 	if (cpu_to_chip_id(boot_cpuid) != -1) {
-		int idx = DIV_ROUND_UP(num_possible_cpus(), threads_per_core);
+		int idx = DIV_ROUND_UP(cpumask_last(cpu_possible_mask),
+				threads_per_core);
 
 		/*
 		 * All threads of a core will all belong to the same core,
-- 
2.31.1


  parent reply	other threads:[~2023-12-27  2:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27  2:39 [PATCHv10 0/3] enable nr_cpus for powerpc without re-ordering cpu number Pingfan Liu
2023-12-27  2:39 ` [PATCHv10 1/3] powerpc/kernel: Remove check on paca_ptrs_size Pingfan Liu
2023-12-27  2:41 ` Pingfan Liu [this message]
2023-12-27 19:52   ` [PATCHv10 2/3] powerpc/kernel: Extend arrays' size to make room for a hole in cpu_possible_mask kernel test robot
2023-12-27  2:41 ` [PATCHv10 3/3] powerpc/smp: Allow hole in paca_ptrs to accommodate boot_cpu Pingfan Liu
2023-12-27 20:45   ` kernel test robot
2023-12-28  4:07   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231227024126.12424-1-kernelfans@gmail.com \
    --to=kernelfans@gmail.com \
    --cc=bhe@redhat.com \
    --cc=hbathini@linux.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mahesh@linux.ibm.com \
    --cc=ming.lei@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=piliu@redhat.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=wenxiong@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).