X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Foprofile%2Fcpu_buffer.c;fp=drivers%2Foprofile%2Fcpu_buffer.c;h=78193e4bbdb564981a98b00437bdad6a8b851500;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=a59878e140cdcafc2f1188cd8dc19009180e063b;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index a59878e14..78193e4bb 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c @@ -6,10 +6,6 @@ * * @author John Levon * - * Modified by Aravind Menon for Xen - * These modifications are: - * Copyright (C) 2005 Hewlett-Packard Co. - * * Each CPU has a local buffer that stores PC value/event * pairs. We also log context switches when we notice them. * Eventually each CPU's buffer is processed into the global @@ -38,14 +34,13 @@ static void wq_sync_buffer(void *); #define DEFAULT_TIMER_EXPIRE (HZ / 10) static int work_enabled; -static int32_t current_domain = COORDINATOR_DOMAIN; - void free_cpu_buffers(void) { int i; - for_each_online_cpu(i) + for_each_online_cpu(i) { vfree(cpu_buffer[i].buffer); + } } int alloc_cpu_buffers(void) @@ -63,7 +58,7 @@ int alloc_cpu_buffers(void) goto fail; b->last_task = NULL; - b->last_cpu_mode = -1; + b->last_is_kernel = -1; b->tracing = 0; b->buffer_size = buffer_size; b->tail_pos = 0; @@ -119,7 +114,7 @@ void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf) * collected will populate the buffer with proper * values to initialize the buffer */ - cpu_buf->last_cpu_mode = -1; + cpu_buf->last_is_kernel = -1; cpu_buf->last_task = NULL; } @@ -169,13 +164,13 @@ add_code(struct oprofile_cpu_buffer * buffer, unsigned long value) * because of the head/tail separation of the writer and reader * of the CPU buffer. * - * cpu_mode is needed because on some architectures you cannot + * is_kernel is needed because on some architectures you cannot * tell if you are in kernel or user space simply by looking at - * pc. We tag this in the buffer by generating kernel/user (and xen) - * enter events whenever cpu_mode changes + * pc. We tag this in the buffer by generating kernel enter/exit + * events whenever is_kernel changes */ static int log_sample(struct oprofile_cpu_buffer * cpu_buf, unsigned long pc, - int cpu_mode, unsigned long event) + int is_kernel, unsigned long event) { struct task_struct * task; @@ -186,20 +181,18 @@ static int log_sample(struct oprofile_cpu_buffer * cpu_buf, unsigned long pc, return 0; } - WARN_ON(cpu_mode > CPU_MODE_XEN); + is_kernel = !!is_kernel; task = current; /* notice a switch from user->kernel or vice versa */ - if (cpu_buf->last_cpu_mode != cpu_mode) { - cpu_buf->last_cpu_mode = cpu_mode; - add_code(cpu_buf, cpu_mode); + if (cpu_buf->last_is_kernel != is_kernel) { + cpu_buf->last_is_kernel = is_kernel; + add_code(cpu_buf, is_kernel); } - + /* notice a task switch */ - /* if not processing other domain samples */ - if ((cpu_buf->last_task != task) && - (current_domain == COORDINATOR_DOMAIN)) { + if (cpu_buf->last_task != task) { cpu_buf->last_task = task; add_code(cpu_buf, (unsigned long)task); } @@ -225,10 +218,11 @@ static void oprofile_end_trace(struct oprofile_cpu_buffer * cpu_buf) cpu_buf->tracing = 0; } -void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, - unsigned long event, int is_kernel) +void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) { struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[smp_processor_id()]; + unsigned long pc = profile_pc(regs); + int is_kernel = !user_mode(regs); if (!backtrace_depth) { log_sample(cpu_buf, pc, is_kernel, event); @@ -245,14 +239,6 @@ void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, oprofile_end_trace(cpu_buf); } -void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) -{ - int is_kernel = !user_mode(regs); - unsigned long pc = profile_pc(regs); - - oprofile_add_ext_sample(pc, regs, event, is_kernel); -} - void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) { struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[smp_processor_id()]; @@ -283,25 +269,6 @@ void oprofile_add_trace(unsigned long pc) add_sample(cpu_buf, pc, 0); } -int oprofile_add_domain_switch(int32_t domain_id) -{ - struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[smp_processor_id()]; - - /* should have space for switching into and out of domain - (2 slots each) plus one sample and one cpu mode switch */ - if (((nr_available_slots(cpu_buf) < 6) && - (domain_id != COORDINATOR_DOMAIN)) || - (nr_available_slots(cpu_buf) < 2)) - return 0; - - add_code(cpu_buf, CPU_DOMAIN_SWITCH); - add_sample(cpu_buf, domain_id, 0); - - current_domain = domain_id; - - return 1; -} - /* * This serves to avoid cpu buffer overflow, and makes sure * the task mortuary progresses