public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] perf util: Cleanup trace related files
@ 2013-03-13 11:19 Namhyung Kim
  2013-03-13 11:19 ` [PATCH 1/6] perf util: Remove unused trace_read_data function Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern

Hi,

Here's a couple of cleanups of util/trace-event-* files that inspired
by David Ahern's patchset. :) All look like leftovers from the old
port of trace-cmd codes.

Thanks,
Namhyung


Namhyung Kim (6):
  perf util: Remove unused trace_read_data function
  perf util: Remove unused struct definitions
  perf util: Remove unnecessary calc_data_size variable
  perf util: Remove unused macro definitions
  perf util: Remove duplicated page_size definition
  perf util: Change trace info output file name

 tools/perf/util/trace-event-info.c |  31 +-----
 tools/perf/util/trace-event-read.c | 201 -------------------------------------
 2 files changed, 1 insertion(+), 231 deletions(-)

-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] perf util: Remove unused trace_read_data function
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-21 11:32   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
  2013-03-13 11:19 ` [PATCH 2/6] perf util: Remove unused struct definitions Namhyung Kim
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

And functions that called only from the trace_read_data().

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-read.c | 201 -------------------------------------
 1 file changed, 201 deletions(-)

diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 3741572696af..7cb24635adf2 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -41,8 +41,6 @@
 
 static int input_fd;
 
-static int read_page;
-
 int file_bigendian;
 int host_bigendian;
 static int long_size;
@@ -287,205 +285,6 @@ static void read_event_files(struct pevent *pevent)
 	}
 }
 
