stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jin Yao <yao.jin@linux.intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.20 03/42] perf stat: Fix endless wait for child process
Date: Sat,  9 Feb 2019 13:46:55 -0500	[thread overview]
Message-ID: <20190209184734.125935-3-sashal@kernel.org> (raw)
In-Reply-To: <20190209184734.125935-1-sashal@kernel.org>

From: Jin Yao <yao.jin@linux.intel.com>

[ Upstream commit 8a99255a50c0b4c2a449b96fd8d45fcc8d72c701 ]

We hit a 'perf stat' issue by using following script:

  #!/bin/bash

  sleep 1000 &
  exec perf stat -a -e cycles -I1000 -- sleep 5

Since "perf stat" is launched by exec, the "sleep 1000" would be the
child process of "perf stat". The wait4() call will not return because
it's waiting for the child process "sleep 1000" to end. So 'perf stat'
doesn't return even after 5s passes.

This patch lets 'perf stat' return when the specified child process ends
(in this case, the specified child process is "sleep 5").

Committer testing:

  # cat test.sh
  #!/bin/bash

  sleep 10 &
  exec perf stat -a -e cycles -I1000 -- sleep 5
  #

Before:

  # time ./test.sh
  #           time             counts unit events
       1.001113090        108,453,351      cycles
       2.002062196        142,075,435      cycles
       3.002896194        164,801,068      cycles
       4.003731666        107,062,140      cycles
       5.002068867        112,241,832      cycles

  real	0m10.066s
  user	0m0.016s
  sys	0m0.101s
  #

After:

  # time ./test.sh
  #           time             counts unit events
       1.001016096         91,412,027      cycles
       2.002014963        124,063,708      cycles
       3.002883964        125,993,929      cycles
       4.003706470        120,465,734      cycles
       5.002006778        163,560,355      cycles

  real	0m5.123s
  user	0m0.014s
  sys	0m0.105s
  #

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1546501245-4512-1-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/builtin-stat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1410d66192f7..63a3afc7f32b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -561,7 +561,8 @@ try_again:
 					break;
 			}
 		}
-		wait4(child_pid, &status, 0, &stat_config.ru_data);
+		if (child_pid != -1)
+			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));
-- 
2.19.1


  parent reply	other threads:[~2019-02-09 18:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09 18:46 [PATCH AUTOSEL 4.20 01/42] drm/amdgpu/sriov:Correct pfvf exchange logic Sasha Levin
2019-02-09 18:46 ` [PATCH AUTOSEL 4.20 02/42] ACPI: NUMA: Use correct type for printing addresses on i386-PAE Sasha Levin
2019-02-09 18:46 ` Sasha Levin [this message]
2019-02-09 18:46 ` [PATCH AUTOSEL 4.20 04/42] perf report: Fix wrong iteration count in --branch-history Sasha Levin
2019-02-09 18:46 ` [PATCH AUTOSEL 4.20 05/42] perf test shell: Use a fallback to get the pathname in vfs_getname Sasha Levin
2019-02-09 18:46 ` [PATCH AUTOSEL 4.20 06/42] soc: renesas: r8a774c0-sysc: Fix initialization order of 3DG-{A,B} Sasha Levin
2019-02-09 18:46 ` [PATCH AUTOSEL 4.20 07/42] tools uapi: fix RISC-V 64-bit support Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 08/42] riscv: fix trace_sys_exit hook Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 09/42] cpufreq: check if policy is inactive early in __cpufreq_get() Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 10/42] csky: fixup relocation error with 807 & 860 Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 11/42] csky: fixup CACHEV1 store instruction fast retire Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 12/42] csky: fixup compile error with pte_alloc Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 13/42] irqchip/csky: fixup handle_irq_perbit break irq Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 14/42] drm/amd/powerplay: avoid possible buffer overflow Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 15/42] drm/bridge: tc358767: add bus flags Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 16/42] drm/bridge: tc358767: add defines for DP1_SRCCTRL & PHY_2LANE Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 17/42] drm/bridge: tc358767: fix single lane configuration Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 18/42] drm/bridge: tc358767: fix initial DP0/1_SRCCTRL value Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 19/42] drm/bridge: tc358767: reject modes which require too much BW Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 20/42] drm/bridge: tc358767: fix output H/V syncs Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 21/42] nvme-pci: use the same attributes when freeing host_mem_desc_bufs Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 22/42] nvme-pci: fix out of bounds access in nvme_cqe_pending Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 23/42] nvme-multipath: zero out ANA log buffer Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 24/42] nvme: pad fake subsys NQN vid and ssvid with zeros Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 25/42] nvme: introduce NVME_QUIRK_IGNORE_DEV_SUBNQN Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 26/42] drm/amdgpu: fix CPDMA hang in PRT mode for VEGA20 Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 27/42] drm/amdgpu: set WRITE_BURST_LENGTH to 64B to workaround SDMA1 hang Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 28/42] drm/amdgpu: disable system memory page tables for now Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 29/42] ARM: dts: da850-evm: Correct the audio codec regulators Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 30/42] ARM: dts: da850-evm: Correct the sound card name Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 31/42] ARM: dts: da850-lcdk: Correct the audio codec regulators Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 32/42] ARM: dts: da850-lcdk: Correct the sound card name Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 33/42] ARM: dts: kirkwood: Fix polarity of GPIO fan lines Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 34/42] csky: fixup compile error with CPU 810 Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 35/42] gpio: pl061: handle failed allocations Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 36/42] drm/nouveau: Don't disable polling in fallback mode Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 37/42] drm/nouveau/falcon: avoid touching registers if engine is off Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 38/42] cifs: Limit memory used by lock request calls to a page Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 39/42] CIFS: Fix credits calculation for cancelled requests Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 40/42] CIFS: Move credit processing to mid callbacks for SMB3 Sasha Levin
2019-02-12  1:48   ` Pavel Shilovskiy
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 41/42] CIFS: Fix error paths in writeback code Sasha Levin
2019-02-09 18:47 ` [PATCH AUTOSEL 4.20 42/42] kvm: sev: Fail KVM_SEV_INIT if already initialized Sasha Levin

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=20190209184734.125935-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=yao.jin@linux.intel.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;
as well as URLs for NNTP newsgroup(s).