Skip to contentSkip to conversation

perf/urgent fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 6 messages Jul 9, 2015 – Jul 10, 2015

Subsystems (2)
lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit ebf2d2689de551d90965090bb991fc640a0c0d41:

perf/x86: Fix copy_from_user_nmi() return if range is not ok (2015-07-06 14:09:27 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to 08ae217b8d44986062fe3648c5bb83816d5bc00f:

perf thread_map: Fix the sizeof() calculation for map entries (2015-07-09 12:28:53 -0300)

----------------------------------------------------------------
perf/urgent fixes:

User visible:

- Fix 'perf top -u username', where not enough memory per thread_map entry was being allocated nor was being initialized, causing a segfault (Arnaldo Carvalho de Melo)

- Fix locking lockup using 32-bit compat vdso (Adrian Hunter)

Developer stuff:

- Fix shadow declaration of close with older build environments (Jiri Olsa)

- Make the 'clean' target do a better job, removing some more temp files (Riku Voipio)

----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix lockup using 32-bit compat vdso

Arnaldo Carvalho de Melo (1):
perf thread_map: Fix the sizeof() calculation for map entries

Jiri Olsa (1):
perf stat: Fix shadow declaration of close

Riku Voipio (1):
tools lib: Improve clean target

 tools/lib/api/Makefile        | 2 +-
 tools/lib/traceevent/Makefile | 2 +-
 tools/perf/builtin-stat.c     | 4 ++--
 tools/perf/util/thread_map.c  | 3 +--
 tools/perf/util/vdso.c        | 8 +++-----
 5 files changed, 8 insertions(+), 11 deletions(-)
author maintainer
#1 lore raw

PATCH 1/4 perf tools: Fix lockup using 32-bit compat vdso

From: Adrian Hunter <[email protected]>

The __machine__findnew_compat() function is called only from __machine__findnew_vdso_compat() which is called only from machine__findnew_vdso() which already holds machine->dsos.lock, so remove locking from __machine__findnew_compat().

This manifests itself tracing 32-bit programs with a 64-bit perf.

---
 tools/perf/util/vdso.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
tools/perf/util/vdso.c +3 -5
index 4b89118f158d..44d440da15dc 100644
@@ -236,18 +236,16 @@ static struct dso *__machine__findnew_compat(struct machine *machine,
 	const char *file_name;
 	struct dso *dso;
 
-	pthread_rwlock_wrlock(&machine->dsos.lock);
 	dso = __dsos__find(&machine->dsos, vdso_file->dso_name, true);
 	if (dso)
-		goto out_unlock;
+		goto out;
 
 	file_name = vdso__get_compat_file(vdso_file);
 	if (!file_name)
-		goto out_unlock;
+		goto out;
 
 	dso = __machine__addnew_vdso(machine, vdso_file->dso_name, file_name);
-out_unlock:
-	pthread_rwlock_unlock(&machine->dsos.lock);
+out:
 	return dso;
 }
 
Signature · 1 line
2.1.0
author maintainer
#2 lore raw

PATCH 2/4 perf stat: Fix shadow declaration of close

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Vinson reported shadow declaration of close introduced by the following commit:

106a94a0f8c2 perf stat: Introduce read_counters function

Using close_counters name instead.

Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 106a94a0f8c2 ("perf stat: Introduce read_counters function")
---
 tools/perf/builtin-stat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +2 -2
index 37e301a32f43..d99d850e1444 100644
@@ -343,7 +343,7 @@ static int read_counter(struct perf_evsel *counter)
 	return 0;
 }
 
-static void read_counters(bool close)
+static void read_counters(bool close_counters)
 {
 	struct perf_evsel *counter;
 
@@ -354,7 +354,7 @@ static void read_counters(bool close)
 		if (process_counter(counter))
 			pr_warning("failed to process counter %s\n", counter->name);
 
-		if (close) {
+		if (close_counters) {
 			perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter),
 					     thread_map__nr(evsel_list->threads));
 		}
Signature · 1 line
2.1.0
author maintainer
#3 lore raw

