Re: [profile] amortize atomic hit count increments

From: William Lee Irwin III
Date: Tue Sep 14 2004 - 16:26:25 EST


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

On Tue, Sep 14, 2004 at 02:04:22PM -0700, William Lee Irwin III 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.

Repost with corrected patch.


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 13:46:05.151456768 -0700
+++ mm5-2.6.9-rc1/kernel/profile.c 2004-09-14 14:03:01.854894352 -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,21 @@
up(&profile_flip_mutex);
}

+static void profile_discard_flip_buffers(void)
+{
+ 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 +353,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 +472,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/