-struct cpu_data {
-	unsigned long long	offset;
-	unsigned long long	size;
-	unsigned long long	timestamp;
-	struct pevent_record	*next;
-	char			*page;
-	int			cpu;
-	int			index;
-	int			page_size;
-};
-
-static struct cpu_data *cpu_data;
-
-static void update_cpu_data_index(int cpu)
-{
-	cpu_data[cpu].offset += page_size;
-	cpu_data[cpu].size -= page_size;
-	cpu_data[cpu].index = 0;
-}
-
-static void get_next_page(int cpu)
-{
-	off_t save_seek;
-	off_t ret;
-
-	if (!cpu_data[cpu].page)
-		return;
-
-	if (read_page) {
-		if (cpu_data[cpu].size <= page_size) {
-			free(cpu_data[cpu].page);
-			cpu_data[cpu].page = NULL;
-			return;
-		}
-
-		update_cpu_data_index(cpu);
-
-		/* other parts of the code may expect the pointer to not move */
-		save_seek = lseek(input_fd, 0, SEEK_CUR);
-
-		ret = lseek(input_fd, cpu_data[cpu].offset, SEEK_SET);
-		if (ret == (off_t)-1)
-			die("failed to lseek");
-		ret = read(input_fd, cpu_data[cpu].page, page_size);
-		if (ret < 0)
-			die("failed to read page");
-
-		/* reset the file pointer back */
-		lseek(input_fd, save_seek, SEEK_SET);
-
-		return;
-	}
-
-	munmap(cpu_data[cpu].page, page_size);
-	cpu_data[cpu].page = NULL;
-
-	if (cpu_data[cpu].size <= page_size)
-		return;
-
-	update_cpu_data_index(cpu);
-
-	cpu_data[cpu].page = mmap(NULL, page_size, PROT_READ, MAP_PRIVATE,
-				  input_fd, cpu_data[cpu].offset);
-	if (cpu_data[cpu].page == MAP_FAILED)
-		die("failed to mmap cpu %d at offset 0x%llx",
-		    cpu, cpu_data[cpu].offset);
-}
-
-static unsigned int type_len4host(unsigned int type_len_ts)
-{
-	if (file_bigendian)
-		return (type_len_ts >> 27) & ((1 << 5) - 1);
-	else
-		return type_len_ts & ((1 << 5) - 1);
-}
-
-static unsigned int ts4host(unsigned int type_len_ts)
-{
-	if (file_bigendian)
-		return type_len_ts & ((1 << 27) - 1);
-	else
-		return type_len_ts >> 5;
-}
-
-static int calc_index(void *ptr, int cpu)
-{
-	return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page;
-}
-
-struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu)
-{
-	struct pevent_record *data;
-	void *page = cpu_data[cpu].page;
-	int idx = cpu_data[cpu].index;
-	void *ptr = page + idx;
-	unsigned long long extend;
-	unsigned int type_len_ts;
-	unsigned int type_len;
-	unsigned int delta;
-	unsigned int length = 0;
-
-	if (cpu_data[cpu].next)
-		return cpu_data[cpu].next;
-
-	if (!page)
-		return NULL;
-
-	if (!idx) {
-		/* FIXME: handle header page */
-		if (header_page_ts_size != 8)
-			die("expected a long long type for timestamp");
-		cpu_data[cpu].timestamp = data2host8(pevent, ptr);
-		ptr += 8;
-		switch (header_page_size_size) {
-		case 4:
-			cpu_data[cpu].page_size = data2host4(pevent, ptr);
-			ptr += 4;
-			break;
-		case 8:
-			cpu_data[cpu].page_size = data2host8(pevent, ptr);
-			ptr += 8;
-			break;
-		default:
-			die("bad long size");
-		}
-		ptr = cpu_data[cpu].page + header_page_data_offset;
-	}
-
-read_again:
-	idx = calc_index(ptr, cpu);
-
-	if (idx >= cpu_data[cpu].page_size) {
-		get_next_page(cpu);
-		return trace_peek_data(pevent, cpu);
-	}
-
-	type_len_ts = data2host4(pevent, ptr);
-	ptr += 4;
-
-	type_len = type_len4host(type_len_ts);
-	delta = ts4host(type_len_ts);
-
-	switch (type_len) {
-	case RINGBUF_TYPE_PADDING:
-		if (!delta)
-			die("error, hit unexpected end of page");
-		length = data2host4(pevent, ptr);
-		ptr += 4;
-		length *= 4;
-		ptr += length;
-		goto read_again;
-
-	case RINGBUF_TYPE_TIME_EXTEND:
-		extend = data2host4(pevent, ptr);
-		ptr += 4;
-		extend <<= TS_SHIFT;
-		extend += delta;
-		cpu_data[cpu].timestamp += extend;
-		goto read_again;
-
-	case RINGBUF_TYPE_TIME_STAMP:
-		ptr += 12;
-		break;
-	case 0:
-		length = data2host4(pevent, ptr);
-		ptr += 4;
-		die("here! length=%d", length);
-		break;
-	default:
-		length = type_len * 4;
-		break;
-	}
-
-	cpu_data[cpu].timestamp += delta;
-
-	data = malloc_or_die(sizeof(*data));
-	memset(data, 0, sizeof(*data));
-
-	data->ts = cpu_data[cpu].timestamp;
-	data->size = length;
-	data->data = ptr;
-	ptr += length;
-
-	cpu_data[cpu].index = calc_index(ptr, cpu);
-	cpu_data[cpu].next = data;
-
-	return data;
-}
-
-struct pevent_record *trace_read_data(struct pevent *pevent, int cpu)
-{
-	struct pevent_record *data;
-
-	data = trace_peek_data(pevent, cpu);
-	cpu_data[cpu].next = NULL;
-
-	return data;
-}
-
 ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)
 {
 	char buf[BUFSIZ];
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] perf util: Remove unused struct definitions
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
  2013-03-13 11:19 ` [PATCH 1/6] perf util: Remove unused trace_read_data function Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-21 11:33   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
  2013-03-13 11:19 ` [PATCH 3/6] perf util: Remove unnecessary calc_data_size variable Namhyung Kim
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

struct event_list and struct events are never used.
Just get rid of them.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-info.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 5c1509ab0c29..b0bbd76f4a56 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -55,18 +55,6 @@ unsigned int page_size;
 static const char *output_file = "trace.info";
 static int output_fd;
 
