All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
@ 2012-06-18  2:50 Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 2/5] tools lib traceevent: Do not link broken field arg for an old ftrace event Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-06-18  2:50 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

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

Because the only caller of the alloc_event()
(pevent_parse_event) checks return value properly
and all it does after allocation is initializing,
it can be changed to use plain calloc.

Thanks to Steven for suggesting this simpler way.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-wagq5qbdy1mytvjkrjbqt095@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/event-parse.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index c471075e4974..4f667fdc5fae 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -619,12 +619,7 @@ void pevent_print_printk(struct pevent *pevent)
 
 static struct event_format *alloc_event(void)
 {
-	struct event_format *event;
-
-	event = malloc_or_die(sizeof(*event));
-	memset(event, 0, sizeof(*event));
-
-	return event;
+	return calloc(1, sizeof(struct event_format));
 }
 
 static void add_event(struct pevent *pevent, struct event_format *event)
-- 
1.7.10.2


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

* [PATCH v2 2/5] tools lib traceevent: Do not link broken field arg for an old ftrace event
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
@ 2012-06-18  2:50 ` Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 3/5] tools lib traceevent: Introduce pevent_errno Namhyung Kim
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-06-18  2:50 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

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

Defer linking a newly allocated arg to print_fmt.args until
all of its field is setup so that later access to ->field.name
cannot be NULL.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-7zlkindw0qqqe5h117u59ood@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/event-parse.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 4f667fdc5fae..ae172e2ee958 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4658,20 +4658,20 @@ int pevent_parse_event(struct pevent *pevent,
 		struct print_arg *arg, **list;
 
 		/* old ftrace had no args */
-
 		list = &event->print_fmt.args;
 		for (field = event->format.fields; field; field = field->next) {
 			arg = alloc_arg();
-			*list = arg;
-			list = &arg->next;
 			arg->type = PRINT_FIELD;
 			arg->field.name = strdup(field->name);
 			if (!arg->field.name) {
 				do_warning("failed to allocate field name");
 				event->flags |= EVENT_FL_FAILED;
+				free_arg(arg);
 				return -1;
 			}
 			arg->field.field = field;
+			*list = arg;
+			list = &arg->next;
 		}
 		return 0;
 	}
-- 
1.7.10.2


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

* [PATCH v2 3/5] tools lib traceevent: Introduce pevent_errno
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 2/5] tools lib traceevent: Do not link broken field arg for an old ftrace event Namhyung Kim
@ 2012-06-18  2:50 ` Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror Namhyung Kim
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-06-18  2:50 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

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

Define and use error numbers for pevent_parse_event()
and get rid of die() and do_warning() calls. If the
function returns non-zero value, the caller can check
the return code and do appropriate things.

I chose the error numbers to be negative not to clash
with standard errno, and as usual, 0 for success.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-gnepcf1hycmm0cpejr7ipumn@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/event-parse.c |   50 +++++++++++++++++++++---------------
 tools/lib/traceevent/event-parse.h |   26 +++++++++++++++++--
 2 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index ae172e2ee958..2ad529367886 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4590,9 +4590,8 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event)
  *
  * /sys/kernel/debug/tracing/events/.../.../format
  */
