Skip to contentSkip to conversation

perf test: Fix hist testcases when kptr_restrict is on

PATCH Applied Namhyung Kim 4 participants 4 messages Dec 14, 2015 – Dec 18, 2015 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf test: Fix hist testcases when kptr_restrict is on

Currently if kptr_restrict is enabled, all hist tests failed with segfaults. This is because machine__create_kernel_maps() in setup_fake_machine() failed in that situation, and it called machine__delete() on the error path. But outer callers again called machines__exit() causing double free for the host machine.

---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/tests/hists_common.c +2 -3
index 46f453b1de60..bcfd081ee1d2 100644
@@ -88,8 +88,8 @@ struct machine *setup_fake_machine(struct machines *machines)
 	}
 
 	if (machine__create_kernel_maps(machine)) {
-		pr_debug("Not enough memory for machine setup\n");
-		goto out;
+		pr_debug("Cannot create kernel maps\n");
+		return NULL;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
@@ -155,7 +155,6 @@ struct machine *setup_fake_machine(struct machines *machines)
 out:
 	pr_debug("Not enough memory for machine setup\n");
 	machine__delete_threads(machine);
-	machine__delete(machine);
 	return NULL;
 }
 
Signature · 1 line
2.6.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Namhyung Kim

Currently if kptr_restrict is enabled, all hist tests failed with segfaults. This is because machine__create_kernel_maps() in setup_fake_machine() failed in that situation, and it called machine__delete() on the error path. But outer callers again called machines__exit() causing double free for the host machine.

thanks,
jirka

Quoted 32 lines
---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/tests/hists_common.c +2 -3
index 46f453b1de60..bcfd081ee1d2 100644
@@ -88,8 +88,8 @@ struct machine *setup_fake_machine(struct machines *machines)
 	}
 
 	if (machine__create_kernel_maps(machine)) {
-		pr_debug("Not enough memory for machine setup\n");
-		goto out;
+		pr_debug("Cannot create kernel maps\n");
+		return NULL;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
@@ -155,7 +155,6 @@ struct machine *setup_fake_machine(struct machines *machines)
 out:
 	pr_debug("Not enough memory for machine setup\n");
 	machine__delete_threads(machine);
-	machine__delete(machine);
 	return NULL;
 }
 
Signature · 1 line
2.6.4
maintainer Applied
#2 lore raw

Em Mon, Dec 14, 2015 at 10:48:07AM +0100, Jiri Olsa escreveu:

Quoted 8 lines · Namhyung Kim
Quoted 5 lines

Currently if kptr_restrict is enabled, all hist tests failed with segfaults. This is because machine__create_kernel_maps() in setup_fake_machine() failed in that situation, and it called machine__delete() on the error path. But outer callers again called machines__exit() causing double free for the host machine.

Thanks, applied.

Quoted 35 lines

thanks,
jirka

Quoted 32 lines
---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/tests/hists_common.c +2 -3
index 46f453b1de60..bcfd081ee1d2 100644
@@ -88,8 +88,8 @@ struct machine *setup_fake_machine(struct machines *machines)
 	}
 
 	if (machine__create_kernel_maps(machine)) {
-		pr_debug("Not enough memory for machine setup\n");
-		goto out;
+		pr_debug("Cannot create kernel maps\n");
+		return NULL;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
@@ -155,7 +155,6 @@ struct machine *setup_fake_machine(struct machines *machines)
 out:
 	pr_debug("Not enough memory for machine setup\n");
 	machine__delete_threads(machine);
-	machine__delete(machine);
 	return NULL;
 }
 
Signature · 1 line
2.6.4
#3 lore raw
In reply to Namhyung Kim
perf test: Fix hist testcases when kptr_restrict is on
Commit-ID:  71d6de64feddd4b455555326fba2111b3006d9e0
Gitweb:     http://git.kernel.org/tip/71d6de64feddd4b455555326fba2111b3006d9e0
Author:     Namhyung Kim <[email protected]>
AuthorDate: Mon, 14 Dec 2015 12:11:13 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Dec 2015 12:15:07 -0300

perf test: Fix hist testcases when kptr_restrict is on

Currently if kptr_restrict is enabled, all hist tests failed with segfaults. This is because machine__create_kernel_maps() in setup_fake_machine() failed in that situation, and it called machine__delete() on the error path. But outer callers again called machines__exit() causing double free for the host machine.

---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/tests/hists_common.c +2 -3
index 46f453b..bcfd081 100644
@@ -88,8 +88,8 @@ struct machine *setup_fake_machine(struct machines *machines)
 	}
 
 	if (machine__create_kernel_maps(machine)) {
-		pr_debug("Not enough memory for machine setup\n");
-		goto out;
+		pr_debug("Cannot create kernel maps\n");
+		return NULL;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
@@ -155,7 +155,6 @@ struct machine *setup_fake_machine(struct machines *machines)
 out:
 	pr_debug("Not enough memory for machine setup\n");
 	machine__delete_threads(machine);
-	machine__delete(machine);
 	return NULL;
 }