-struct event_list {
-	struct event_list *next;
-	const char *event;
-};
-
-struct events {
-	struct events *sibling;
-	struct events *children;
-	struct events *next;
-	char *name;
-};
-
 
 static void *malloc_or_die(unsigned int size)
 {
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] perf util: Remove unnecessary calc_data_size variable
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
  2013-03-13 11:19 ` [PATCH 1/6] perf util: Remove unused trace_read_data function Namhyung Kim
  2013-03-13 11:19 ` [PATCH 2/6] perf util: Remove unused struct definitions Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-21 11:34   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
  2013-03-13 11:19 ` [PATCH 4/6] perf util: Remove unused macro definitions Namhyung Kim
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

It's not set from anywhere so no need to keep it.  Looks like an
unneeded copy of the same variable in trace-event-read.c

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-info.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index b0bbd76f4a56..783ab51e3ff7 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -119,17 +119,10 @@ static void put_tracing_file(char *file)
 	free(file);
 }
 
-static ssize_t calc_data_size;
-
 static ssize_t write_or_die(const void *buf, size_t len)
 {
 	int ret;
 
-	if (calc_data_size) {
-		calc_data_size += len;
-		return len;
-	}
-
 	ret = write(output_fd, buf, len);
 	if (ret < 0)
 		die("writing to '%s'", output_file);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] perf util: Remove unused macro definitions
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
                   ` (2 preceding siblings ...)
  2013-03-13 11:19 ` [PATCH 3/6] perf util: Remove unnecessary calc_data_size variable Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-21 11:35   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
  2013-03-13 11:19 ` [PATCH 5/6] perf util: Remove duplicated page_size definition Namhyung Kim
  2013-03-13 11:19 ` [PATCH 6/6] perf util: Change trace info output file name Namhyung Kim
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

They're never used and looks like leftovers from the porting of
trace-cmd code.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-info.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 783ab51e3ff7..3c452b587daa 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -43,13 +43,6 @@
 
 #define VERSION "0.5"
 
-#define TRACE_CTRL	"tracing_on"
-#define TRACE		"trace"
-#define AVAILABLE	"available_tracers"
-#define CURRENT		"current_tracer"
-#define ITER_CTRL	"trace_options"
-#define MAX_LATENCY	"tracing_max_latency"
-
 unsigned int page_size;
 
 static const char *output_file = "trace.info";
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] perf util: Remove duplicated page_size definition
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
                   ` (3 preceding siblings ...)
  2013-03-13 11:19 ` [PATCH 4/6] perf util: Remove unused macro definitions Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-21 11:37   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
  2013-03-13 11:19 ` [PATCH 6/6] perf util: Change trace info output file name Namhyung Kim
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

It's defined in util/util.c and gets set from the begining of perf
run.  No need to duplicate it.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-info.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 3c452b587daa..5729f434c5b1 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -43,8 +43,6 @@
 
 #define VERSION "0.5"
 
-unsigned int page_size;
-
 static const char *output_file = "trace.info";
 static int output_fd;
 
@@ -431,7 +429,6 @@ static void tracing_data_header(void)
 	write_or_die(buf, 1);
 
 	/* save page_size */
-	page_size = sysconf(_SC_PAGESIZE);
 	write_or_die(&page_size, 4);
 }
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] perf util: Change trace info output file name
  2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
                   ` (4 preceding siblings ...)
  2013-03-13 11:19 ` [PATCH 5/6] perf util: Remove duplicated page_size definition Namhyung Kim
@ 2013-03-13 11:19 ` Namhyung Kim
  2013-03-13 13:47   ` David Ahern
  5 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2013-03-13 11:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	David Ahern, Steven Rostedt, Frederic Weisbecker

From: Namhyung Kim <namhyung.kim@lge.com>

Not sure it's worth to trouble, but it's obviously has wrong name.
Change it to the default "perf.data".

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/trace-event-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 5729f434c5b1..227f19db3e24 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -43,7 +43,7 @@
 
 #define VERSION "0.5"
 
-static const char *output_file = "trace.info";
+static const char *output_file = "perf.data";
 static int output_fd;
 
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] perf util: Change trace info output file name
  2013-03-13 11:19 ` [PATCH 6/6] perf util: Change trace info output file name Namhyung Kim
@ 2013-03-13 13:47   ` David Ahern
  2013-03-14  8:23     ` Namhyung Kim
  0 siblings, 1 reply; 14+ messages in thread
From: David Ahern @ 2013-03-13 13:47 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras,
	Ingo Molnar, Namhyung Kim, LKML, Steven Rostedt,
	Frederic Weisbecker

On 3/13/13 5:19 AM, Namhyung Kim wrote:
> -static const char *output_file = "trace.info";
> +static const char *output_file = "perf.data";
>   static int output_fd;

Not really needed. Only use is a couple of die() calls. Since the file 
name is not used on the open the die message would be misleading.

David

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] perf util: Change trace info output file name
  2013-03-13 13:47   ` David Ahern
