Skip to content

Commit

Permalink
x86/oprofile: introduce oprofile_add_data64()
Browse files Browse the repository at this point in the history
The IBS implemention writes 64 bit register values to the cpu buffer
by writing two 32 values using oprofile_add_data(). This patch
introduces oprofile_add_data64() to write a single 64 bit value to the
buffer.

Signed-off-by: Robert Richter <robert.richter@amd.com>
  • Loading branch information
Robert Richter committed Jun 11, 2009
1 parent c572ae4 commit 51563a0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
27 changes: 9 additions & 18 deletions arch/x86/oprofile/op_model_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,10 @@ op_amd_handle_ibs(struct pt_regs * const regs,
rdmsrl(MSR_AMD64_IBSFETCHLINAD, val);
oprofile_write_reserve(&entry, regs, val,
IBS_FETCH_CODE, IBS_FETCH_SIZE);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data(&entry, (u32)ctl);
oprofile_add_data(&entry, (u32)(ctl >> 32));
oprofile_add_data64(&entry, val);
oprofile_add_data64(&entry, ctl);
rdmsrl(MSR_AMD64_IBSFETCHPHYSAD, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
oprofile_write_commit(&entry);

/* reenable the IRQ */
Expand All @@ -162,23 +159,17 @@ op_amd_handle_ibs(struct pt_regs * const regs,
rdmsrl(MSR_AMD64_IBSOPRIP, val);
oprofile_write_reserve(&entry, regs, val,
IBS_OP_CODE, IBS_OP_SIZE);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
rdmsrl(MSR_AMD64_IBSOPDATA, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
rdmsrl(MSR_AMD64_IBSOPDATA2, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
rdmsrl(MSR_AMD64_IBSOPDATA3, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
rdmsrl(MSR_AMD64_IBSDCLINAD, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
rdmsrl(MSR_AMD64_IBSDCPHYSAD, val);
oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data64(&entry, val);
oprofile_write_commit(&entry);

/* reenable the IRQ */
Expand Down
15 changes: 15 additions & 0 deletions drivers/oprofile/cpu_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,21 @@ int oprofile_add_data(struct op_entry *entry, unsigned long val)
return op_cpu_buffer_add_data(entry, val);
}

int oprofile_add_data64(struct op_entry *entry, u64 val)
{
if (!entry->event)
return 0;
if (op_cpu_buffer_get_size(entry) < 2)
/*
* the function returns 0 to indicate a too small
* buffer, even if there is some space left
*/
return 0;
if (!op_cpu_buffer_add_data(entry, (u32)val))
return 0;
return op_cpu_buffer_add_data(entry, (u32)(val >> 32));
}

int oprofile_write_commit(struct op_entry *entry)
{
if (!entry->event)
Expand Down
1 change: 1 addition & 0 deletions include/linux/oprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void oprofile_write_reserve(struct op_entry *entry,
struct pt_regs * const regs,
unsigned long pc, int code, int size);
int oprofile_add_data(struct op_entry *entry, unsigned long val);
int oprofile_add_data64(struct op_entry *entry, u64 val);
int oprofile_write_commit(struct op_entry *entry);

#endif /* OPROFILE_H */

0 comments on commit 51563a0

Please sign in to comment.