From: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
To: Christoph Lameter <clameter@sgi.com>
Cc: akpm@osdl.org, ak@suse.de, linux-kernel@vger.kernel.org,
linux-ia64@vger.kernel.org
Subject: Re: light weight counters: race free through local_t?
Date: Fri, 16 Jun 2006 09:14:52 +0000 [thread overview]
Message-ID: <4492768C.1010703@bull.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0606151110100.9618@schroedinger.engr.sgi.com>
Let's put it in another way:
Do the statistics need to be absolutely precise?
I guess they do not.
By the time you can display them, they have already been changed.
Let's take an example:
zone_statistics(struct zonelist *zonelist, struct zone *z)
{
...
// local_irq_save(flags); // No IRQ lock out
cpu = smp_processor_id(); // Can become another CPU
p = &z->pageset[cpu]; // Can count for someone else
if (pg = orig) {
stat_incr(&z->pageset[cpu].numa_hit); // Unsafe
} else {
...
// local_irq_restore(flags);
}
Where "stat_incr()" is arch. dependent and possibly unsafe routine.
For IA64:
// Unsafe statistics
static inline void stat_incr(int *addr){
int tmp;
// Obtain immediately the cache line exclusivity, do not touch L1
asm volatile ("ld4.bias.nt1 %0=[%1]" : "=r"(tmp) : "r" (addr));
tmp++;
asm volatile ("st4 [%1] = %0" :: "r"(tmp), "r"(addr) : "memory");
}
It takes 10 clock cycles.
Regards,
Zoltan
WARNING: multiple messages have this Message-ID (diff)
From: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
To: Christoph Lameter <clameter@sgi.com>
Cc: akpm@osdl.org, ak@suse.de, linux-kernel@vger.kernel.org,
linux-ia64@vger.kernel.org
Subject: Re: light weight counters: race free through local_t?
Date: Fri, 16 Jun 2006 11:14:52 +0200 [thread overview]
Message-ID: <4492768C.1010703@bull.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0606151110100.9618@schroedinger.engr.sgi.com>
Let's put it in another way:
Do the statistics need to be absolutely precise?
I guess they do not.
By the time you can display them, they have already been changed.
Let's take an example:
zone_statistics(struct zonelist *zonelist, struct zone *z)
{
...
// local_irq_save(flags); // No IRQ lock out
cpu = smp_processor_id(); // Can become another CPU
p = &z->pageset[cpu]; // Can count for someone else
if (pg == orig) {
stat_incr(&z->pageset[cpu].numa_hit); // Unsafe
} else {
...
// local_irq_restore(flags);
}
Where "stat_incr()" is arch. dependent and possibly unsafe routine.
For IA64:
// Unsafe statistics
static inline void stat_incr(int *addr){
int tmp;
// Obtain immediately the cache line exclusivity, do not touch L1
asm volatile ("ld4.bias.nt1 %0=[%1]" : "=r"(tmp) : "r" (addr));
tmp++;
asm volatile ("st4 [%1] = %0" :: "r"(tmp), "r"(addr) : "memory");
}
It takes 10 clock cycles.
Regards,
Zoltan
next prev parent reply other threads:[~2006-06-16 9:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-10 5:30 light weight counters: race free through local_t? Christoph Lameter
2006-06-10 5:30 ` Christoph Lameter
2006-06-14 16:05 ` Zoltan Menyhart
2006-06-14 16:05 ` Zoltan Menyhart
2006-06-14 16:33 ` Christoph Lameter
2006-06-14 16:33 ` Christoph Lameter
2006-06-15 12:22 ` Zoltan Menyhart
2006-06-15 12:22 ` Zoltan Menyhart
2006-06-15 15:56 ` Christoph Lameter
2006-06-15 15:56 ` Christoph Lameter
2006-06-15 16:46 ` Zoltan Menyhart
2006-06-15 16:46 ` Zoltan Menyhart
2006-06-15 18:14 ` Christoph Lameter
2006-06-15 18:14 ` Christoph Lameter
2006-06-16 9:14 ` Zoltan Menyhart [this message]
2006-06-16 9:14 ` Zoltan Menyhart
2006-06-15 16:06 ` Christoph Lameter
2006-06-15 16:06 ` Christoph Lameter
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=4492768C.1010703@bull.net \
--to=zoltan.menyhart@bull.net \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=clameter@sgi.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.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 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.