/* Use oprofile_add_data(&entry, val) to add data and oprofile_write_commit(&entry) to commit the sample.  */
void oprofile_write_reserve(struct op_entry *entry, struct pt_regs *const regs, unsigned long pc, int code, int size)
/* Use oprofile_add_data(&entry, val) to add data and oprofile_write_commit(&entry) to commit the sample.  */
void oprofile_write_reserve(struct op_entry *entry, struct pt_regs *const regs, unsigned long pc, int code, int size)
{
	struct op_sample *sample;
	int is_kernel = !user_mode(regs);
	struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
	cpu_buf->sample_received++;
	if (op_add_code(cpu_buf, 0, is_kernel, current))
		goto fail;
	sample = op_cpu_buffer_write_reserve(entry, size + 2);
	if (!sample)
		goto fail;
	sample->eip = ESCAPE_CODE;
	sample->event = 0;
	op_cpu_buffer_add_data(entry, code);
	op_cpu_buffer_add_data(entry, pc);
	return;
fail:
	entry->event = NULL;
	cpu_buf->sample_lost_overflow++;
}