Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b039cb4 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt
Browse files

tracing: Add trace_seq_buffer_ptr() helper function

There's several locations in the kernel that open code the calculation
of the next location in the trace_seq buffer. This is usually done with

  p->buffer + p->len

Instead of having this open coded, supply a helper function in the
header to do it for them. This function is called trace_seq_buffer_ptr().

Link: http://lkml.kernel.org/p/20140626220129.452783019@goodmis.org



Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 3f4d8f78
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@
	__entry->unsync = sp->unsync;
	__entry->unsync = sp->unsync;


#define KVM_MMU_PAGE_PRINTK() ({				        \
#define KVM_MMU_PAGE_PRINTK() ({				        \
	const char *ret = p->buffer + p->len;				\
	const char *ret = trace_seq_buffer_ptr(p);			\
	static const char *access_str[] = {			        \
	static const char *access_str[] = {			        \
		"---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux"  \
		"---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux"  \
	};							        \
	};							        \
+8 −8
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@ scsi_trace_misc(struct trace_seq *, unsigned char *, int);
static const char *
static const char *
scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	sector_t lba = 0, txlen = 0;
	sector_t lba = 0, txlen = 0;


	lba |= ((cdb[1] & 0x1F) << 16);
	lba |= ((cdb[1] & 0x1F) << 16);
@@ -46,7 +46,7 @@ scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	sector_t lba = 0, txlen = 0;
	sector_t lba = 0, txlen = 0;


	lba |= (cdb[2] << 24);
	lba |= (cdb[2] << 24);
@@ -71,7 +71,7 @@ scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	sector_t lba = 0, txlen = 0;
	sector_t lba = 0, txlen = 0;


	lba |= (cdb[2] << 24);
	lba |= (cdb[2] << 24);
@@ -94,7 +94,7 @@ scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	sector_t lba = 0, txlen = 0;
	sector_t lba = 0, txlen = 0;


	lba |= ((u64)cdb[2] << 56);
	lba |= ((u64)cdb[2] << 56);
@@ -125,7 +125,7 @@ scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len, *cmd;
	const char *ret = trace_seq_buffer_ptr(p), *cmd;
	sector_t lba = 0, txlen = 0;
	sector_t lba = 0, txlen = 0;
	u32 ei_lbrt = 0;
	u32 ei_lbrt = 0;


@@ -180,7 +180,7 @@ scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_unmap(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_unmap(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	unsigned int regions = cdb[7] << 8 | cdb[8];
	unsigned int regions = cdb[7] << 8 | cdb[8];


	trace_seq_printf(p, "regions=%u", (regions - 8) / 16);
	trace_seq_printf(p, "regions=%u", (regions - 8) / 16);
@@ -192,7 +192,7 @@ scsi_trace_unmap(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_service_action_in(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_service_action_in(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len, *cmd;
	const char *ret = trace_seq_buffer_ptr(p), *cmd;
	sector_t lba = 0;
	sector_t lba = 0;
	u32 alloc_len = 0;
	u32 alloc_len = 0;


@@ -247,7 +247,7 @@ scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb, int len)
static const char *
static const char *
scsi_trace_misc(struct trace_seq *p, unsigned char *cdb, int len)
scsi_trace_misc(struct trace_seq *p, unsigned char *cdb, int len)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);


	trace_seq_printf(p, "-");
	trace_seq_printf(p, "-");
	trace_seq_putc(p, 0);
	trace_seq_putc(p, 0);
+15 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,21 @@ trace_seq_init(struct trace_seq *s)
	s->full = 0;
	s->full = 0;
}
}


/**
 * trace_seq_buffer_ptr - return pointer to next location in buffer
 * @s: trace sequence descriptor
 *
 * Returns the pointer to the buffer where the next write to
 * the buffer will happen. This is useful to save the location
 * that is about to be written to and then return the result
 * of that write.
 */
static inline unsigned char *
trace_seq_buffer_ptr(struct trace_seq *s)
{
	return s->buffer + s->len;
}

/*
/*
 * Currently only defined when tracing is enabled.
 * Currently only defined when tracing is enabled.
 */
 */
+7 −7
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
{
{
	unsigned long mask;
	unsigned long mask;
	const char *str;
	const char *str;
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);
	int i, first = 1;
	int i, first = 1;


	for (i = 0;  flag_array[i].name && flags; i++) {
	for (i = 0;  flag_array[i].name && flags; i++) {
@@ -111,7 +111,7 @@ ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
			 const struct trace_print_flags *symbol_array)
			 const struct trace_print_flags *symbol_array)
{
{
	int i;
	int i;
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);


	for (i = 0;  symbol_array[i].name; i++) {
	for (i = 0;  symbol_array[i].name; i++) {


@@ -122,7 +122,7 @@ ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
		break;
		break;
	}
	}


	if (ret == (const char *)(p->buffer + p->len))
	if (ret == (const char *)(trace_seq_buffer_ptr(p)))
		trace_seq_printf(p, "0x%lx", val);
		trace_seq_printf(p, "0x%lx", val);
		
		
	trace_seq_putc(p, 0);
	trace_seq_putc(p, 0);
@@ -137,7 +137,7 @@ ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
			 const struct trace_print_flags_u64 *symbol_array)
			 const struct trace_print_flags_u64 *symbol_array)
{
{
	int i;
	int i;
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);


	for (i = 0;  symbol_array[i].name; i++) {
	for (i = 0;  symbol_array[i].name; i++) {


@@ -148,7 +148,7 @@ ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
		break;
		break;
	}
	}


	if (ret == (const char *)(p->buffer + p->len))
	if (ret == (const char *)(trace_seq_buffer_ptr(p)))
		trace_seq_printf(p, "0x%llx", val);
		trace_seq_printf(p, "0x%llx", val);


	trace_seq_putc(p, 0);
	trace_seq_putc(p, 0);
@@ -162,7 +162,7 @@ const char *
ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
			 unsigned int bitmask_size)
			 unsigned int bitmask_size)
{
{
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);


	trace_seq_bitmask(p, bitmask_ptr, bitmask_size * 8);
	trace_seq_bitmask(p, bitmask_ptr, bitmask_size * 8);
	trace_seq_putc(p, 0);
	trace_seq_putc(p, 0);
@@ -175,7 +175,7 @@ const char *
ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
{
{
	int i;
	int i;
	const char *ret = p->buffer + p->len;
	const char *ret = trace_seq_buffer_ptr(p);


	for (i = 0; i < buf_len; i++)
	for (i = 0; i < buf_len; i++)
		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);