All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Christoph Lameter <clameter@sgi.com>
Cc: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: 2.6.16-rc6-mm2
Date: Mon, 12 Jun 2006 13:48:57 +0200	[thread overview]
Message-ID: <20060612114857.GA14616@elte.hu> (raw)
In-Reply-To: <20060612110537.GA11358@elte.hu>


* Ingo Molnar <mingo@elte.hu> wrote:

> 
> * Christoph Lameter <clameter@sgi.com> wrote:
> 
> > Sorry that patch was still against mm1. Here is a fixed up version 
> > that applies cleanly against mm2:
> 
> i have applied both patches you sent in this thread but it still 
> triggers tons of messages:

> trying to fix it i realized that i'd have to touch tons of 
> architectures, which all duplicate this piece of code:

below is an updated patch that includes fixups for i386 - but the real 
fix should be to properly reduce the per-arch local.h footprint to the 
bare minimum possible, and to do this fix on the asm-generic headers.

	Ingo
---
 include/asm-generic/local.h |   20 ++++++++++----------
 include/asm-i386/local.h    |   25 ++++++++++++++-----------
 include/linux/page-flags.h  |   14 +++++---------
 mm/page_alloc.c             |    8 ++++----
 4 files changed, 33 insertions(+), 34 deletions(-)

Index: linux/include/asm-generic/local.h
===================================================================
--- linux.orig/include/asm-generic/local.h
+++ linux/include/asm-generic/local.h
@@ -44,19 +44,19 @@ typedef struct
  * much more efficient than these naive implementations.  Note they take
  * a variable (eg. mystruct.foo), not an address.
  */
-#define cpu_local_read(v)	local_read(&__get_cpu_var(v))
-#define cpu_local_set(v, i)	local_set(&__get_cpu_var(v), (i))
-#define cpu_local_inc(v)	local_inc(&__get_cpu_var(v))
-#define cpu_local_dec(v)	local_dec(&__get_cpu_var(v))
-#define cpu_local_add(i, v)	local_add((i), &__get_cpu_var(v))
-#define cpu_local_sub(i, v)	local_sub((i), &__get_cpu_var(v))
+#define cpu_local_read(v)	local_read(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_set(v, i)	local_set(&per_cpu(v, raw_smp_processor_id()), (i))
+#define cpu_local_inc(v)	local_inc(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_dec(v)	local_dec(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_add(i, v)	local_add((i), &per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_sub(i, v)	local_sub((i), &per_cpu(v, raw_smp_processor_id()))
 
 /* Non-atomic increments, ie. preemption disabled and won't be touched
  * in interrupt, etc.  Some archs can optimize this case well.
  */
-#define __cpu_local_inc(v)	__local_inc(&__get_cpu_var(v))
-#define __cpu_local_dec(v)	__local_dec(&__get_cpu_var(v))
-#define __cpu_local_add(i, v)	__local_add((i), &__get_cpu_var(v))
-#define __cpu_local_sub(i, v)	__local_sub((i), &__get_cpu_var(v))
+#define __cpu_local_inc(v)	__local_inc(&per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_dec(v)	__local_dec(&per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_add(i, v)	__local_add((i), &per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_sub(i, v)	__local_sub((i), &per_cpu(v, raw_smp_processor_id()))
 
 #endif /* _ASM_GENERIC_LOCAL_H */
