Commit 0794bff0 authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] make prof_buffer atomic_t

Convert prof_buffer to an array of atomic_t instead of sometimes atomic_t,
sometimes unsigned int.  Also, bootmem rounds up internally, so blow away some
crap code there.
Signed-off-by: default avatarWilliam Irwin <wli@holomorphy.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9e22a072
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/profile.h> #include <linux/profile.h>
#include <asm/sections.h> #include <asm/sections.h>
static unsigned int *prof_buffer; static atomic_t *prof_buffer;
static unsigned long prof_len, prof_shift; static unsigned long prof_len, prof_shift;
static int prof_on; static int prof_on;
static cpumask_t prof_cpu_mask = CPU_MASK_ALL; static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
...@@ -40,17 +40,12 @@ __setup("profile=", profile_setup); ...@@ -40,17 +40,12 @@ __setup("profile=", profile_setup);
void __init profile_init(void) void __init profile_init(void)
{ {
unsigned int size;
if (!prof_on) if (!prof_on)
return; return;
/* only text is profiled */ /* only text is profiled */
prof_len = _etext - _stext; prof_len = (_etext - _stext) >> prof_shift;
prof_len >>= prof_shift; prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t));
size = prof_len * sizeof(unsigned int) + PAGE_SIZE - 1;
prof_buffer = (unsigned int *) alloc_bootmem(size);
} }
/* Profile event notifications */ /* Profile event notifications */
...@@ -174,7 +169,7 @@ void profile_hit(int type, void *__pc) ...@@ -174,7 +169,7 @@ void profile_hit(int type, void *__pc)
if (prof_on != type || !prof_buffer) if (prof_on != type || !prof_buffer)
return; return;
pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift; pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
atomic_inc((atomic_t *)&prof_buffer[min(pc, prof_len - 1)]); atomic_inc(&prof_buffer[min(pc, prof_len - 1)]);
} }
void profile_tick(int type, struct pt_regs *regs) void profile_tick(int type, struct pt_regs *regs)
...@@ -252,7 +247,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -252,7 +247,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
put_user(*((char *)(&sample_step)+p),buf); put_user(*((char *)(&sample_step)+p),buf);
buf++; p++; count--; read++; buf++; p++; count--; read++;
} }
pnt = (char *)prof_buffer + p - sizeof(unsigned int); 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;
...@@ -283,7 +278,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf, ...@@ -283,7 +278,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
} }
#endif #endif
memset(prof_buffer, 0, prof_len * sizeof(*prof_buffer)); memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
return count; return count;
} }
......
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