Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1469075ima; Sun, 21 Oct 2018 12:28:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61yIM+Yil4dohxCIvNu18zzL7ta6Jv7vgK0ezSmFSSroLl0YGS26BFfpn3//pItrD+tdFN0 X-Received: by 2002:a17:902:8342:: with SMTP id z2-v6mr41499661pln.147.1540150088168; Sun, 21 Oct 2018 12:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540150088; cv=none; d=google.com; s=arc-20160816; b=nlyKF6d56eRo5hSfYPqKvv4LW2Ieqc3cx7y+TNUeGuXtrwV4kwtytDg8sKoZ7iMvpu w2qZWl/0Gft8kjqF6sRLDpilVBk6kvZ4/AkecNmaXf9YPHndMOP8X/LWCggQmo1z4uYE CT1/aWRIa59MRRJV2R9sUmyQv6yPQ2t3K7QmGKziv8AIAFYidP964uy0Ol7XcI9P2vDk EwW9j4n5GQgH7UpbINCvZhX+p5YXzjPkLTj2wW2sBHbpXJC+xRe5EmpwLAH+qXd5P0bd 6ldw85cv5nPrwwrYzFUdorBpEOkeHCXxNGlhwITPlVmF0nKsk/RPmB4YoZYLWh0Vr3kO Fniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P70s8qO8BSSmjUfKWWRycg2v2KxyieYQlXgMw5G13ug=; b=Gl2Mw6hRzdVWUGGqTKCJ8zqqi27s/ojSuUopiJCWV5AyLSuzhsgd+O6XmfTd7dIPDV nlWBpf88E2apCtXBCWXi2dIPU1QxfdfyhUi1h0utXGjgmEwpwUOvZjOA9idWvx4ZatGO yhskXm/6CH6ukKUDZhYR6q7drixA4AzGUPwLed8bmIY3bLpAPRQwzqvZsVXrpRFcvJBF caCr8rHcyI9lyeTlbA+WhvyEkO5Zsj2Tv9jPYXm6IszwtO5MfPSB91124ly4puSnDzrA 65QEv5inB0TdTojHTbYdI6/1hS65o3l0bOk5dWDGq2+QzzvGxmXg2N0FGLOaQzO1AD/v H8Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=hxJVvxUD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12-v6si31570743pgj.70.2018.10.21.12.27.18; Sun, 21 Oct 2018 12:28:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=hxJVvxUD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbeJVDaH (ORCPT + 99 others); Sun, 21 Oct 2018 23:30:07 -0400 Received: from mail.kdab.com ([176.9.126.58]:7871 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbeJVDaG (ORCPT ); Sun, 21 Oct 2018 23:30:06 -0400 Authentication-Results: mail.kdab.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=kdab.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdab.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from; s=dkim; t= 1540149285; x=1541013286; bh=P70s8qO8BSSmjUfKWWRycg2v2KxyieYQlXg Mw5G13ug=; b=hxJVvxUDImO4eWwp77ma8CGyfodMU+ZUC8lAevtLS4mXL3jvALs zw9VJQG86tQQddSELtVTEGbnlLcdRIdOZNeOdBdpcaDar2t1ICbES07JA1BeP7q7 9KUmyjDELdRWTOY/QVbH/Xn2UdP0JCPE5lgZ4FHlSQnOowjsAZieN4kE= X-Virus-Scanned: amavisd-new at kdab.com From: Milian Wolff To: acme@kernel.org, jolsa@kernel.org Cc: Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Milian Wolff Subject: [PATCH 2/2] perf script: flush output stream after events in verbose mode Date: Sun, 21 Oct 2018 21:14:24 +0200 Message-Id: <20181021191424.16183-2-milian.wolff@kdab.com> In-Reply-To: <20181021191424.16183-1-milian.wolff@kdab.com> References: <20181021191424.16183-1-milian.wolff@kdab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the perf script output is written to a terminal stream, the normal output of `perf script` would get buffered, but its debug output would be written directly. This made it quite hard to figure out where a given debug output is coming from. We can improve on this by flushing the output buffer after processing an event. To see the value, compare the following output for a `perf script -v` run: Before this patch: ``` unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 unwind: find_proc_info dso /usr/lib/ld-2.28.so unwind: reg 6, val 0 unwind: _start:ip =3D 0x7faf7dfdc000 (0x2000) unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 unwind: find_proc_info dso /usr/lib/ld-2.28.so unwind: reg 6, val 0 unwind: _start:ip =3D 0x7faf7dfdc000 (0x2000) unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 unwind: find_proc_info dso /usr/lib/ld-2.28.so unwind: reg 6, val 0 unwind: _start:ip =3D 0x7faf7dfdc000 (0x2000) unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 ... lots and lots of verbose debug output cpp-inlining 24617 90229.122036534: 1 cycles:uppp: 7faf7dfdc000 _start+0x0 (/usr/lib/ld-2.28.so) cpp-inlining 24617 90229.122043974: 1 cycles:uppp: 7faf7dfdc000 _start+0x0 (/usr/lib/ld-2.28.so) ... ``` After this patch: ``` ... unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 unwind: find_proc_info dso /usr/lib/ld-2.28.so unwind: reg 6, val 0 unwind: _start:ip =3D 0x7faf7dfdc000 (0x2000) cpp-inlining 24617 90229.122036534: 1 cycles:uppp: 7faf7dfdc000 _start+0x0 (/usr/lib/ld-2.28.so) unwind: reg 16, val 7faf7dfdc000 unwind: reg 7, val 7ffc80811e30 unwind: find_proc_info dso /usr/lib/ld-2.28.so unwind: reg 6, val 0 unwind: _start:ip =3D 0x7faf7dfdc000 (0x2000) cpp-inlining 24617 90229.122043974: 1 cycles:uppp: 7faf7dfdc000 _start+0x0 (/usr/lib/ld-2.28.so) ... ``` This new output format makes it much easier to use perf script output for debugging purposes, e.g. to investigate broken dwarf unwinding. Signed-off-by: Milian Wolff Cc: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index bd468b90801b..ca09b7d2adb7 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1737,6 +1737,9 @@ static void process_event(struct perf_script *scrip= t, =20 if (PRINT_FIELD(METRIC)) perf_sample__fprint_metric(script, thread, evsel, sample, fp); + + if (verbose) + fflush(fp); } =20 static struct scripting_ops *scripting_ops; --=20 2.19.1