]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/profile.c
Merge branch 'master' of /usr/src/ntfs-2.6/
[linux-2.6-omap-h63xx.git] / kernel / profile.c
index 0221a50ca867c50feda6b0f1317fd2637d41d8a6..ad81f799a9b4ad29fee8836e6ef0651e2dba0819 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/cpu.h>
 #include <linux/profile.h>
 #include <linux/highmem.h>
+#include <linux/mutex.h>
 #include <asm/sections.h>
 #include <asm/semaphore.h>
 
@@ -35,29 +36,33 @@ struct profile_hit {
 #define NR_PROFILE_GRP         (NR_PROFILE_HIT/PROFILE_GRPSZ)
 
 /* Oprofile timer tick hook */
-int (*timer_hook)(struct pt_regs *);
+int (*timer_hook)(struct pt_regs *) __read_mostly;
 
 static atomic_t *prof_buffer;
 static unsigned long prof_len, prof_shift;
-static int prof_on;
+static int prof_on __read_mostly;
 static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
 #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);
+static DEFINE_MUTEX(profile_flip_mutex);
 #endif /* CONFIG_SMP */
 
 static int __init profile_setup(char * str)
 {
+       static char __initdata schedstr[] = "schedule";
        int par;
 
-       if (!strncmp(str, "schedule", 8)) {
+       if (!strncmp(str, schedstr, strlen(schedstr))) {
                prof_on = SCHED_PROFILING;
-               printk(KERN_INFO "kernel schedule profiling enabled\n");
-               if (str[7] == ',')
-                       str += 8;
-       }
-       if (get_option(&str,&par)) {
+               if (str[strlen(schedstr)] == ',')
+                       str += strlen(schedstr) + 1;
+               if (get_option(&str, &par))
+                       prof_shift = par;
+               printk(KERN_INFO
+                       "kernel schedule profiling enabled (shift: %ld)\n",
+                       prof_shift);
+       } else if (get_option(&str, &par)) {
                prof_shift = par;
                prof_on = CPU_PROFILING;
                printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
@@ -239,7 +244,7 @@ static void profile_flip_buffers(void)
 {
        int i, j, cpu;
 
-       down(&profile_flip_mutex);
+       mutex_lock(&profile_flip_mutex);
        j = per_cpu(cpu_profile_flip, get_cpu());
        put_cpu();
        on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -255,14 +260,14 @@ static void profile_flip_buffers(void)
                        hits[i].hits = hits[i].pc = 0;
                }
        }
-       up(&profile_flip_mutex);
+       mutex_unlock(&profile_flip_mutex);
 }
 
 static void profile_discard_flip_buffers(void)
 {
        int i, cpu;
 
-       down(&profile_flip_mutex);
+       mutex_lock(&profile_flip_mutex);
        i = per_cpu(cpu_profile_flip, get_cpu());
        put_cpu();
        on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -270,7 +275,7 @@ static void profile_discard_flip_buffers(void)
                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);
+       mutex_unlock(&profile_flip_mutex);
 }
 
 void profile_hit(int type, void *__pc)