Skip to contentSkip to conversation

perf: cleanup initialization of attr->size

PATCH In review Stephane Eranian 1 participant 2 messages Feb 9, 2012 – Feb 17, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: cleanup initialization of attr->size

The perf_event_attr size needs to be initialized in all cases because it captures the ABI version.

This patch moves the initialization of the field from the perf_event_open() syscall stub to its proper location in the event_attr_init().

---

tools/perf/perf.h +0 -1
index 92af168..06f2d1a 100644
@@ -167,7 +167,6 @@ sys_perf_event_open(struct perf_event_attr *attr,
 		      pid_t pid, int cpu, int group_fd,
 		      unsigned long flags)
 {
-	attr->size = sizeof(*attr);
 	return syscall(__NR_perf_event_open, attr, pid, cpu,
 		       group_fd, flags);
 }
tools/perf/util/util.c +2 -0
index 8131410..c1017b3 100644
@@ -14,6 +14,8 @@ void event_attr_init(struct perf_event_attr *attr)
 		attr->exclude_host  = 1;
 	if (!perf_guest)
 		attr->exclude_guest = 1;
+	/* to capture ABI version */
+	attr->size = sizeof(*attr);
 }
 
 int mkdir_p(char *path, mode_t mode)
#1 lore raw

[tip:perf/core] perf tools: cleanup initialization of attr->size

Commit-ID:  7e1ccd3804281fc0755eb726b654469c40a96d89
Gitweb:     http://git.kernel.org/tip/7e1ccd3804281fc0755eb726b654469c40a96d89
Author:     Stephane Eranian <[email protected]>
AuthorDate: Thu, 9 Feb 2012 16:12:38 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 13 Feb 2012 23:35:04 -0200

perf tools: cleanup initialization of attr->size

The perf_event_attr size needs to be initialized in all cases because it captures the ABI version.

This patch moves the initialization of the field from the perf_event_open() syscall stub to its proper location in the event_attr_init().

---
 tools/perf/perf.h      |    1 -
 tools/perf/util/util.c |    2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/perf.h +0 -1
index deb17db..03a0456 100644
@@ -167,7 +167,6 @@ sys_perf_event_open(struct perf_event_attr *attr,
 		      pid_t pid, int cpu, int group_fd,
 		      unsigned long flags)
 {
-	attr->size = sizeof(*attr);
 	return syscall(__NR_perf_event_open, attr, pid, cpu,
 		       group_fd, flags);
 }
tools/perf/util/util.c +2 -0
index fb25d13..8109a90 100644
@@ -14,6 +14,8 @@ void event_attr_init(struct perf_event_attr *attr)
 		attr->exclude_host  = 1;
 	if (!perf_guest)
 		attr->exclude_guest = 1;
+	/* to capture ABI version */
+	attr->size = sizeof(*attr);
 }
 
 int mkdir_p(char *path, mode_t mode)