Index: linux/include/asm-i386/local.h
===================================================================
--- linux.orig/include/asm-i386/local.h
+++ linux/include/asm-i386/local.h
@@ -53,18 +53,21 @@ static __inline__ void local_sub(long i,
 
 /* Use these for per-cpu local_t variables: on some archs they are
  * much more efficient than these naive implementations.  Note they take
- * a variable, not an address.
+ * a variable (eg. mystruct.foo), not an address.
  */
-#define cpu_local_read(v)	local_read(&__get_cpu_var(v))
-#define cpu_local_set(v, i)	local_set(&__get_cpu_var(v), (i))
-#define cpu_local_inc(v)	local_inc(&__get_cpu_var(v))
-#define cpu_local_dec(v)	local_dec(&__get_cpu_var(v))
-#define cpu_local_add(i, v)	local_add((i), &__get_cpu_var(v))
-#define cpu_local_sub(i, v)	local_sub((i), &__get_cpu_var(v))
+#define cpu_local_read(v)	local_read(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_set(v, i)	local_set(&per_cpu(v, raw_smp_processor_id()), (i))
+#define cpu_local_inc(v)	local_inc(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_dec(v)	local_dec(&per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_add(i, v)	local_add((i), &per_cpu(v, raw_smp_processor_id()))
+#define cpu_local_sub(i, v)	local_sub((i), &per_cpu(v, raw_smp_processor_id()))
 
-#define __cpu_local_inc(v)	cpu_local_inc(v)
-#define __cpu_local_dec(v)	cpu_local_dec(v)
-#define __cpu_local_add(i, v)	cpu_local_add((i), (v))
-#define __cpu_local_sub(i, v)	cpu_local_sub((i), (v))
+/* Non-atomic increments, ie. preemption disabled and won't be touched
+ * in interrupt, etc.  Some archs can optimize this case well.
+ */
+#define __cpu_local_inc(v)	__local_inc(&per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_dec(v)	__local_dec(&per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_add(i, v)	__local_add((i), &per_cpu(v, raw_smp_processor_id()))
+#define __cpu_local_sub(i, v)	__local_sub((i), &per_cpu(v, raw_smp_processor_id()))
 
 #endif /* _ARCH_I386_LOCAL_H */
Index: linux/include/linux/page-flags.h
===================================================================
--- linux.orig/include/linux/page-flags.h
+++ linux/include/linux/page-flags.h
@@ -8,7 +8,7 @@
 #include <linux/percpu.h>
 #include <linux/cache.h>
 #include <linux/types.h>
-
+#include <asm/local.h>
 #include <asm/pgtable.h>
 
 /*
@@ -108,10 +108,6 @@
 /*
  * Light weight per cpu counter implementation.
  *
- * Note that these can race. We do not bother to enable preemption
- * or care about interrupt races. All we care about is to have some
- * approximate count of events.
- *
  * Counters should only be incremented and no critical kernel component
  * should rely on the counter values.
  *
@@ -134,24 +130,24 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
 };
 
 struct vm_event_state {
-	unsigned long event[NR_VM_EVENT_ITEMS];
+	local_t event[NR_VM_EVENT_ITEMS];
 };
 
 DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
 
 static inline unsigned long get_cpu_vm_events(enum vm_event_item item)
 {
-	return __get_cpu_var(vm_event_states).event[item];
+	return cpu_local_read(vm_event_states.event[item]);
 }
 
 static inline void count_vm_event(enum vm_event_item item)
 {
-	__get_cpu_var(vm_event_states).event[item]++;
+	cpu_local_inc(vm_event_states.event[item]);
 }
 
 static inline void count_vm_events(enum vm_event_item item, long delta)
 {
-	__get_cpu_var(vm_event_states).event[item] += delta;
+	cpu_local_add(delta, vm_event_states.event[item]);
 }
 
 extern void all_vm_events(unsigned long *);
Index: linux/mm/page_alloc.c
===================================================================
--- linux.orig/mm/page_alloc.c
+++ linux/mm/page_alloc.c
@@ -1583,7 +1583,7 @@ static void show_node(struct zone *zone)
 #endif
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
-DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
+DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{LOCAL_INIT(0)}};
 EXPORT_PER_CPU_SYMBOL(vm_event_states);
 
 static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask)
@@ -1604,7 +1604,7 @@ static void sum_vm_events(unsigned long 
 
 
 		for (i=0; i< NR_VM_EVENT_ITEMS; i++)
-			ret[i] += this->event[i];
+			ret[i] += local_read(&this->event[i]);
 	}
 }
 
@@ -2881,8 +2881,8 @@ static void vm_events_fold_cpu(int cpu)
 	int i;
 
 	for (i = 0; i < NR_VM_EVENT_ITEMS; i++) {
-		count_vm_events(i, fold_state->event[i]);
-		fold_state->event[i] = 0;
+		count_vm_events(i, local_read(&fold_state->event[i]));
+		local_set(&fold_state->event[i], 0);
 	}
 }
 

  reply	other threads:[~2006-06-12 11:49 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-10  4:40 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 10:23 ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-10 16:24   ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 16:43     ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-10 16:51       ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-10 17:03         ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 18:04           ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-10 18:14             ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-10 18:31               ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-10 18:35                 ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-12 11:05                 ` 2.6.16-rc6-mm2 Ingo Molnar
2006-06-12 11:48                   ` Ingo Molnar [this message]
2006-06-12 12:14                     ` 2.6.16-rc6-mm2 Andi Kleen
2006-06-12 13:07                       ` 2.6.16-rc6-mm2 Ingo Molnar
2006-06-12 13:41                         ` 2.6.16-rc6-mm2 Andi Kleen
2006-06-13  3:28                       ` 2.6.16-rc6-mm2 Keith Owens
2006-06-13  4:56                         ` 2.6.16-rc6-mm2 Andi Kleen
2006-06-13  5:08                           ` 2.6.16-rc6-mm2 Keith Owens
2006-06-13  5:18                             ` 2.6.16-rc6-mm2 Andi Kleen
2006-06-13  5:43                               ` 2.6.16-rc6-mm2 Nick Piggin
2006-06-13  5:48                                 ` 2.6.16-rc6-mm2 Andi Kleen
2006-06-13 11:45                             ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-13 12:41                               ` 2.6.16-rc6-mm2 Keith Owens
2006-06-12 16:37                     ` broken local_t on i386 Christoph Lameter
2006-06-12 16:48                       ` Andi Kleen
2006-06-12 16:54                         ` Christoph Lameter
2006-06-12 17:06                           ` Andi Kleen
2006-06-12 17:11                             ` Christoph Lameter
2006-06-12 17:29                               ` Andi Kleen
2006-06-12 18:14                             ` Lee Revell
2006-06-12 18:46                               ` Alan Cox
2006-06-12 18:27                             ` Christoph Lameter
2006-06-12 17:35                               ` Andi Kleen
2006-06-12 18:42                                 ` Christoph Lameter
2006-06-12 17:55                                   ` Andi Kleen
2006-06-12 18:59                                     ` Christoph Lameter
2006-06-12 18:11                                       ` Andi Kleen
2006-06-12 19:15                                         ` Christoph Lameter
2006-06-13  3:36                                           ` Andi Kleen
2006-06-12 20:12                                         ` Alan Cox
2006-06-13  4:02                                           ` Andi Kleen
2006-06-12 13:50                   ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-12 14:20                     ` 2.6.16-rc6-mm2 Ingo Molnar
2006-06-12 14:57                       ` 2.6.16-rc6-mm2 Michal Piotrowski
     [not found]               ` <6bffcb0e0606101126v55cc20dbk275d8aa7fdcb0f1a@mail.gmail.com>
2006-06-10 18:36                 ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-10 19:08                   ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-10 16:58       ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 14:56 ` 2.6.16-rc6-mm2 Martin J. Bligh
2006-06-10 14:56   ` 2.6.16-rc6-mm2 Martin J. Bligh
2006-06-10 15:40   ` 2.6.16-rc6-mm2 Felix Oxley
2006-06-10 16:43   ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 16:43     ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-10 16:18 ` 2.6.16-rc6-mm2 Dominik Karall
2006-06-10 16:25   ` 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-10 17:42     ` 2.6.16-rc6-mm2 Dominik Karall
2006-06-10 18:43       ` 2.6.16-rc6-mm2 Rafael J. Wysocki
2006-06-11 10:17         ` 2.6.16-rc6-mm2 Jan Engelhardt
2006-06-11 10:58           ` 2.6.16-rc6-mm2 Rafael J. Wysocki
2006-06-12 16:56 ` 2.6.16-rc6-mm2 Zan Lynx
2006-06-12 17:35 ` 2.6.16-rc6-mm2 Cedric Le Goater
2006-06-12 20:55   ` Fwd: 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-12 22:16   ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-13  0:24     ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-14 21:56       ` 2.6.16-rc6-mm2 Trond Myklebust
2006-06-13  7:22     ` 2.6.16-rc6-mm2 Cedric Le Goater
2006-06-13 17:54       ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-13 19:35         ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-13 20:22           ` 2.6.16-rc6-mm2 Cedric Le Goater
2006-06-13 21:13             ` 2.6.16-rc6-mm2 Christoph Lameter
2006-06-13 21:50               ` 2.6.16-rc6-mm2 Cedric Le Goater
2006-06-12 18:19 ` 2.6.16-rc6-mm2 Badari Pulavarty
2006-06-12 20:48   ` Fwd: 2.6.16-rc6-mm2 Michal Piotrowski
2006-06-13 13:54   ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-13 17:04     ` 2.6.16-rc6-mm2 Badari Pulavarty
2006-06-12 22:09 ` 2.6.16-rc6-mm2 Steve Fox
2006-06-13 13:54   ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-13 14:10     ` 2.6.16-rc6-mm2 Sergei Shtylyov
2006-06-13 19:01       ` 2.6.16-rc6-mm2 Steve Fox
2006-06-13 21:43       ` 2.6.16-rc6-mm2 Andrew Morton
2006-06-13 21:51       ` 2.6.16-rc6-mm2 Badari Pulavarty
2006-06-13 22:36         ` 2.6.16-rc6-mm2 Steve Fox
  -- strict thread matches above, loose matches on Subject: below --
2006-03-18 12:40 2.6.16-rc6-mm2 Andrew Morton
2006-03-18 12:40 2.6.16-rc6-mm2 Andrew Morton
2006-03-18 20:21 ` 2.6.16-rc6-mm2 Rafael J. Wysocki
2006-03-18 20:54   ` 2.6.16-rc6-mm2 Andrew Morton
2006-03-18 21:24     ` 2.6.16-rc6-mm2 Rafael J. Wysocki
2006-03-22  8:41 ` 2.6.16-rc6-mm2 J.A. Magallon
2006-03-22  8:48   ` 2.6.16-rc6-mm2 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=20060612114857.GA14616@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.k.k.piotrowski@gmail.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 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.