]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - kernel/profile.c
arm: tegra: register save and restore ops
[linux-3.10.git] / kernel / profile.c
index 1e6a0d94ea63feb3bd90bc455f89b7db149be043..0bf400737660d65a03280c23df130c9e17c776ea 100644 (file)
@@ -8,12 +8,13 @@
  *  Scheduler profiling support, Arjan van de Ven and Ingo Molnar,
  *     Red Hat, July 2004
  *  Consolidation of architecture support code for profiling,
- *     William Irwin, Oracle, July 2004
+ *     Nadia Yvette Chambers, Oracle, July 2004
  *  Amortized hit count accounting via per-cpu open-addressed hashtables
- *     to resolve timer interrupt livelocks, William Irwin, Oracle, 2004
+ *     to resolve timer interrupt livelocks, Nadia Yvette Chambers,
+ *     Oracle, 2004
  */
 
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/profile.h>
 #include <linux/bootmem.h>
 #include <linux/notifier.h>
@@ -36,9 +37,6 @@ struct profile_hit {
 #define NR_PROFILE_HIT         (PAGE_SIZE/sizeof(struct profile_hit))
 #define NR_PROFILE_GRP         (NR_PROFILE_HIT/PROFILE_GRPSZ)
 
-/* Oprofile timer tick hook */
-static int (*timer_hook)(struct pt_regs *) __read_mostly;
-
 static atomic_t *prof_buffer;
 static unsigned long prof_len, prof_shift;
 
@@ -126,11 +124,9 @@ int __ref profile_init(void)
        if (prof_buffer)
                return 0;
 
-       prof_buffer = vmalloc(buffer_bytes);
-       if (prof_buffer) {
-               memset(prof_buffer, 0, buffer_bytes);
+       prof_buffer = vzalloc(buffer_bytes);
+       if (prof_buffer)
                return 0;
-       }
 
        free_cpumask_var(prof_cpu_mask);
        return -ENOMEM;
@@ -209,25 +205,6 @@ int profile_event_unregister(enum profile_type type, struct notifier_block *n)
 }
 EXPORT_SYMBOL_GPL(profile_event_unregister);
 
-int register_timer_hook(int (*hook)(struct pt_regs *))
-{
-       if (timer_hook)
-               return -EBUSY;
-       timer_hook = hook;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(register_timer_hook);
-
-void unregister_timer_hook(int (*hook)(struct pt_regs *))
-{
-       WARN_ON(hook != timer_hook);
-       timer_hook = NULL;
-       /* make sure all CPUs see the NULL hook */
-       synchronize_sched();  /* Allow ongoing interrupts to complete. */
-}
-EXPORT_SYMBOL_GPL(unregister_timer_hook);
-
-
 #ifdef CONFIG_SMP
 /*
  * Each cpu has a pair of open-addressed hashtables for pending
@@ -258,7 +235,7 @@ EXPORT_SYMBOL_GPL(unregister_timer_hook);
  * pagetable hash functions, but uses a full hashtable full of finite
  * collision chains, not just pairs of them.
  *
- * -- wli
+ * -- nyc
  */
 static void __profile_flip_buffers(void *unused)
 {
@@ -305,14 +282,12 @@ static void profile_discard_flip_buffers(void)
        mutex_unlock(&profile_flip_mutex);
 }
 
-void profile_hits(int type, void *__pc, unsigned int nr_hits)
+static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
 {
        unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
        int i, j, cpu;
        struct profile_hit *hits;
 
-       if (prof_on != type || !prof_buffer)
-               return;
        pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
        i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
        secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
@@ -365,7 +340,7 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
        switch (action) {
        case CPU_UP_PREPARE:
        case CPU_UP_PREPARE_FROZEN:
-               node = cpu_to_node(cpu);
+               node = cpu_to_mem(cpu);
                per_cpu(cpu_profile_flip, cpu) = 0;
                if (!per_cpu(cpu_profile_hits, cpu)[1]) {
                        page = alloc_pages_exact_node(node,
@@ -419,24 +394,26 @@ out_free:
 #define profile_discard_flip_buffers() do { } while (0)
 #define profile_cpu_callback           NULL
 
-void profile_hits(int type, void *__pc, unsigned int nr_hits)
+static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
 {
        unsigned long pc;
-
-       if (prof_on != type || !prof_buffer)
-               return;
        pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
        atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
 }
 #endif /* !CONFIG_SMP */
+
+void profile_hits(int type, void *__pc, unsigned int nr_hits)
+{
+       if (prof_on != type || !prof_buffer)
+               return;
+       do_profile_hits(type, __pc, nr_hits);
+}
 EXPORT_SYMBOL_GPL(profile_hits);
 
 void profile_tick(int type)
 {
        struct pt_regs *regs = get_irq_regs();
 
-       if (type == CPU_PROFILING && timer_hook)
-               timer_hook(regs);
        if (!user_mode(regs) && prof_cpu_mask != NULL &&
            cpumask_test_cpu(smp_processor_id(), prof_cpu_mask))
                profile_hit(type, (void *)profile_pc(regs));
@@ -485,10 +462,10 @@ static const struct file_operations prof_cpu_mask_proc_fops = {
        .write          = prof_cpu_mask_proc_write,
 };
 
-void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
+void create_prof_cpu_mask(void)
 {
        /* create /proc/irq/prof_cpu_mask */
-       proc_create("prof_cpu_mask", 0600, root_irq_dir, &prof_cpu_mask_proc_fops);
+       proc_create("irq/prof_cpu_mask", 0600, NULL, &prof_cpu_mask_proc_fops);
 }
 
 /*
@@ -555,6 +532,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
 static const struct file_operations proc_profile_operations = {
        .read           = read_profile,
        .write          = write_profile,
+       .llseek         = default_llseek,
 };
 
 #ifdef CONFIG_SMP
@@ -567,7 +545,7 @@ static int create_hash_tables(void)
        int cpu;
 
        for_each_online_cpu(cpu) {
-               int node = cpu_to_node(cpu);
+               int node = cpu_to_mem(cpu);
                struct page *page;
 
                page = alloc_pages_exact_node(node,
@@ -622,7 +600,7 @@ int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */
                            NULL, &proc_profile_operations);
        if (!entry)
                return 0;
-       entry->size = (1+prof_len) * sizeof(atomic_t);
+       proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
        hotcpu_notifier(profile_cpu_callback, 0);
        return 0;
 }