Commit 1ad82fd5 authored by Paolo Ciarrocchi's avatar Paolo Ciarrocchi Committed by Ingo Molnar

debug: clean up kernel/profile.c

 Before:
 total: 25 errors, 13 warnings, 602 lines checked

 After:
 total: 0 errors, 2 warnings, 601 lines checked

No code changed:

kernel/profile.o:
   text    data     bss     dec     hex filename
   3048     236      24    3308     cec profile.o.before
   3048     236      24    3308     cec profile.o.after
 md5:
   2501d64748a4d350dffb11203e2a5182  profile.o.before.asm
   2501d64748a4d350dffb11203e2a5182  profile.o.after.asm
Signed-off-by: default avatarPaolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 6478d880
...@@ -52,7 +52,7 @@ static DEFINE_PER_CPU(int, cpu_profile_flip); ...@@ -52,7 +52,7 @@ static DEFINE_PER_CPU(int, cpu_profile_flip);
static DEFINE_MUTEX(profile_flip_mutex); static DEFINE_MUTEX(profile_flip_mutex);
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
static int __init profile_setup(char * str) static int __init profile_setup(char *str)
{ {
static char __initdata schedstr[] = "schedule"; static char __initdata schedstr[] = "schedule";
static char __initdata sleepstr[] = "sleep"; static char __initdata sleepstr[] = "sleep";
...@@ -104,28 +104,28 @@ __setup("profile=", profile_setup); ...@@ -104,28 +104,28 @@ __setup("profile=", profile_setup);
void __init profile_init(void) void __init profile_init(void)
{ {
if (!prof_on) if (!prof_on)
return; return;
/* only text is profiled */ /* only text is profiled */
prof_len = (_etext - _stext) >> prof_shift; prof_len = (_etext - _stext) >> prof_shift;
prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t)); prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t));
} }
/* Profile event notifications */ /* Profile event notifications */
#ifdef CONFIG_PROFILING #ifdef CONFIG_PROFILING
static BLOCKING_NOTIFIER_HEAD(task_exit_notifier); static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
static ATOMIC_NOTIFIER_HEAD(task_free_notifier); static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
static BLOCKING_NOTIFIER_HEAD(munmap_notifier); static BLOCKING_NOTIFIER_HEAD(munmap_notifier);
void profile_task_exit(struct task_struct * task) void profile_task_exit(struct task_struct *task)
{ {
blocking_notifier_call_chain(&task_exit_notifier, 0, task); blocking_notifier_call_chain(&task_exit_notifier, 0, task);
} }
int profile_handoff_task(struct task_struct * task) int profile_handoff_task(struct task_struct *task)
{ {
int ret; int ret;
ret = atomic_notifier_call_chain(&task_free_notifier, 0, task); ret = atomic_notifier_call_chain(&task_free_notifier, 0, task);
...@@ -137,52 +137,55 @@ void profile_munmap(unsigned long addr) ...@@ -137,52 +137,55 @@ void profile_munmap(unsigned long addr)
blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr); blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr);
} }
int task_handoff_register(struct notifier_block * n) int task_handoff_register(struct notifier_block *n)
{ {
return atomic_notifier_chain_register(&task_free_notifier, n); return atomic_notifier_chain_register(&task_free_notifier, n);
} }
EXPORT_SYMBOL_GPL(task_handoff_register);
int task_handoff_unregister(struct notifier_block * n) int task_handoff_unregister(struct notifier_block *n)
{ {
return atomic_notifier_chain_unregister(&task_free_notifier, n); return atomic_notifier_chain_unregister(&task_free_notifier, n);
} }
EXPORT_SYMBOL_GPL(task_handoff_unregister);
int profile_event_register(enum profile_type type, struct notifier_block * n) int profile_event_register(enum profile_type type, struct notifier_block *n)
{ {
int err = -EINVAL; int err = -EINVAL;
switch (type) { switch (type) {
case PROFILE_TASK_EXIT: case PROFILE_TASK_EXIT:
err = blocking_notifier_chain_register( err = blocking_notifier_chain_register(
&task_exit_notifier, n); &task_exit_notifier, n);
break; break;
case PROFILE_MUNMAP: case PROFILE_MUNMAP:
err = blocking_notifier_chain_register( err = blocking_notifier_chain_register(
&munmap_notifier, n); &munmap_notifier, n);
break; break;
} }
return err; return err;
} }
EXPORT_SYMBOL_GPL(profile_event_register);
int profile_event_unregister(enum profile_type type, struct notifier_block *n)
int profile_event_unregister(enum profile_type type, struct notifier_block * n)
{ {
int err = -EINVAL; int err = -EINVAL;
switch (type) { switch (type) {
case PROFILE_TASK_EXIT: case PROFILE_TASK_EXIT:
err = blocking_notifier_chain_unregister( err = blocking_notifier_chain_unregister(
&task_exit_notifier, n); &task_exit_notifier, n);
break; break;
case PROFILE_MUNMAP: case PROFILE_MUNMAP:
err = blocking_notifier_chain_unregister( err = blocking_notifier_chain_unregister(
&munmap_notifier, n); &munmap_notifier, n);
break; break;
} }
return err; return err;
} }
EXPORT_SYMBOL_GPL(profile_event_unregister);
int register_timer_hook(int (*hook)(struct pt_regs *)) int register_timer_hook(int (*hook)(struct pt_regs *))
{ {
...@@ -191,6 +194,7 @@ int register_timer_hook(int (*hook)(struct pt_regs *)) ...@@ -191,6 +194,7 @@ int register_timer_hook(int (*hook)(struct pt_regs *))
timer_hook = hook; timer_hook = hook;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(register_timer_hook);
void unregister_timer_hook(int (*hook)(struct pt_regs *)) void unregister_timer_hook(int (*hook)(struct pt_regs *))
{ {
...@@ -199,13 +203,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *)) ...@@ -199,13 +203,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
/* make sure all CPUs see the NULL hook */ /* make sure all CPUs see the NULL hook */
synchronize_sched(); /* Allow ongoing interrupts to complete. */ synchronize_sched(); /* Allow ongoing interrupts to complete. */
} }
EXPORT_SYMBOL_GPL(register_timer_hook);
EXPORT_SYMBOL_GPL(unregister_timer_hook); EXPORT_SYMBOL_GPL(unregister_timer_hook);
EXPORT_SYMBOL_GPL(task_handoff_register);
EXPORT_SYMBOL_GPL(task_handoff_unregister);
EXPORT_SYMBOL_GPL(profile_event_register);
EXPORT_SYMBOL_GPL(profile_event_unregister);
#endif /* CONFIG_PROFILING */ #endif /* CONFIG_PROFILING */
...@@ -366,7 +364,7 @@ static int __devinit profile_cpu_callback(struct notifier_block *info, ...@@ -366,7 +364,7 @@ static int __devinit profile_cpu_callback(struct notifier_block *info,
per_cpu(cpu_profile_hits, cpu)[0] = page_address(page); per_cpu(cpu_profile_hits, cpu)[0] = page_address(page);
} }
break; break;
out_free: out_free:
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]); page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
per_cpu(cpu_profile_hits, cpu)[1] = NULL; per_cpu(cpu_profile_hits, cpu)[1] = NULL;
__free_page(page); __free_page(page);
...@@ -409,7 +407,6 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits) ...@@ -409,7 +407,6 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits)
atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]); atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
} }
#endif /* !CONFIG_SMP */ #endif /* !CONFIG_SMP */
EXPORT_SYMBOL_GPL(profile_hits); EXPORT_SYMBOL_GPL(profile_hits);
void profile_tick(int type) void profile_tick(int type)
...@@ -427,7 +424,7 @@ void profile_tick(int type) ...@@ -427,7 +424,7 @@ void profile_tick(int type)
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data) int count, int *eof, void *data)
{ {
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
...@@ -437,8 +434,8 @@ static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, ...@@ -437,8 +434,8 @@ static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
return len; return len;
} }
static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer, static int prof_cpu_mask_write_proc(struct file *file,
unsigned long count, void *data) const char __user *buffer, unsigned long count, void *data)
{ {
cpumask_t *mask = (cpumask_t *)data; cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err; unsigned long full_count = count, err;
...@@ -457,7 +454,8 @@ void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir) ...@@ -457,7 +454,8 @@ void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
struct proc_dir_entry *entry; struct proc_dir_entry *entry;
/* create /proc/irq/prof_cpu_mask */ /* create /proc/irq/prof_cpu_mask */
if (!(entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir))) entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return; return;
entry->data = (void *)&prof_cpu_mask; entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc; entry->read_proc = prof_cpu_mask_read_proc;
...@@ -475,7 +473,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -475,7 +473,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{ {
unsigned long p = *ppos; unsigned long p = *ppos;
ssize_t read; ssize_t read;
char * pnt; char *pnt;
unsigned int sample_step = 1 << prof_shift; unsigned int sample_step = 1 << prof_shift;
profile_flip_buffers(); profile_flip_buffers();
...@@ -486,12 +484,12 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -486,12 +484,12 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
read = 0; read = 0;
while (p < sizeof(unsigned int) && count > 0) { while (p < sizeof(unsigned int) && count > 0) {
if (put_user(*((char *)(&sample_step)+p),buf)) if (put_user(*((char *)(&sample_step)+p), buf))
return -EFAULT; return -EFAULT;
buf++; p++; count--; read++; buf++; p++; count--; read++;
} }
pnt = (char *)prof_buffer + p - sizeof(atomic_t); pnt = (char *)prof_buffer + p - sizeof(atomic_t);
if (copy_to_user(buf,(void *)pnt,count)) if (copy_to_user(buf, (void *)pnt, count))
return -EFAULT; return -EFAULT;
read += count; read += count;
*ppos += read; *ppos += read;
...@@ -508,7 +506,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf, ...@@ -508,7 +506,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
extern int setup_profiling_timer (unsigned int multiplier); extern int setup_profiling_timer(unsigned int multiplier);
if (count == sizeof(int)) { if (count == sizeof(int)) {
unsigned int multiplier; unsigned int multiplier;
...@@ -591,7 +589,8 @@ static int __init create_proc_profile(void) ...@@ -591,7 +589,8 @@ static int __init create_proc_profile(void)
return 0; return 0;
if (create_hash_tables()) if (create_hash_tables())
return -1; return -1;
if (!(entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL))) entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL);
if (!entry)
return 0; return 0;
entry->proc_fops = &proc_profile_operations; entry->proc_fops = &proc_profile_operations;
entry->size = (1+prof_len) * sizeof(atomic_t); entry->size = (1+prof_len) * sizeof(atomic_t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment