Re: [profile] amortize atomic hit count increments

From: William Lee Irwin III
Date: Tue Sep 14 2004 - 16:20:23 EST


On Tue, Sep 14, 2004 at 12:00:30PM -0700, William Lee Irwin III wrote:
>>> Goddamn fscking short-format VHPT crap. Rusty, how the hell do I
>>> hotplug-ize this?

On Tue, Sep 14, 2004 at 01:02:20PM -0700, William Lee Irwin III wrote:
>> Okay, here's an attempt to hotplug-ize it. I have no clue whether this
>> actually works, compiles, or follows whatever rules there are about
>> dynamically allocated data referenced by per_cpu areas.

On Tue, Sep 14, 2004 at 01:04:53PM -0700, William Lee Irwin III wrote:
> Take 2: actually register the notifier I wrote.

As pointed out by John Hawkes, I forgot to flush the pending hits at
the time of profile buffer reset. The following patch, atop the cpu
hotplug notifier bits, does so.

Index: mm5-2.6.9-rc1/kernel/profile.c
===================================================================
--- mm5-2.6.9-rc1.orig/kernel/profile.c 2004-09-14 12:56:33.871160032 -0700
+++ mm5-2.6.9-rc1/kernel/profile.c 2004-09-14 13:43:55.826117208 -0700
@@ -37,6 +37,7 @@
#ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
static DEFINE_PER_CPU(int, cpu_profile_flip);
+static DECLARE_MUTEX(profile_flip_mutex);
#endif /* CONFIG_SMP */

static int __init profile_setup(char * str)
@@ -242,7 +243,6 @@

static void profile_flip_buffers(void)
{
- static DECLARE_MUTEX(profile_flip_mutex);
int i, j, cpu;

down(&profile_flip_mutex);
@@ -261,6 +261,22 @@
up(&profile_flip_mutex);
}

+static void profile_discard_flip_buffers(void)
+{
+ static DECLARE_MUTEX(profile_flip_mutex);
+ int i, cpu;
+
+ down(&profile_flip_mutex);
+ i = per_cpu(cpu_profile_flip, get_cpu());
+ put_cpu();
+ on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
+ for_each_online_cpu(cpu) {
+ struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
+ memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
+ }
+ up(&profile_flip_mutex);
+}
+
void profile_hit(int type, void *__pc)
{
unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
@@ -338,6 +354,7 @@
#endif /* CONFIG_HOTPLUG_CPU */
#else /* !CONFIG_SMP */
#define profile_flip_buffers() do { } while (0)
+#define profile_discard_flip_buffers() do { } while (0)

void profile_hit(int type, void *__pc)
{
@@ -456,7 +473,7 @@
return -EINVAL;
}
#endif
-
+ profile_discard_flip_buffers();
memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
return count;
}
-
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/