mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: tj@kernel.org
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/12]: sparc64: Only allocate per-cpu areas for possible cpus.
Date: Wed, 08 Apr 2009 22:37:55 -0700 (PDT)	[thread overview]
Message-ID: <20090408.223755.06231218.davem@davemloft.net> (raw)


This gets us real close to the generic implementation of
setup_per_cpu_areas() except:

1) We store the per-cpu offset into the trap_block[], whereas
   the generic code has it's own static array.

2) We have to initialize the %g5 register to hold the boot cpu's
   per-cpu area offset.

3) The OBP/MDESC cpu info scan is performed at the end.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/smp_64.c |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index af0b28e..168025f 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1373,27 +1373,17 @@ void smp_send_stop(void)
 
 void __init setup_per_cpu_areas(void)
 {
-	unsigned long base, shift, goal, size, i;
+	unsigned long size, i, nr_possible_cpus = num_possible_cpus();
 	char *ptr;
 
 	/* Copy section for each CPU (we discard the original) */
-	goal = PERCPU_ENOUGH_ROOM;
+	size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
+	ptr = alloc_bootmem_pages(size * nr_possible_cpus);
 
-	shift = PAGE_SHIFT;
-	for (size = PAGE_SIZE; size < goal; size <<= 1UL)
-		shift++;
-
-	ptr = __alloc_bootmem(size * NR_CPUS, PAGE_SIZE, 0);
-	if (!ptr) {
-		prom_printf("Cannot allocate per-cpu memory.\n");
-		prom_halt();
-	}
-
-	base = ptr - __per_cpu_start;
-
-	for (i = 0; i < NR_CPUS; i++, ptr += size) {
-		__per_cpu_offset(i) = base + (i * size);
+	for_each_possible_cpu(i) {
+		__per_cpu_offset(i) = ptr - __per_cpu_start;
 		memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+		ptr += size;
 	}
 
 	/* Setup %g5 for the boot cpu.  */
-- 
1.6.2.2


                 reply	other threads:[~2009-04-09  5:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090408.223755.06231218.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=tj@kernel.org \
    /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

all inboxes | Powered by JetHome®