Re: [PATCH 05/16] perf test: Fix hist testcases when kptr_restrict is on

2015-12-14 Thread Wangnan (F)

Hi,

On 2015/12/15 1:44, Arnaldo Carvalho de Melo wrote:

From: 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.

Signed-off-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1450062673-22312-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
  tools/perf/tests/hists_common.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)


I have a similar patch on this problem at [1][2].

This patch applied solves only half of the problem I seen. Although double
free is gone, in case when kptr_restrict is enabled a normal user still
gets incorrect result. For example:

 $ ./perf test -v 'filtering hist entries'
 25: Test filtering hist entries  :
 --- start ---
 test child forked, pid 4186
 Cannot create kernel maps
 test child finished with 0
  end 
 Test filtering hist entries: Ok

The test body doesn't get called at all. I think in this case we'd better
return 'Skip'.

I'd like to send another for it.

[1] 
http://lkml.kernel.org/g/1450089563-122430-2-git-send-email-wangn...@huawei.com
[2] 
http://lkml.kernel.org/g/1449726768-79624-1-git-send-email-wangn...@huawei.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/16] perf test: Fix hist testcases when kptr_restrict is on

2015-12-14 Thread Arnaldo Carvalho de Melo
From: 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.

Signed-off-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1450062673-22312-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index 46f453b1de60..bcfd081ee1d2 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -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;
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] perf test: Fix hist testcases when kptr_restrict is on

2015-12-14 Thread Wangnan (F)

Hi,

On 2015/12/15 1:44, Arnaldo Carvalho de Melo wrote:

From: 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.

Signed-off-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1450062673-22312-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
  tools/perf/tests/hists_common.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)


I have a similar patch on this problem at [1][2].

This patch applied solves only half of the problem I seen. Although double
free is gone, in case when kptr_restrict is enabled a normal user still
gets incorrect result. For example:

 $ ./perf test -v 'filtering hist entries'
 25: Test filtering hist entries  :
 --- start ---
 test child forked, pid 4186
 Cannot create kernel maps
 test child finished with 0
  end 
 Test filtering hist entries: Ok

The test body doesn't get called at all. I think in this case we'd better
return 'Skip'.

I'd like to send another for it.

[1] 
http://lkml.kernel.org/g/1450089563-122430-2-git-send-email-wangn...@huawei.com
[2] 
http://lkml.kernel.org/g/1449726768-79624-1-git-send-email-wangn...@huawei.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/16] perf test: Fix hist testcases when kptr_restrict is on

2015-12-14 Thread Arnaldo Carvalho de Melo
From: 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.

Signed-off-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1450062673-22312-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/hists_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index 46f453b1de60..bcfd081ee1d2 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -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;
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/