PATCH 3/4 tools lib: Improve clean target

In reply to Arnaldo Carvalho de Melo

From: Riku Voipio <[email protected]>

The clean targets miss some .cmd and .d files.

---
 tools/lib/api/Makefile        | 2 +-
 tools/lib/traceevent/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/lib/api/Makefile +1 -1
index 8bd960658463..fe1b02c2c95b 100644
@@ -36,7 +36,7 @@ $(LIBFILE): $(API_IN)
 
 clean:
 	$(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \
-	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o | xargs $(RM)
+	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
 
 FORCE:
 
tools/lib/traceevent/Makefile +1 -1
index 6daaff652aff..7851df1490e0 100644
@@ -268,7 +268,7 @@ install: install_lib
 
 clean:
 	$(call QUIET_CLEAN, libtraceevent) \
-		$(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d \
+		$(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \
 		$(RM) TRACEEVENT-CFLAGS tags TAGS
 
 PHONY += force plugins
Signature · 1 line
2.1.0
author maintainer
#4 lore raw

PATCH 4/4 perf thread_map: Fix the sizeof() calculation for map entries

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

When we started adding extra stuff per array entry, growing the size of those entries to more than sizeof(pid_t), we had to convert those sizeof operations to the more robust sizeof(map->map[0]) idiom, that is future proof, i.e. if/when we add more stuff to those entries, that expression will produce the new per-entry size.

And besides that, we need to zero out those extra fields, that sometimes may not get filled, like when we couldn't care less about the comms, since we don't need those, but since we will try freeing it at thread_map__delete(), we better fix it.

That is why a thread_map__realloc() was provided.

But that method wasn't used in thread_map__new_by_uid(), fix it.

Fixes 792402fd5c0a ("perf thrad_map: Add comm string into array")
Fixes 9d7e8c3a96e5 ("perf tools: Add thread_map__(alloc|realloc) helpers")
Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/thread_map.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/thread_map.c +1 -2
index da7646d767fe..292ae2c90e06 100644
@@ -136,8 +136,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
 		if (grow) {
 			struct thread_map *tmp;
 
-			tmp = realloc(threads, (sizeof(*threads) +
-						max_threads * sizeof(pid_t)));
+			tmp = thread_map__realloc(threads, max_threads);
 			if (tmp == NULL)
 				goto out_free_namelist;
 
Signature · 1 line
2.1.0
#5 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 51 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit ebf2d2689de551d90965090bb991fc640a0c0d41:

perf/x86: Fix copy_from_user_nmi() return if range is not ok (2015-07-06 14:09:27 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to 08ae217b8d44986062fe3648c5bb83816d5bc00f:

perf thread_map: Fix the sizeof() calculation for map entries (2015-07-09 12:28:53 -0300)

----------------------------------------------------------------
perf/urgent fixes:

User visible:

- Fix 'perf top -u username', where not enough memory per thread_map entry was being allocated nor was being initialized, causing a segfault (Arnaldo Carvalho de Melo)

- Fix locking lockup using 32-bit compat vdso (Adrian Hunter)

Developer stuff:

- Fix shadow declaration of close with older build environments (Jiri Olsa)

- Make the 'clean' target do a better job, removing some more temp files (Riku Voipio)

----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix lockup using 32-bit compat vdso

Arnaldo Carvalho de Melo (1):
perf thread_map: Fix the sizeof() calculation for map entries

Jiri Olsa (1):
perf stat: Fix shadow declaration of close

Riku Voipio (1):
tools lib: Improve clean target

Quoted 6 lines
 tools/lib/api/Makefile        | 2 +-
 tools/lib/traceevent/Makefile | 2 +-
 tools/perf/builtin-stat.c     | 4 ++--
 tools/perf/util/thread_map.c  | 3 +--
 tools/perf/util/vdso.c        | 8 +++-----
 5 files changed, 8 insertions(+), 11 deletions(-)

Pulled this and the second round of fixes, thanks a lot Arnaldo!

Ingo