From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Wang Nan <wangnan0@huawei.com>,
linux-kernel@vger.kernel.org, pi3orama@163.com,
He Kuang <hekuang@huawei.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Namhyung Kim <namhyung@kernel.org>, Zefan Li <lizefan@huawei.com>
Subject: Re: [PATCH 03/10] perf record: Turns auxtrace_snapshot_enable into 3 states
Date: Wed, 13 Apr 2016 12:55:33 -0300 [thread overview]
Message-ID: <20160413155533.GG9056@kernel.org> (raw)
In-Reply-To: <1460535673-159866-4-git-send-email-wangnan0@huawei.com>
Em Wed, Apr 13, 2016 at 08:21:06AM +0000, Wang Nan escreveu:
> auxtrace_snapshot_enable has only two states (0/1). Turns it into a
> triple states enum so SIGUSR2 handler can safely do other works without
> triggering auxtrace snapshot.
Adrian, can you take a look at this? Is it ok with you?
Thanks,
- Arnaldo
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.com
> ---
> tools/perf/builtin-record.c | 59 +++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 49 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index eb6a199..480033f 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -125,7 +125,43 @@ out:
> static volatile int done;
> static volatile int signr = -1;
> static volatile int child_finished;
> -static volatile int auxtrace_snapshot_enabled;
> +
> +static volatile enum {
> + AUXTRACE_SNAPSHOT_OFF = -1,
> + AUXTRACE_SNAPSHOT_DISABLED = 0,
> + AUXTRACE_SNAPSHOT_ENABLED = 1,
> +} auxtrace_snapshot_state = AUXTRACE_SNAPSHOT_OFF;
> +
> +static inline void
> +auxtrace_snapshot_on(void)
> +{
> + auxtrace_snapshot_state = AUXTRACE_SNAPSHOT_DISABLED;
> +}
> +
> +static inline void
> +auxtrace_snapshot_enable(void)
> +{
> + if (auxtrace_snapshot_state == AUXTRACE_SNAPSHOT_OFF)
> + return;
> + auxtrace_snapshot_state = AUXTRACE_SNAPSHOT_ENABLED;
> +}
> +
> +static inline void
> +auxtrace_snapshot_disable(void)
> +{
> + if (auxtrace_snapshot_state == AUXTRACE_SNAPSHOT_OFF)
> + return;
> + auxtrace_snapshot_state = AUXTRACE_SNAPSHOT_DISABLED;
> +}
> +
> +static inline bool
> +auxtrace_snapshot_is_enabled(void)
> +{
> + if (auxtrace_snapshot_state == AUXTRACE_SNAPSHOT_OFF)
> + return false;
> + return auxtrace_snapshot_state == AUXTRACE_SNAPSHOT_ENABLED;
> +}
> +
> static volatile int auxtrace_snapshot_err;
> static volatile int auxtrace_record__snapshot_started;
>
> @@ -249,7 +285,7 @@ static void record__read_auxtrace_snapshot(struct record *rec)
> } else {
> auxtrace_snapshot_err = auxtrace_record__snapshot_finish(rec->itr);
> if (!auxtrace_snapshot_err)
> - auxtrace_snapshot_enabled = 1;
> + auxtrace_snapshot_enable();
> }
> }
>
> @@ -615,10 +651,13 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
> signal(SIGCHLD, sig_handler);
> signal(SIGINT, sig_handler);
> signal(SIGTERM, sig_handler);
> - if (rec->opts.auxtrace_snapshot_mode)
> +
> + if (rec->opts.auxtrace_snapshot_mode) {
> signal(SIGUSR2, snapshot_sig_handler);
> - else
> + auxtrace_snapshot_on();
> + } else {
> signal(SIGUSR2, SIG_IGN);
> + }
>
> session = perf_session__new(file, false, tool);
> if (session == NULL) {
> @@ -744,12 +783,12 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
> perf_evlist__enable(rec->evlist);
> }
>
> - auxtrace_snapshot_enabled = 1;
> + auxtrace_snapshot_enable();
> for (;;) {
> unsigned long long hits = rec->samples;
>
> if (record__mmap_read_all(rec) < 0) {
> - auxtrace_snapshot_enabled = 0;
> + auxtrace_snapshot_disable();
> err = -1;
> goto out_child;
> }
> @@ -787,12 +826,12 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
> * disable events in this case.
> */
> if (done && !disabled && !target__none(&opts->target)) {
> - auxtrace_snapshot_enabled = 0;
> + auxtrace_snapshot_disable();
> perf_evlist__disable(rec->evlist);
> disabled = true;
> }
> }
> - auxtrace_snapshot_enabled = 0;
> + auxtrace_snapshot_disable();
>
> if (forks && workload_exec_errno) {
> char msg[STRERR_BUFSIZE];
> @@ -1358,9 +1397,9 @@ out_symbol_exit:
>
> static void snapshot_sig_handler(int sig __maybe_unused)
> {
> - if (!auxtrace_snapshot_enabled)
> + if (!auxtrace_snapshot_is_enabled())
> return;
> - auxtrace_snapshot_enabled = 0;
> + auxtrace_snapshot_disable();
> auxtrace_snapshot_err = auxtrace_record__snapshot_start(record.itr);
> auxtrace_record__snapshot_started = 1;
> }
> --
> 1.8.3.4
next prev parent reply other threads:[~2016-04-13 15:55 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 8:21 [PATCH 00/10] perf tools: Use SIGUSR2 control data dumpping Wang Nan
2016-04-13 8:21 ` [PATCH 01/10] perf tools: Make ordered_events reusable Wang Nan
2016-04-13 15:24 ` Arnaldo Carvalho de Melo
2016-04-14 13:35 ` [tip:perf/core] perf ordered_events: Introduce reinit() tip-bot for Wang Nan
2016-04-14 13:35 ` [tip:perf/core] perf session: Make ordered_events reusable tip-bot for Wang Nan
2016-04-13 8:21 ` [PATCH 02/10] perf tools: Add perf_data_file__switch() helper Wang Nan
2016-04-14 13:36 ` [tip:perf/core] perf data: " tip-bot for Wang Nan
2016-04-15 10:41 ` [PATCH 02/10] perf tools: " Jiri Olsa
2016-04-15 16:00 ` Arnaldo Carvalho de Melo
2016-04-13 8:21 ` [PATCH 03/10] perf record: Turns auxtrace_snapshot_enable into 3 states Wang Nan
2016-04-13 15:55 ` Arnaldo Carvalho de Melo [this message]
2016-04-14 7:15 ` Adrian Hunter
2016-04-14 7:50 ` Wangnan (F)
2016-04-14 8:30 ` Adrian Hunter
2016-04-14 9:07 ` Wangnan (F)
2016-04-14 10:21 ` Adrian Hunter
2016-04-14 13:36 ` [tip:perf/core] " tip-bot for Wang Nan
2016-04-13 8:21 ` [PATCH 04/10] perf record: Add '--timestamp-filename' option to append timestamp to output filename Wang Nan
2016-04-14 13:36 ` [tip:perf/core] perf record: Add '--timestamp-filename' option to append timestamp to output file name tip-bot for Wang Nan
2016-04-13 8:21 ` [PATCH 05/10] perf record: Split output into multiple files via '--switch-output' Wang Nan
2016-04-13 8:21 ` [PATCH 06/10] perf record: Force enable --timestamp-filename when --switch-output is provided Wang Nan
2016-04-13 8:21 ` [PATCH 07/10] perf record: Disable buildid cache options by default in switch output mode Wang Nan
2016-04-13 8:21 ` [PATCH 08/10] perf record: Re-synthesize tracking events after output switching Wang Nan
2016-04-13 8:21 ` [PATCH 09/10] perf record: Generate tracking events for process forked by perf Wang Nan
2016-04-13 8:21 ` [PATCH 10/10] perf core: Add backward attribute to perf event Wang Nan
2016-04-13 17:15 ` [PATCH 00/10] perf tools: Use SIGUSR2 control data dumpping Arnaldo Carvalho de Melo
2016-04-15 10:40 ` Jiri Olsa
2016-04-15 10:45 ` Wangnan (F)
2016-04-15 11:40 ` Wangnan (F)
2016-04-15 13:09 ` Arnaldo Carvalho de Melo
2016-04-15 16:26 ` Arnaldo Carvalho de Melo
2016-04-15 16:48 ` Wangnan (F)
2016-04-15 17:56 ` Wangnan (F)
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=20160413155533.GG9056@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=hekuang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
--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
Powered by JetHome