-int pevent_parse_event(struct pevent *pevent,
-		       const char *buf, unsigned long size,
-		       const char *sys)
+enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
+				     unsigned long size, const char *sys)
 {
 	struct event_format *event;
 	int ret;
@@ -4601,17 +4600,16 @@ int pevent_parse_event(struct pevent *pevent,
 
 	event = alloc_event();
 	if (!event)
-		return -ENOMEM;
+		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
 	event->name = event_read_name();
 	if (!event->name) {
 		/* Bad event? */
-		free(event);
-		return -1;
+		ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
+		goto event_alloc_failed;
 	}
 
 	if (strcmp(sys, "ftrace") == 0) {
-
 		event->flags |= EVENT_FL_ISFTRACE;
 
 		if (strcmp(event->name, "bprint") == 0)
@@ -4619,20 +4617,28 @@ int pevent_parse_event(struct pevent *pevent,
 	}
 		
 	event->id = event_read_id();
-	if (event->id < 0)
-		die("failed to read event id");
+	if (event->id < 0) {
+		ret = PEVENT_ERRNO__READ_ID_FAILED;
+		/*
+		 * This isn't an allocation error actually.
+		 * But as the ID is critical, just bail out.
+		 */
+		goto event_alloc_failed;
+	}
 
 	event->system = strdup(sys);
-	if (!event->system)
-		die("failed to allocate system");
+	if (!event->system) {
+		ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
+		goto event_alloc_failed;
+	}
 
 	/* Add pevent to event so that it can be referenced */
 	event->pevent = pevent;
 
 	ret = event_read_format(event);
 	if (ret < 0) {
-		do_warning("failed to read event format for %s", event->name);
-		goto event_failed;
+		ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
+		goto event_parse_failed;
 	}
 
 	/*
@@ -4644,10 +4650,9 @@ int pevent_parse_event(struct pevent *pevent,
 
 	ret = event_read_print(event);
 	if (ret < 0) {
-		do_warning("failed to read event print fmt for %s",
-			   event->name);
 		show_warning = 1;
-		goto event_failed;
+		ret = PEVENT_ERRNO__READ_PRINT_FAILED;
+		goto event_parse_failed;
 	}
 	show_warning = 1;
 
@@ -4664,10 +4669,9 @@ int pevent_parse_event(struct pevent *pevent,
 			arg->type = PRINT_FIELD;
 			arg->field.name = strdup(field->name);
 			if (!arg->field.name) {
-				do_warning("failed to allocate field name");
 				event->flags |= EVENT_FL_FAILED;
 				free_arg(arg);
-				return -1;
+				return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED;
 			}
 			arg->field.field = field;
 			*list = arg;
@@ -4682,11 +4686,17 @@ int pevent_parse_event(struct pevent *pevent,
 
 	return 0;
 
- event_failed:
+ event_parse_failed:
 	event->flags |= EVENT_FL_FAILED;
 	/* still add it even if it failed */
 	add_event(pevent, event);
-	return -1;
+	return ret;
+
+ event_alloc_failed:
+	free(event->system);
+	free(event->name);
+	free(event);
+	return ret;
 }
 
 int get_field_val(struct trace_seq *s, struct format_field *field,
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index ac997bc7b592..24b7649d530b 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -338,6 +338,28 @@ enum pevent_flag {
 	PEVENT_NSEC_OUTPUT		= 1,	/* output in NSECS */
 };
 
+enum pevent_errno {
+	PEVENT_ERRNO__SUCCESS			= 0,
+
+	/*
+	 * Choose an arbitrary negative big number not to clash with standard
+	 * errno since SUS requires the errno has distinct positive values.
+	 * See 'Issue 6' in the link below.
+	 *
+	 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
+	 */
+	__PEVENT_ERRNO__START			= -100000,
+
+	PEVENT_ERRNO__MEM_ALLOC_FAILED		= __PEVENT_ERRNO__START,
+	PEVENT_ERRNO__PARSE_EVENT_FAILED,
+	PEVENT_ERRNO__READ_ID_FAILED,
+	PEVENT_ERRNO__READ_FORMAT_FAILED,
+	PEVENT_ERRNO__READ_PRINT_FAILED,
+	PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED,
+
+	__PEVENT_ERRNO__END,
+};
+
 struct cmdline;
 struct cmdline_list;
 struct func_map;
@@ -502,8 +524,8 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
 int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
 			     int long_size);
 
-int pevent_parse_event(struct pevent *pevent, const char *buf,
-		       unsigned long size, const char *sys);
+enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
+				     unsigned long size, const char *sys);
 
 void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
 			   const char *name, struct pevent_record *record,
-- 
1.7.10.2


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

* [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 2/5] tools lib traceevent: Do not link broken field arg for an old ftrace event Namhyung Kim
  2012-06-18  2:50 ` [PATCH v2 3/5] tools lib traceevent: Introduce pevent_errno Namhyung Kim
@ 2012-06-18  2:50 ` Namhyung Kim
  2012-06-18 13:41   ` Steven Rostedt
  2012-06-18  2:50 ` [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-06-18  2:50 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

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

The pevent_strerror() sets @buf to a string that describes the
(libtraceevent-specific) error condition that is passed via @errnum.

This is similar to strerror_r() and does same thing if @errnum has a
standard errno value.

To sync error string with its code, define PEVENT_ERRORS with _PE()
macro and use it as suggested by Steven.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-hlenk1kvu9igyqowtm2okpz6@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/event-parse.c |   43 ++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/event-parse.h |   20 ++++++++++++-----
 2 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 2ad529367886..853b604b6240 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4699,6 +4699,49 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
 	return ret;
 }
 
+#undef _PE
+#define _PE(code, str) str
+static const char * const pevent_error_str[] = {
+	PEVENT_ERRORS
+};
+#undef _PE
+
+int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
+		    char *buf, size_t buflen)
+{
+	int idx;
+	const char *msg;
+
+	if (errnum >= 0) {
+		strerror_r(errnum, buf, buflen);
+		return 0;
+	}
+
+	if (errnum <= __PEVENT_ERRNO__START ||
+	    errnum >= __PEVENT_ERRNO__END)
+		return -1;
+
+	idx = errnum - __PEVENT_ERRNO__START;
+	msg = pevent_error_str[idx];
+
+	switch (errnum) {
+	case PEVENT_ERRNO__MEM_ALLOC_FAILED:
+	case PEVENT_ERRNO__PARSE_EVENT_FAILED:
+	case PEVENT_ERRNO__READ_ID_FAILED:
+	case PEVENT_ERRNO__READ_FORMAT_FAILED:
+	case PEVENT_ERRNO__READ_PRINT_FAILED:
+	case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED:
+		snprintf(buf, buflen, "%s", msg);
+		break;
+
+	default:
+		/* cannot reach here */
+		break;
+	}
+
+	return 0;
+}
+
 int get_field_val(struct trace_seq *s, struct format_field *field,
 		  const char *name, struct pevent_record *record,
 		  unsigned long long *val, int err)
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 24b7649d530b..a8121d78a046 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -338,6 +338,16 @@ enum pevent_flag {
 	PEVENT_NSEC_OUTPUT		= 1,	/* output in NSECS */
 };
 
