Re: kernbench on 512p
From: William Lee Irwin III
Date: Fri Aug 20 2004 - 12:37:11 EST
On Thu, Aug 19, 2004 at 04:03:15PM -0700, William Lee Irwin III wrote:
> Not tremendously intelligent, as concurrent readers of /proc/profile
> can render each other's results gibberish, however, this should
> mitigate some of the cacheline bouncing of prof_buffer.
> Some kind of proper IO should be possible given sufficient effort, but
> I gave up immediately when my first attempt didn't work, and this
> should be enough for getting /proc/profile to stop bouncing madly for
> users that can tolerate the concurrent IO constraint. I suppose that
> in principle one could hackishly guard collation and copying of
> prof_buffer with a semaphore in the per-cpu case. I'll work on fixing
> this eventually.
> Use perpcu_profile on the kernel command line to activate the feature.
This fixes the degenerate collate_per_cpu_profiles() behavior jbarnes
saw with this patch alone.
Index: mm2-2.6.8.1/kernel/profile.c
===================================================================
--- mm2-2.6.8.1.orig/kernel/profile.c 2004-08-19 15:11:40.000000000 -0700
+++ mm2-2.6.8.1/kernel/profile.c 2004-08-20 09:32:08.986630798 -0700
@@ -251,16 +251,15 @@
static void collate_per_cpu_profiles(void)
{
- unsigned long i;
+ int cpu;
- for (i = 0; i < prof_len; ++i) {
- int cpu;
+ memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
+ for_each_online_cpu(cpu) {
+ unsigned long i;
+ atomic_t *buf per_cpu(cpu_prof_buffer, cpu);
- atomic_set(&prof_buffer[i], 0);
- for_each_online_cpu(cpu) {
- atomic_t *buf = per_cpu(cpu_prof_buffer, cpu);
- atomic_add(atomic_read(&buf[i]), &prof_buffer[i]);
- }
+ for (i = 0; i < prof_len; ++i)
+ prof_buffer[i].counter += atomic_read(&buf[i]);
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/