@ 2013-03-14  8:23     ` Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2013-03-14  8:23 UTC (permalink / raw)
  To: David Ahern
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras,
	Ingo Molnar, Namhyung Kim, LKML, Steven Rostedt,
	Frederic Weisbecker

Hi David,

On Wed, 13 Mar 2013 07:47:16 -0600, David Ahern wrote:
> On 3/13/13 5:19 AM, Namhyung Kim wrote:
>> -static const char *output_file = "trace.info";
>> +static const char *output_file = "perf.data";
>>   static int output_fd;
>
> Not really needed. Only use is a couple of die() calls. Since the file
> name is not used on the open the die message would be misleading.

I know.  But it just looked too ugly to me. :)

I'm fine with dropping this one.  I think I'm going to get rid of these
die() and something_or_die() calls soonish..

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [tip:perf/core] perf tools: Remove unused trace_read_data function
  2013-03-13 11:19 ` [PATCH 1/6] perf util: Remove unused trace_read_data function Namhyung Kim
@ 2013-03-21 11:32   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-03-21 11:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, fweisbec, rostedt, dsahern, tglx

Commit-ID:  f3ff40ec8d92b36e60ebbbdb604ffeb5cfe6545f
Gitweb:     http://git.kernel.org/tip/f3ff40ec8d92b36e60ebbbdb604ffeb5cfe6545f
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 13 Mar 2013 20:19:40 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:08 -0300

perf tools: Remove unused trace_read_data function

And functions that called only from the trace_read_data().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363173585-9754-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-read.c | 201 -------------------------------------
 1 file changed, 201 deletions(-)

diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 3741572..7cb2463 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -41,8 +41,6 @@
 
 static int input_fd;
 
-static int read_page;
-
 int file_bigendian;
 int host_bigendian;
 static int long_size;
@@ -287,205 +285,6 @@ static void read_event_files(struct pevent *pevent)
 	}
 }
 