+#define PEVENT_ERRORS 							      \
+	_PE(MEM_ALLOC_FAILED,	"failed to allocate memory"),		      \
+	_PE(PARSE_EVENT_FAILED,	"failed to parse event"),		      \
+	_PE(READ_ID_FAILED,	"failed to read event id"),		      \
+	_PE(READ_FORMAT_FAILED,	"failed to read event format"),		      \
+	_PE(READ_PRINT_FAILED,	"failed to read event print fmt"), 	      \
+	_PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace")
+
+#undef _PE
+#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
 enum pevent_errno {
 	PEVENT_ERRNO__SUCCESS			= 0,
 
@@ -350,15 +360,11 @@ enum pevent_errno {
 	 */
 	__PEVENT_ERRNO__START			= -100000,
 
-	PEVENT_ERRNO__MEM_ALLOC_FAILED		= __PEVENT_ERRNO__START,
-	PEVENT_ERRNO__PARSE_EVENT_FAILED,
-	PEVENT_ERRNO__READ_ID_FAILED,
-	PEVENT_ERRNO__READ_FORMAT_FAILED,
-	PEVENT_ERRNO__READ_PRINT_FAILED,
-	PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED,
+	PEVENT_ERRORS,
 
 	__PEVENT_ERRNO__END,
 };
+#undef _PE
 
 struct cmdline;
 struct cmdline_list;
@@ -576,6 +582,8 @@ int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
 const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
 void pevent_event_info(struct trace_seq *s, struct event_format *event,
 		       struct pevent_record *record);
+int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
+		    char *buf, size_t buflen);
 
 struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type);
 struct format_field **pevent_event_common_fields(struct event_format *event);
-- 
1.7.10.2


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

