From: Andrew Morton <akpm@osdl.org>
To: Andi Kleen <ak@muc.de>
Cc: ashok.raj@intel.com, ntl@pobox.com, dada1@cosmosbay.com,
riel@redhat.com, linux-kernel@vger.kernel.org, torvalds@osdl.org,
mingo@elte.hu, 76306.1226@compuserve.com, wli@holomorphy.com,
heiko.carstens@de.ibm.com, pj@sgi.com
Subject: Re: [PATCH] percpu data: only iterate over possible CPUs
Date: Fri, 10 Feb 2006 11:08:44 -0800 [thread overview]
Message-ID: <20060210110844.602a1bb0.akpm@osdl.org> (raw)
In-Reply-To: <200602101310.59889.ak@muc.de>
Andi Kleen <ak@muc.de> wrote:
>
> On Friday 10 February 2006 11:42, Andrew Morton wrote:
> > Andi Kleen <ak@muc.de> wrote:
> > >
> > > On Thursday 09 February 2006 19:04, Andrew Morton wrote:
> > > > Ashok Raj <ashok.raj@intel.com> wrote:
> > > > >
> > > > > The problem was with ACPI just simply looking at the namespace doesnt
> > > > > exactly give us an idea of how many processors are possible in this platform.
> > > >
> > > > We need to fix this asap - the performance penalty for HOTPLUG_CPU=y,
> > > > NR_CPUS=lots will be appreciable.
> > >
> > > What is this performance penalty exactly?
> >
> > All those for_each_cpu() loops will hit NR_CPUS cachelines instead of
> > hweight(cpu_possible_map) cachelines.
>
> But are there any in real fast paths? iirc they are mostly in initialization,
> where it doesn't matter too much.
>
Could be so.
I just added one to percpu_counters though. And it'd be a pain to
introduce a cpu notifier for each and every percpu_counter.
From: Andrew Morton <akpm@osdl.org>
Implement percpu_counter_sum(). This is a more accurate but slower version of
percpu_counter_read_positive().
We need this for Alex's speedup-ext3_statfs patch. Otherwise it would be too
inaccurate on large CPU counts.
Cc: Ravikiran G Thirumalai <kiran@scalex86.org>
Cc: Alex Tomas <alex@clusterfs.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
include/linux/percpu_counter.h | 6 ++++++
mm/swap.c | 25 +++++++++++++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff -puN include/linux/percpu_counter.h~percpu_counter_sum include/linux/percpu_counter.h
--- devel/include/linux/percpu_counter.h~percpu_counter_sum 2006-02-08 13:34:08.000000000 -0800
+++ devel-akpm/include/linux/percpu_counter.h 2006-02-08 13:34:08.000000000 -0800
@@ -39,6 +39,7 @@ static inline void percpu_counter_destro
}
void percpu_counter_mod(struct percpu_counter *fbc, long amount);
+long percpu_counter_sum(struct percpu_counter *fbc);
static inline long percpu_counter_read(struct percpu_counter *fbc)
{
@@ -92,6 +93,11 @@ static inline long percpu_counter_read_p
return fbc->count;
}
+static inline long percpu_counter_sum(struct percpu_counter *fbc)
+{
+ return percpu_counter_read_positive(fbc);
+}
+
#endif /* CONFIG_SMP */
static inline void percpu_counter_inc(struct percpu_counter *fbc)
diff -puN mm/swap.c~percpu_counter_sum mm/swap.c
--- devel/mm/swap.c~percpu_counter_sum 2006-02-08 13:34:08.000000000 -0800
+++ devel-akpm/mm/swap.c 2006-02-08 13:34:08.000000000 -0800
@@ -491,13 +491,34 @@ void percpu_counter_mod(struct percpu_co
if (count >= FBC_BATCH || count <= -FBC_BATCH) {
spin_lock(&fbc->lock);
fbc->count += count;
+ *pcount = 0;
spin_unlock(&fbc->lock);
- count = 0;
+ } else {
+ *pcount = count;
}
- *pcount = count;
put_cpu();
}
EXPORT_SYMBOL(percpu_counter_mod);
+
+/*
+ * Add up all the per-cpu counts, return the result. This is a more accurate
+ * but much slower version of percpu_counter_read_positive()
+ */
+long percpu_counter_sum(struct percpu_counter *fbc)
+{
+ long ret;
+ int cpu;
+
+ spin_lock(&fbc->lock);
+ ret = fbc->count;
+ for_each_cpu(cpu) {
+ long *pcount = per_cpu_ptr(fbc->counters, cpu);
+ ret += *pcount;
+ }
+ spin_unlock(&fbc->lock);
+ return ret < 0 ? 0 : ret;
+}
+EXPORT_SYMBOL(percpu_counter_sum);
#endif
/*
_
next prev parent reply other threads:[~2006-02-10 19:10 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200602051959.k15JxoHK001630@hera.kernel.org>
2006-02-07 15:15 ` Heiko Carstens
2006-02-07 15:31 ` Jens Axboe
2006-02-07 16:25 ` Eric Dumazet
2006-02-07 16:42 ` Linus Torvalds
2006-02-07 17:34 ` Andrew Morton
2006-02-07 17:48 ` Linus Torvalds
2006-02-07 18:30 ` Dipankar Sarma
2006-02-07 18:43 ` Linus Torvalds
2006-02-07 18:53 ` Dipankar Sarma
2006-02-07 19:11 ` Linus Torvalds
2006-02-08 4:40 ` Heiko Carstens
2006-02-08 8:55 ` Ivan Kokshaysky
2006-02-08 22:31 ` Rik van Riel
2006-02-09 1:20 ` Rik van Riel
2006-02-09 3:05 ` Andrew Morton
2006-02-09 3:08 ` Andrew Morton
2006-02-09 4:36 ` Eric Dumazet
2006-02-09 4:45 ` Andrew Morton
2006-02-09 4:56 ` Paul Jackson
2006-02-09 16:08 ` Nathan Lynch
2006-02-09 16:13 ` Heiko Carstens
2006-02-09 16:38 ` Rik van Riel
2006-02-09 16:59 ` Nathan Lynch
2006-02-09 17:37 ` Andi Kleen
2006-02-10 10:05 ` Heiko Carstens
2006-02-10 10:13 ` Andi Kleen
2006-02-11 14:49 ` Heiko Carstens
2006-02-11 18:04 ` Andi Kleen
2006-02-09 17:03 ` Ashok Raj
2006-02-09 17:23 ` Nathan Lynch
2006-02-09 18:04 ` Andrew Morton
2006-02-09 18:52 ` Ashok Raj
2006-02-09 20:37 ` Andrew Morton
2006-02-09 21:03 ` Ashok Raj
2006-02-10 10:02 ` Andi Kleen
2006-02-10 10:42 ` Andrew Morton
2006-02-10 11:09 ` Eric Dumazet
2006-02-10 11:23 ` Andrew Morton
2006-02-10 11:26 ` Andrew Morton
2006-02-10 14:13 ` Eric Dumazet
2006-02-11 0:10 ` Nathan Lynch
2006-02-11 0:25 ` Andrew Morton
2006-02-10 12:10 ` Andi Kleen
2006-02-10 19:08 ` Andrew Morton [this message]
2006-02-09 4:39 ` Eric Dumazet
2006-02-09 4:46 ` Nick Piggin
2006-02-09 8:32 Chuck Ebbert
2006-02-09 8:55 ` Paul Jackson
2006-02-09 9:06 ` Andrew Morton
2006-02-09 9:11 ` Andrew Morton
2006-02-09 10:08 ` Heiko Carstens
2006-02-09 10:13 ` Andrew Morton
2006-02-09 10:23 ` Heiko Carstens
2006-02-09 10:31 ` Andrew Morton
2006-02-09 11:47 ` Heiko Carstens
2006-02-09 12:46 ` Eric Dumazet
2006-02-09 13:12 ` Heiko Carstens
2006-02-09 13:55 ` Eric Dumazet
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=20060210110844.602a1bb0.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=76306.1226@compuserve.com \
--cc=ak@muc.de \
--cc=ashok.raj@intel.com \
--cc=dada1@cosmosbay.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=ntl@pobox.com \
--cc=pj@sgi.com \
--cc=riel@redhat.com \
--cc=torvalds@osdl.org \
--cc=wli@holomorphy.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
Powered by JetHome