-struct cpu_data {
-	unsigned long long	offset;
-	unsigned long long	size;
-	unsigned long long	timestamp;
-	struct pevent_record	*next;
-	char			*page;
-	int			cpu;
-	int			index;
-	int			page_size;
-};
-
-static struct cpu_data *cpu_data;
-
-static void update_cpu_data_index(int cpu)
-{
-	cpu_data[cpu].offset += page_size;
-	cpu_data[cpu].size -= page_size;
-	cpu_data[cpu].index = 0;
-}
-
-static void get_next_page(int cpu)
-{
-	off_t save_seek;
-	off_t ret;
-
-	if (!cpu_data[cpu].page)
-		return;
-
-	if (read_page) {
-		if (cpu_data[cpu].size <= page_size) {
-			free(cpu_data[cpu].page);
-			cpu_data[cpu].page = NULL;
-			return;
-		}
-
-		update_cpu_data_index(cpu);
-
-		/* other parts of the code may expect the pointer to not move */
-		save_seek = lseek(input_fd, 0, SEEK_CUR);
-
-		ret = lseek(input_fd, cpu_data[cpu].offset, SEEK_SET);
-		if (ret == (off_t)-1)
-			die("failed to lseek");
-		ret = read(input_fd, cpu_data[cpu].page, page_size);
-		if (ret < 0)
-			die("failed to read page");
-
-		/* reset the file pointer back */
-		lseek(input_fd, save_seek, SEEK_SET);
-
-		return;
-	}
-
-	munmap(cpu_data[cpu].page, page_size);
-	cpu_data[cpu].page = NULL;
-
-	if (cpu_data[cpu].size <= page_size)
-		return;
-
-	update_cpu_data_index(cpu);
-
-	cpu_data[cpu].page = mmap(NULL, page_size, PROT_READ, MAP_PRIVATE,
-				  input_fd, cpu_data[cpu].offset);
-	if (cpu_data[cpu].page == MAP_FAILED)
-		die("failed to mmap cpu %d at offset 0x%llx",
-		    cpu, cpu_data[cpu].offset);
-}
-
-static unsigned int type_len4host(unsigned int type_len_ts)
-{
-	if (file_bigendian)
-		return (type_len_ts >> 27) & ((1 << 5) - 1);
-	else
-		return type_len_ts & ((1 << 5) - 1);
-}
-
-static unsigned int ts4host(unsigned int type_len_ts)
-{
-	if (file_bigendian)
-		return type_len_ts & ((1 << 27) - 1);
-	else
-		return type_len_ts >> 5;
-}
-
-static int calc_index(void *ptr, int cpu)
-{
-	return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page;
-}
-
-struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu)
-{
-	struct pevent_record *data;
-	void *page = cpu_data[cpu].page;
-	int idx = cpu_data[cpu].index;
-	void *ptr = page + idx;
-	unsigned long long extend;
-	unsigned int type_len_ts;
-	unsigned int type_len;
-	unsigned int delta;
-	unsigned int length = 0;
-
-	if (cpu_data[cpu].next)
-		return cpu_data[cpu].next;
-
-	if (!page)
-		return NULL;
-
-	if (!idx) {
-		/* FIXME: handle header page */
-		if (header_page_ts_size != 8)
-			die("expected a long long type for timestamp");
-		cpu_data[cpu].timestamp = data2host8(pevent, ptr);
-		ptr += 8;
-		switch (header_page_size_size) {
-		case 4:
-			cpu_data[cpu].page_size = data2host4(pevent, ptr);
-			ptr += 4;
-			break;
-		case 8:
-			cpu_data[cpu].page_size = data2host8(pevent, ptr);
-			ptr += 8;
-			break;
-		default:
-			die("bad long size");
-		}
-		ptr = cpu_data[cpu].page + header_page_data_offset;
-	}
-
-read_again:
-	idx = calc_index(ptr, cpu);
-
-	if (idx >= cpu_data[cpu].page_size) {
-		get_next_page(cpu);
-		return trace_peek_data(pevent, cpu);
-	}
-
-	type_len_ts = data2host4(pevent, ptr);
-	ptr += 4;
-
-	type_len = type_len4host(type_len_ts);
-	delta = ts4host(type_len_ts);
-
-	switch (type_len) {
-	case RINGBUF_TYPE_PADDING:
-		if (!delta)
-			die("error, hit unexpected end of page");
-		length = data2host4(pevent, ptr);
-		ptr += 4;
-		length *= 4;
-		ptr += length;
-		goto read_again;
-
-	case RINGBUF_TYPE_TIME_EXTEND:
-		extend = data2host4(pevent, ptr);
-		ptr += 4;
-		extend <<= TS_SHIFT;
-		extend += delta;
-		cpu_data[cpu].timestamp += extend;
-		goto read_again;
-
-	case RINGBUF_TYPE_TIME_STAMP:
-		ptr += 12;
-		break;
-	case 0:
-		length = data2host4(pevent, ptr);
-		ptr += 4;
-		die("here! length=%d", length);
-		break;
-	default:
-		length = type_len * 4;
-		break;
-	}
-
-	cpu_data[cpu].timestamp += delta;
-
-	data = malloc_or_die(sizeof(*data));
-	memset(data, 0, sizeof(*data));
-
-	data->ts = cpu_data[cpu].timestamp;
-	data->size = length;
-	data->data = ptr;
-	ptr += length;
-
-	cpu_data[cpu].index = calc_index(ptr, cpu);
-	cpu_data[cpu].next = data;
-
-	return data;
-}
-
-struct pevent_record *trace_read_data(struct pevent *pevent, int cpu)
-{
-	struct pevent_record *data;
-
-	data = trace_peek_data(pevent, cpu);
-	cpu_data[cpu].next = NULL;
-
-	return data;
-}
-
 ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)
 {
 	char buf[BUFSIZ];

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] perf tools: Remove unused struct definitions
  2013-03-13 11:19 ` [PATCH 2/6] perf util: Remove unused struct definitions Namhyung Kim
@ 2013-03-21 11:33   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-03-21 11:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, fweisbec, rostedt, dsahern, tglx

Commit-ID:  d301de830d89454a47947e9a3851708e8f3a8822
Gitweb:     http://git.kernel.org/tip/d301de830d89454a47947e9a3851708e8f3a8822
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 13 Mar 2013 20:19:41 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:09 -0300

perf tools: Remove unused struct definitions

struct event_list and struct events are never used.

Just get rid of them.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363173585-9754-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-info.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 5c1509a..b0bbd76 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -55,18 +55,6 @@ unsigned int page_size;
 static const char *output_file = "trace.info";
 static int output_fd;
 
-struct event_list {
-	struct event_list *next;
-	const char *event;
-};
-
-struct events {
-	struct events *sibling;
-	struct events *children;
-	struct events *next;
-	char *name;
-};
-
 
 static void *malloc_or_die(unsigned int size)
 {

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] perf tools: Remove unnecessary calc_data_size variable
  2013-03-13 11:19 ` [PATCH 3/6] perf util: Remove unnecessary calc_data_size variable Namhyung Kim
@ 2013-03-21 11:34   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-03-21 11:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, fweisbec, rostedt, dsahern, tglx

