All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Jan Beulich <JBeulich@novell.com>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@suse.de>,
	shai@scalex86.org, kiran@scalex86.org, pravins@calsoftinc.com
Subject: [PATCH] [SMP] __GENERIC_PER_CPU changes
Date: Wed, 01 Feb 2006 10:21:10 +0100	[thread overview]
Message-ID: <43E07D86.10509@cosmosbay.com> (raw)
In-Reply-To: <43D63DB5.3010601@cosmosbay.com>

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

Now CONFIG_DEBUG_INITDATA is in, initial percpu data 
[__per_cpu_start,__per_cpu_end] can be declared as a redzone, and invalid 
accesses after boot can be detected, at least for i386.

We can let non possible cpus percpu data point to this 'redzone' instead of NULL .

NULL was not a good choice because part of [0..32768] memory may be readable 
and invalid accesses may happen unnoticed.

If CONFIG_DEBUG_INITDATA is not defined, each non possible cpu points to the 
initial percpu data (__per_cpu_offset[cpu] == 0), thus invalid accesses wont 
be detected/crash.

This patch also moves __per_cpu_offset[] to read_mostly area to avoid false 
sharing.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

[-- Attachment #2: init_main.patch --]
[-- Type: text/plain, Size: 662 bytes --]

--- a/init/main.c	2006-02-01 10:44:10.000000000 +0100
+++ b/init/main.c	2006-02-01 10:50:16.000000000 +0100
@@ -325,7 +325,7 @@
 #else
 
 #ifdef __GENERIC_PER_CPU
-unsigned long __per_cpu_offset[NR_CPUS];
+unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
 
 EXPORT_SYMBOL(__per_cpu_offset);
 
@@ -343,11 +343,7 @@
 #endif
 	ptr = alloc_bootmem(size * nr_possible_cpus);
 
-	for (i = 0; i < NR_CPUS; i++) {
-		if (!cpu_possible(i)) {
-			__per_cpu_offset[i] = (char*)0 - __per_cpu_start;
-			continue;
-		}
+	for_each_cpu(i) {
 		__per_cpu_offset[i] = ptr - __per_cpu_start;
 		memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
 		ptr += size;

  parent reply	other threads:[~2006-02-01  9:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-18 13:11 [PATCH] tvec_bases too large for per-cpu data Jan Beulich
2006-01-21  7:25 ` Andrew Morton
2006-01-23 10:31   ` Jan Beulich
2006-01-23 10:57     ` Andrew Morton
2006-01-24  8:33       ` Jan Beulich
2006-01-24  8:58         ` Andrew Morton
2006-01-24 14:46           ` [PATCH] [SMP] reduce size of percpudata, and make sure per_cpu(object, not_possible_cpu) cause an invalid memory reference Eric Dumazet
2006-01-24 14:53             ` Andi Kleen
2006-02-01  9:21             ` Eric Dumazet [this message]
2006-01-30  8:43       ` [PATCH] tvec_bases too large for per-cpu data Jan Beulich
2006-01-31 22:27         ` Andrew Morton

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=43E07D86.10509@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=JBeulich@novell.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=kiran@scalex86.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pravins@calsoftinc.com \
    --cc=shai@scalex86.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.