linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf stat: Honour --timeout for forked workloads
Date: Wed, 15 Apr 2020 19:46:57 +0300	[thread overview]
Message-ID: <2996611.mvXUDI8C0e@constantine-n61ja> (raw)
In-Reply-To: <20200415153803.GB20324@kernel.org>

Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru>

On среда, 15 апреля 2020 г. 18:38:03 MSK Arnaldo Carvalho de Melo wrote:
> Hi guys,
> 
> 	Please take a look and give this your acks, Tested-by, etc.
> 
> Thanks,
> 
> - Arnaldo
> 
> ----
> 
> When --timeout is used and a workload is specified to be started by
> 'perf stat', i.e.
> 
>   $ perf stat --timeout 1000 sleep 1h
> 
> The --timeout wasn't being honoured, i.e. the workload, 'sleep 1h' in
> the above example, should be terminated after 1000ms, but it wasn't,
> 'perf stat' was waiting for it to finish.
> 
> Fix it by sending a SIGTERM when the timeout expires.
> 
> Now it works:
> 
>   # perf stat -e cycles --timeout 1234 sleep 1h
>   sleep: Terminated
> 
>    Performance counter stats for 'sleep 1h':
> 
>            1,066,692      cycles
> 
>          1.234314838 seconds time elapsed
> 
>          0.000750000 seconds user
>          0.000000000 seconds sys
> 
>   #
> 
> Reported-by: Konstantin Kharlamov <hi-angel@yandex.ru>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207243
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/builtin-stat.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index ec053dc1e35c..9207b6c45475 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -686,8 +686,11 @@ static int __run_perf_stat(int argc, const char **argv,
> int run_idx) break;
>  			}
>  		}
> -		if (child_pid != -1)
> +		if (child_pid != -1) {
> +			if (timeout)
> +				kill(child_pid, SIGTERM);
>  			wait4(child_pid, &status, 0, 
&stat_config.ru_data);
> +		}
> 
>  		if (workload_exec_errno) {
>  			const char *emsg = 
str_error_r(workload_exec_errno, msg, sizeof(msg));


-- 
Инженер-разработчик Константин Харламов

      parent reply	other threads:[~2020-04-15 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 15:38 [PATCH] perf stat: Honour --timeout for forked workloads Arnaldo Carvalho de Melo
2020-04-15 16:25 ` Jiri Olsa
2020-04-15 16:46 ` Konstantin Kharlamov [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=2996611.mvXUDI8C0e@constantine-n61ja \
    --to=hi-angel@yandex.ru \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).