Commit-ID:  024b13082e9d4a50f2d39c5fe2d1179261e7aa22
Gitweb:     http://git.kernel.org/tip/024b13082e9d4a50f2d39c5fe2d1179261e7aa22
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 13 Mar 2013 20:19:42 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:09 -0300

perf tools: Remove unnecessary calc_data_size variable

It's not set from anywhere so no need to keep it.  Looks like an
unneeded copy of the same variable in trace-event-read.c

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363173585-9754-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-info.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index b0bbd76..783ab51 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -119,17 +119,10 @@ static void put_tracing_file(char *file)
 	free(file);
 }
 
-static ssize_t calc_data_size;
-
 static ssize_t write_or_die(const void *buf, size_t len)
 {
 	int ret;
 
-	if (calc_data_size) {
-		calc_data_size += len;
-		return len;
-	}
-
 	ret = write(output_fd, buf, len);
 	if (ret < 0)
 		die("writing to '%s'", output_file);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] perf tools: Remove unused macro definitions
  2013-03-13 11:19 ` [PATCH 4/6] perf util: Remove unused macro definitions Namhyung Kim
@ 2013-03-21 11:35   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-03-21 11:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, fweisbec, rostedt, dsahern, tglx

Commit-ID:  e5f5e5ee78457198184abf3e43d95ea0fab21272
Gitweb:     http://git.kernel.org/tip/e5f5e5ee78457198184abf3e43d95ea0fab21272
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 13 Mar 2013 20:19:43 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:09 -0300

perf tools: Remove unused macro definitions

They're never used and looks like leftovers from the porting of
trace-cmd code.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363173585-9754-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-info.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 783ab51..3c452b5 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -43,13 +43,6 @@
 
 #define VERSION "0.5"
 
-#define TRACE_CTRL	"tracing_on"
-#define TRACE		"trace"
-#define AVAILABLE	"available_tracers"
-#define CURRENT		"current_tracer"
-#define ITER_CTRL	"trace_options"
-#define MAX_LATENCY	"tracing_max_latency"
-
 unsigned int page_size;
 
 static const char *output_file = "trace.info";

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] perf tools: Remove duplicated page_size definition
  2013-03-13 11:19 ` [PATCH 5/6] perf util: Remove duplicated page_size definition Namhyung Kim
@ 2013-03-21 11:37   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-03-21 11:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, fweisbec, rostedt, dsahern, tglx

Commit-ID:  45fa534cffb246872de0cb8af207bea4a09aeb2f
Gitweb:     http://git.kernel.org/tip/45fa534cffb246872de0cb8af207bea4a09aeb2f
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 13 Mar 2013 20:19:44 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:09 -0300

perf tools: Remove duplicated page_size definition

It's defined in util/util.c and gets set from the begining of perf run.
No need to duplicate it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363173585-9754-6-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-info.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 3c452b5..5729f43 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -43,8 +43,6 @@
 
 #define VERSION "0.5"
 
-unsigned int page_size;
-
 static const char *output_file = "trace.info";
 static int output_fd;
 
@@ -431,7 +429,6 @@ static void tracing_data_header(void)
 	write_or_die(buf, 1);
 
 	/* save page_size */
-	page_size = sysconf(_SC_PAGESIZE);
 	write_or_die(&page_size, 4);
 }
 

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-03-21 11:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 11:19 [PATCH 0/6] perf util: Cleanup trace related files Namhyung Kim
2013-03-13 11:19 ` [PATCH 1/6] perf util: Remove unused trace_read_data function Namhyung Kim
2013-03-21 11:32   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
2013-03-13 11:19 ` [PATCH 2/6] perf util: Remove unused struct definitions Namhyung Kim
2013-03-21 11:33   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
2013-03-13 11:19 ` [PATCH 3/6] perf util: Remove unnecessary calc_data_size variable Namhyung Kim
2013-03-21 11:34   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
2013-03-13 11:19 ` [PATCH 4/6] perf util: Remove unused macro definitions Namhyung Kim
2013-03-21 11:35   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
2013-03-13 11:19 ` [PATCH 5/6] perf util: Remove duplicated page_size definition Namhyung Kim
2013-03-21 11:37   ` [tip:perf/core] perf tools: " tip-bot for Namhyung Kim
2013-03-13 11:19 ` [PATCH 6/6] perf util: Change trace info output file name Namhyung Kim
2013-03-13 13:47   ` David Ahern
2013-03-14  8:23     ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox