29 #include <linux/module.h>
32 #include <linux/sched.h>
44 static void process_task_mortuary(
void);
59 list_add(&task->
tasks, &dying_tasks);
60 spin_unlock_irqrestore(&task_mortuary, flags);
85 munmap_notify(
struct notifier_block *
self,
unsigned long val,
void *data)
87 unsigned long addr = (
unsigned long)data;
112 module_load_notify(
struct notifier_block *
self,
unsigned long val,
void *data)
114 #ifdef CONFIG_MODULES
115 if (val != MODULE_STATE_COMING)
129 .notifier_call = task_free_notify,
133 .notifier_call = task_exit_notify,
137 .notifier_call = munmap_notify,
141 .notifier_call = module_load_notify,
144 static void free_all_tasks(
void)
147 process_task_mortuary();
148 process_task_mortuary();
155 if (!zalloc_cpumask_var(&marked_cpus,
GFP_KERNEL))
183 free_cpumask_var(marked_cpus);
200 free_cpumask_var(marked_cpus);
208 static inline unsigned long fast_get_dcookie(
struct path *
path)
213 return (
unsigned long)path->
dentry;
224 static unsigned long get_exec_dcookie(
struct mm_struct *mm)
229 cookie = fast_get_dcookie(&mm->
exe_file->f_path);
252 cookie = fast_get_dcookie(&vma->
vm_file->f_path);
271 static void add_cpu_switch(
int i)
279 static void add_kernel_ctx_switch(
unsigned int in_kernel)
289 add_user_ctx_switch(
struct task_struct const *
task,
unsigned long cookie)
302 static void add_cookie_switch(
unsigned long cookie)
310 static void add_trace_begin(
void)
322 if (!op_cpu_buffer_get_data(entry, &code))
324 if (!op_cpu_buffer_get_data(entry, &pc))
326 if (!op_cpu_buffer_get_size(entry))
338 if (cookie != last_cookie) {
339 add_cookie_switch(cookie);
349 while (op_cpu_buffer_get_data(entry, &val))
353 static inline void add_sample_entry(
unsigned long offset,
unsigned long event)
390 if (cookie != last_cookie) {
391 add_cookie_switch(cookie);
395 add_sample_entry(offset, s->
event);
401 static void release_mm(
struct mm_struct *mm)
419 static inline int is_code(
unsigned long val)
431 static void process_task_mortuary(
void)
440 list_splice_init(&dead_tasks, &local_dead_tasks);
441 list_splice_init(&dying_tasks, &dead_tasks);
443 spin_unlock_irqrestore(&task_mortuary, flags);
452 static void mark_done(
int cpu)
456 cpumask_set_cpu(cpu, marked_cpus);
466 process_task_mortuary();
468 cpumask_clear(marked_cpus);
495 unsigned long cookie = 0;
508 op_cpu_buffer_reset(cpu);
517 flags = sample->
event;
527 add_kernel_ctx_switch(flags & IS_KERNEL);
530 && op_cpu_buffer_get_data(&entry, &val)) {
535 mm = take_tasks_mm(
new);
537 cookie = get_exec_dcookie(mm);
538 add_user_ctx_switch(
new, cookie);
540 if (op_cpu_buffer_get_size(&entry))
549 if (add_sample(mm, sample, in_kernel))
571 unsigned int stop,
unsigned int max)