From: tip-bot for Wang Nan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: namhyung@kernel.org, jolsa@redhat.com, tglx@linutronix.de,
wangnan0@huawei.com, lizefan@huawei.com, acme@redhat.com,
linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com
Subject: [tip:perf/core] perf tools: Clear struct machine during machine__init()
Date: Mon, 14 Dec 2015 00:39:17 -0800 [thread overview]
Message-ID: <tip-93b0ba3c60da89043ce2b9f601cd2b3da408903b@git.kernel.org> (raw)
In-Reply-To: <1449541544-67621-17-git-send-email-wangnan0@huawei.com>
Commit-ID: 93b0ba3c60da89043ce2b9f601cd2b3da408903b
Gitweb: http://git.kernel.org/tip/93b0ba3c60da89043ce2b9f601cd2b3da408903b
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 8 Dec 2015 02:25:44 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 11 Dec 2015 09:32:41 -0300
perf tools: Clear struct machine during machine__init()
There are so many test cases use stack allocated 'struct machine'.
Including:
test__hists_link
test__hists_filter
test__mmap_thread_lookup
test__thread_mg_share
test__hists_output
test__hists_cumulate
Also, in non-test code (for example, machine__new_host()) there are
code use 'malloc()' to alloc struct machine.
These are dangerous operations, cause some tests fail or hung in
machines__exit(). For example, in
machines__exit ->
machine__destroy_kernel_maps ->
map_groups__remove ->
maps__remove ->
pthread_rwlock_wrlock
a incorrectly initialized lock causes unintended behavior.
This patch memset(0) that structure in machine__init() to ensure all
fields in 'struct machine' are initialized to zero.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449541544-67621-17-git-send-email-wangnan0@huawei.com
[ Use memset, see 'man bzero' ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/machine.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f5882b8..1407d51 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -25,6 +25,7 @@ static void dsos__init(struct dsos *dsos)
int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
{
+ memset(machine, 0, sizeof(*machine));
map_groups__init(&machine->kmaps, machine);
RB_CLEAR_NODE(&machine->rb_node);
dsos__init(&machine->dsos);
prev parent reply other threads:[~2015-12-14 8:39 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 2:25 [PATCH v4 00/16] perf tools: BPF related update and other improvements Wang Nan
2015-12-08 2:25 ` [PATCH v4 01/16] tools lib bpf: Check return value of strdup when reading map names Wang Nan
2015-12-14 8:37 ` [tip:perf/core] " tip-bot for Wang Nan
2015-12-08 2:25 ` [PATCH v4 02/16] tools lib bpf: Fetch map names from correct strtab Wang Nan
2015-12-14 8:38 ` [tip:perf/core] " tip-bot for Wang Nan
2015-12-08 2:25 ` [PATCH v4 03/16] perf tools: Add API to config maps in bpf object Wang Nan
2015-12-08 2:25 ` [PATCH v4 04/16] perf tools: Enable BPF object configure syntax Wang Nan
2015-12-08 2:25 ` [PATCH v4 05/16] perf record: Apply config to BPF objects before recording Wang Nan
2015-12-08 2:25 ` [PATCH v4 06/16] perf tools: Support perf event alias name Wang Nan
2015-12-11 12:03 ` Arnaldo Carvalho de Melo
2015-12-11 12:12 ` pi3orama
2015-12-08 2:25 ` [PATCH v4 07/16] perf tools: Enable passing event to BPF object Wang Nan
2015-12-08 2:25 ` [PATCH v4 08/16] perf tools: Support setting different slots in a BPF map separately Wang Nan
2015-12-08 2:25 ` [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps Wang Nan
2015-12-11 12:11 ` Arnaldo Carvalho de Melo
2015-12-11 12:15 ` Arnaldo Carvalho de Melo
2015-12-11 12:39 ` pi3orama
2015-12-11 12:47 ` Arnaldo Carvalho de Melo
2015-12-11 12:57 ` pi3orama
2015-12-11 18:21 ` Alexei Starovoitov
2015-12-14 3:27 ` Wangnan (F)
2015-12-14 4:28 ` Alexei Starovoitov
2015-12-14 4:39 ` Wangnan (F)
2015-12-14 5:51 ` Alexei Starovoitov
2015-12-08 2:25 ` [PATCH v4 10/16] perf tools: Introduce bpf-output event Wang Nan
2015-12-08 2:25 ` [PATCH v4 11/16] perf data: Add u32_hex data type Wang Nan
2015-12-14 8:38 ` [tip:perf/core] " tip-bot for Wang Nan
2015-12-08 2:25 ` [PATCH v4 12/16] perf data: Support converting data from bpf_perf_event_output() Wang Nan
2015-12-08 2:25 ` [PATCH v4 13/16] perf tools: Always give options even it not compiled Wang Nan
2015-12-11 12:39 ` Arnaldo Carvalho de Melo
2015-12-08 2:25 ` [PATCH v4 14/16] perf record: Support custom vmlinux path Wang Nan
2015-12-08 2:25 ` [PATCH v4 15/16] perf script: Add support for PERF_TYPE_BREAKPOINT Wang Nan
2015-12-14 8:38 ` [tip:perf/core] " tip-bot for Wang Nan
2015-12-08 2:25 ` [PATCH v4 16/16] perf tools: Clear struct machine during machine__init() Wang Nan
2015-12-14 8:39 ` tip-bot for Wang Nan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-93b0ba3c60da89043ce2b9f601cd2b3da408903b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox