Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54277
b: refs/heads/master
c: 542401d
h: refs/heads/master
i:
  54275: e109570
v: v3
  • Loading branch information
Cyrill Gorcunov authored and Linus Torvalds committed May 7, 2007
1 parent 6f10081 commit 7467caa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c65808ef769a486dc0c7c0e79069c06459054631
refs/heads/master: 542401d97a3251ee20d7acb2f3736d0f34b49e64
81 changes: 48 additions & 33 deletions trunk/arch/cris/kernel/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,47 @@ static int prof_running = 0;
void
cris_profile_sample(struct pt_regs* regs)
{
if (!prof_running)
return;
if (user_mode(regs))
*(unsigned int*)sample_buffer_pos = current->pid;
else
*(unsigned int*)sample_buffer_pos = 0;
*(unsigned int*)(sample_buffer_pos + 4) = instruction_pointer(regs);
sample_buffer_pos += 8;
if (sample_buffer_pos == sample_buffer + SAMPLE_BUFFER_SIZE)
sample_buffer_pos = sample_buffer;
if (!prof_running)
return;

if (user_mode(regs))
*(unsigned int*)sample_buffer_pos = current->pid;
else
*(unsigned int*)sample_buffer_pos = 0;

*(unsigned int*)(sample_buffer_pos + 4) = instruction_pointer(regs);
sample_buffer_pos += 8;

if (sample_buffer_pos == sample_buffer + SAMPLE_BUFFER_SIZE)
sample_buffer_pos = sample_buffer;
}

static ssize_t
read_cris_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
read_cris_profile(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
if (p > SAMPLE_BUFFER_SIZE)
return 0;
if (p + count > SAMPLE_BUFFER_SIZE)
count = SAMPLE_BUFFER_SIZE - p;
if (copy_to_user(buf, sample_buffer + p,count))
unsigned long p = *ppos;

if (p > SAMPLE_BUFFER_SIZE)
return 0;

if (p + count > SAMPLE_BUFFER_SIZE)
count = SAMPLE_BUFFER_SIZE - p;
if (copy_to_user(buf, sample_buffer + p,count))
return -EFAULT;
memset(sample_buffer + p, 0, count);
*ppos += count;
return count;

memset(sample_buffer + p, 0, count);
*ppos += count;

return count;
}

static ssize_t
write_cris_profile(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
size_t count, loff_t *ppos)
{
sample_buffer_pos = sample_buffer;
memset(sample_buffer, 0, SAMPLE_BUFFER_SIZE);
sample_buffer_pos = sample_buffer;
memset(sample_buffer, 0, SAMPLE_BUFFER_SIZE);
}

static const struct file_operations cris_proc_profile_operations = {
Expand All @@ -58,16 +66,23 @@ static const struct file_operations cris_proc_profile_operations = {
static int
__init init_cris_profile(void)
{
struct proc_dir_entry *entry;
sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL);
sample_buffer_pos = sample_buffer;
entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL);
if (entry) {
entry->proc_fops = &cris_proc_profile_operations;
entry->size = SAMPLE_BUFFER_SIZE;
}
prof_running = 1;
return 0;
struct proc_dir_entry *entry;

sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL);
if (!sample_buffer) {
return -ENOMEM;
}

sample_buffer_pos = sample_buffer;

entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL);
if (entry) {
entry->proc_fops = &cris_proc_profile_operations;
entry->size = SAMPLE_BUFFER_SIZE;
}
prof_running = 1;

return 0;
}

__initcall(init_cris_profile);

0 comments on commit 7467caa

Please sign in to comment.