* [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
                   ` (2 preceding siblings ...)
  2012-06-18  2:50 ` [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror Namhyung Kim
@ 2012-06-18  2:50 ` Namhyung Kim
  2012-06-18 13:44   ` Steven Rostedt
  2012-07-26 12:24   ` Michal Marek
  2012-06-18 13:37 ` [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Steven Rostedt
  2012-06-18 13:45 ` Steven Rostedt
  5 siblings, 2 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-06-18  2:50 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML,
	Namhyung Kim, Michal Marek

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

As we use a macro trick to sync each error codes with its
description string, teach [ce]tags to process them properly.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Michal Marek <mmarek@suse.cz>
Link: http://lkml.kernel.org/n/tip-qt5fv4pzigr2nnl27ydimg4h@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 scripts/tags.sh |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index cf7b12fee573..cff8faad73d1 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -153,7 +153,8 @@ exuberant()
 	--regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'	\
 	--regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/'	\
 	--regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
-	--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/'
+	--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
+	--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
 	all_kconfigs | xargs $1 -a                              \
 	--langdef=kconfig --language-force=kconfig              \
@@ -195,7 +196,8 @@ emacs()
 	--regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'	\
 	--regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
 	--regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
-	--regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/'
+	--regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
+	--regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
 	all_kconfigs | xargs $1 -a                              \
 	--regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
-- 
1.7.10.2


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

* Re: [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
                   ` (3 preceding siblings ...)
  2012-06-18  2:50 ` [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
@ 2012-06-18 13:37 ` Steven Rostedt
  2012-06-18 13:45 ` Steven Rostedt
  5 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-06-18 13:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Frederic Weisbecker, Peter Zijlstra,
	Ingo Molnar, LKML, Namhyung Kim

On Mon, 2012-06-18 at 11:50 +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> Because the only caller of the alloc_event()
> (pevent_parse_event) checks return value properly
> and all it does after allocation is initializing,
> it can be changed to use plain calloc.
> 
> Thanks to Steven for suggesting this simpler way.
> 
> Cc: Frederic Weisbecker <fweisbec@gmail.com>

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve


> Link: http://lkml.kernel.org/n/tip-wagq5qbdy1mytvjkrjbqt095@git.kernel.org
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/lib/traceevent/event-parse.c |    7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index c471075e4974..4f667fdc5fae 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -619,12 +619,7 @@ void pevent_print_printk(struct pevent *pevent)
>  
>  static struct event_format *alloc_event(void)
>  {
> -	struct event_format *event;
> -
> -	event = malloc_or_die(sizeof(*event));
> -	memset(event, 0, sizeof(*event));
> -
> -	return event;
> +	return calloc(1, sizeof(struct event_format));
>  }
>  
>  static void add_event(struct pevent *pevent, struct event_format *event)



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

* Re: [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror
  2012-06-18  2:50 ` [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror Namhyung Kim
@ 2012-06-18 13:41   ` Steven Rostedt
  0 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-06-18 13:41 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Frederic Weisbecker, Peter Zijlstra,
	Ingo Molnar, LKML, Namhyung Kim

On Mon, 2012-06-18 at 11:50 +0900, Namhyung Kim wrote:

> +	if (errnum <= __PEVENT_ERRNO__START ||
> +	    errnum >= __PEVENT_ERRNO__END)
> +		return -1;

OK, so you changed it to have both START and END be exclusive in the
range. No more 'MEM_ALLOC_FAILED = START'.

> +
> +	idx = errnum - __PEVENT_ERRNO__START;
> +	msg = pevent_error_str[idx];
> +
> +	switch (errnum) {
> +	case PEVENT_ERRNO__MEM_ALLOC_FAILED:
> +	case PEVENT_ERRNO__PARSE_EVENT_FAILED:
> +	case PEVENT_ERRNO__READ_ID_FAILED:
> +	case PEVENT_ERRNO__READ_FORMAT_FAILED:
> +	case PEVENT_ERRNO__READ_PRINT_FAILED:
> +	case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED:
> +		snprintf(buf, buflen, "%s", msg);
> +		break;
> +
> +	default:
> +		/* cannot reach here */
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
>  int get_field_val(struct trace_seq *s, struct format_field *field,
>  		  const char *name, struct pevent_record *record,
>  		  unsigned long long *val, int err)
> diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
> index 24b7649d530b..a8121d78a046 100644
> --- a/tools/lib/traceevent/event-parse.h
> +++ b/tools/lib/traceevent/event-parse.h
> @@ -338,6 +338,16 @@ enum pevent_flag {
>  	PEVENT_NSEC_OUTPUT		= 1,	/* output in NSECS */
>  };
>  
> +#define PEVENT_ERRORS 							      \
> +	_PE(MEM_ALLOC_FAILED,	"failed to allocate memory"),		      \
> +	_PE(PARSE_EVENT_FAILED,	"failed to parse event"),		      \
> +	_PE(READ_ID_FAILED,	"failed to read event id"),		      \
> +	_PE(READ_FORMAT_FAILED,	"failed to read event format"),		      \
> +	_PE(READ_PRINT_FAILED,	"failed to read event print fmt"), 	      \
> +	_PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace")
> +
> +#undef _PE
> +#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
>  enum pevent_errno {
>  	PEVENT_ERRNO__SUCCESS			= 0,
>  
> @@ -350,15 +360,11 @@ enum pevent_errno {
>  	 */
>  	__PEVENT_ERRNO__START			= -100000,
>  
> -	PEVENT_ERRNO__MEM_ALLOC_FAILED		= __PEVENT_ERRNO__START,
> -	PEVENT_ERRNO__PARSE_EVENT_FAILED,
> -	PEVENT_ERRNO__READ_ID_FAILED,
> -	PEVENT_ERRNO__READ_FORMAT_FAILED,
> -	PEVENT_ERRNO__READ_PRINT_FAILED,
> -	PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED,
> +	PEVENT_ERRORS,
>  

Looks good.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

>  	__PEVENT_ERRNO__END,
>  };
> +#undef _PE
>  
>  struct cmdline;
>  struct cmdline_list;
> @@ -576,6 +582,8 @@ int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
>  const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
>  void pevent_event_info(struct trace_seq *s, struct event_format *event,
>  		       struct pevent_record *record);
> +int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
> +		    char *buf, size_t buflen);
>  
>  struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type);
>  struct format_field **pevent_event_common_fields(struct event_format *event);



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

* Re: [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes
  2012-06-18  2:50 ` [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
@ 2012-06-18 13:44   ` Steven Rostedt
  2012-07-26 12:24   ` Michal Marek
  1 sibling, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-06-18 13:44 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Frederic Weisbecker, Peter Zijlstra,
	Ingo Molnar, LKML, Namhyung Kim, Michal Marek

On Mon, 2012-06-18 at 11:50 +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> As we use a macro trick to sync each error codes with its
> description string, teach [ce]tags to process them properly.
> 
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Michal Marek <mmarek@suse.cz>
> Link: http://lkml.kernel.org/n/tip-qt5fv4pzigr2nnl27ydimg4h@git.kernel.org
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  scripts/tags.sh |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/tags.sh b/scripts/tags.sh
> index cf7b12fee573..cff8faad73d1 100755
> --- a/scripts/tags.sh
> +++ b/scripts/tags.sh
> @@ -153,7 +153,8 @@ exuberant()
>  	--regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'	\
>  	--regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/'	\
>  	--regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
> -	--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/'
> +	--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
> +	--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
>  
>  	all_kconfigs | xargs $1 -a                              \
>  	--langdef=kconfig --language-force=kconfig              \
> @@ -195,7 +196,8 @@ emacs()
>  	--regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'	\
>  	--regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
>  	--regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
> -	--regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/'
> +	--regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
> +	--regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
>  
>  	all_kconfigs | xargs $1 -a                              \
>  	--regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'


This works great if we run tags from the top level kernel tree, but we
need to also add this in the perf directory as well.

I'll ack this patch for now, and we can fix up perf later. I think there
should be an easy way to get perf to use the tags.sh script from the
scripts directory.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve



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

* Re: [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
  2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
                   ` (4 preceding siblings ...)
  2012-06-18 13:37 ` [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Steven Rostedt
@ 2012-06-18 13:45 ` Steven Rostedt
  2012-06-18 14:06   ` Arnaldo Carvalho de Melo
  5 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2012-06-18 13:45 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML,
	Namhyung Kim, Namhyung Kim

Arnaldo,

I've acked this series. Can you add my Acked-by tags on the patches that
do not have it yet, and then pull it into your repo?

Thanks!

-- Steve



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

* Re: [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
  2012-06-18 13:45 ` Steven Rostedt
@ 2012-06-18 14:06   ` Arnaldo Carvalho de Melo
  2012-06-19  8:02     ` Namhyung Kim
  0 siblings, 1 reply; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-06-18 14:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML,
	Namhyung Kim, Namhyung Kim

Em Mon, Jun 18, 2012 at 09:45:48AM -0400, Steven Rostedt escreveu:
> Arnaldo,
> 
> I've acked this series. Can you add my Acked-by tags on the patches that
> do not have it yet, and then pull it into your repo?

Sure thing, I'll put it in my perf/core branch,

- Arnaldo

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

* Re: [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
  2012-06-18 14:06   ` Arnaldo Carvalho de Melo
@ 2012-06-19  8:02     ` Namhyung Kim
  2012-06-19 12:30       ` Steven Rostedt
  0 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-06-19  8:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Steven Rostedt, Frederic Weisbecker, Peter Zijlstra, Ingo Molnar,
	LKML, Namhyung Kim

Hi, Arnaldo

On Mon, 18 Jun 2012 11:06:25 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jun 18, 2012 at 09:45:48AM -0400, Steven Rostedt escreveu:
>> Arnaldo,
>> 
>> I've acked this series. Can you add my Acked-by tags on the patches that
>> do not have it yet, and then pull it into your repo?
>
> Sure thing, I'll put it in my perf/core branch,
>

As I said before [1], those patches are based on my libtraceevent/next
branch which contains a couple of commits not merged into tip or your
tree. They are my previous backport work, and Steve wanted to leave them
out for 3.6 cycle [2].

So my question is that do you want to pull those bits too? If so, I can
send a pull request to you if you want. :) - I noticed that your
perf/core branch isn't on top of current tip/perf/core. So I've also
setup libtraceevent/core branch to track your branch.

Thanks,
Namhyung


[1] article.gmane.org/gmane.linux.kernel/1310798
[2] article.gmane.org/gmane.linux.kernel/1302643

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

* Re: [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event()
  2012-06-19  8:02     ` Namhyung Kim
@ 2012-06-19 12:30       ` Steven Rostedt
  0 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-06-19 12:30 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Frederic Weisbecker, Peter Zijlstra,
	Ingo Molnar, LKML, Namhyung Kim

On Tue, 2012-06-19 at 17:02 +0900, Namhyung Kim wrote:
> Hi, Arnaldo
> 
> On Mon, 18 Jun 2012 11:06:25 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Jun 18, 2012 at 09:45:48AM -0400, Steven Rostedt escreveu:
> >> Arnaldo,
> >> 
> >> I've acked this series. Can you add my Acked-by tags on the patches that
> >> do not have it yet, and then pull it into your repo?
> >
> > Sure thing, I'll put it in my perf/core branch,
> >
> 
> As I said before [1], those patches are based on my libtraceevent/next
> branch which contains a couple of commits not merged into tip or your
> tree. They are my previous backport work, and Steve wanted to leave them
> out for 3.6 cycle [2].

As the merge window has closed, I was under the assumption that these
patches are for 3.6. That's what I wanted them queued up for.

-- Steve



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

* Re: [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes
  2012-06-18  2:50 ` [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
  2012-06-18 13:44   ` Steven Rostedt
@ 2012-07-26 12:24   ` Michal Marek
  1 sibling, 0 replies; 13+ messages in thread
From: Michal Marek @ 2012-07-26 12:24 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Steven Rostedt, Arnaldo Carvalho de Melo, Frederic Weisbecker,
	Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

On Mon, Jun 18, 2012 at 11:50:51AM +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> As we use a macro trick to sync each error codes with its
> description string, teach [ce]tags to process them properly.
> 
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Michal Marek <mmarek@suse.cz>
> Link: http://lkml.kernel.org/n/tip-qt5fv4pzigr2nnl27ydimg4h@git.kernel.org
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  scripts/tags.sh |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Applied to kbuild.git#misc, thanks.

Michal

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

end of thread, other threads:[~2012-07-26 12:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18  2:50 [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Namhyung Kim
2012-06-18  2:50 ` [PATCH v2 2/5] tools lib traceevent: Do not link broken field arg for an old ftrace event Namhyung Kim
2012-06-18  2:50 ` [PATCH v2 3/5] tools lib traceevent: Introduce pevent_errno Namhyung Kim
2012-06-18  2:50 ` [PATCH v2 4/5] tools lib traceevent: Introduce pevent_strerror Namhyung Kim
2012-06-18 13:41   ` Steven Rostedt
2012-06-18  2:50 ` [PATCH v2 5/5] scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
2012-06-18 13:44   ` Steven Rostedt
2012-07-26 12:24   ` Michal Marek
2012-06-18 13:37 ` [PATCH v2 1/5] tools lib traceevent: Replace malloc_or_die to plain calloc in alloc_event() Steven Rostedt
2012-06-18 13:45 ` Steven Rostedt
2012-06-18 14:06   ` Arnaldo Carvalho de Melo
2012-06-19  8:02     ` Namhyung Kim
2012-06-19 12:30       ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.