Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp449999ima; Fri, 26 Oct 2018 00:36:00 -0700 (PDT) X-Google-Smtp-Source: AJdET5fqrlGiU410kA0VS6+FFZuXJjmQkbe8viB/p8qIu2TB+/KoAo1XAfjJpzZWv9GC3GTRppnR X-Received: by 2002:a17:902:7244:: with SMTP id c4-v6mr2363438pll.251.1540539360692; Fri, 26 Oct 2018 00:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540539360; cv=none; d=google.com; s=arc-20160816; b=bH237zYGMi+IpKbqV+9QHNxxfPc6dxHKczRsy2VbAzkUiwpG9sQNFiTuAm7IqUq/OC iODZrgGei3iTZ9gFtpmQKOywrDo2/FuhBw8Vl1V3fGf//4uFbVLB4D+vNhOH418DWBll XemoS6lACI4Gt67fe7XZhMMGM9yMAHiHmj/x2t6w1pTb0/rWMnDv81yiIdMRl5/P7zNW qmGX725atalcDn6s+UoHJUkHXf5cVNKGr7MStohCkzs8756plNwAtmM6Hk4LqaiPeMfQ t3PlAVkKEC/5sVPR5ZGwQKsuwe7djN/3iDUUTFESXgky0cNxSuN7KTPVe8EmDOIfraaJ VxmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=mLeXMnPMCMY1+mR309RPVjOXagVAnm6ron2uwWjw5Hw=; b=A5ZHYYIpM5grkyYC5hObvwEsdXTRGsvNxr7r0BC43Ww2kIGCM3i6MXcxlMDaLKK0x7 2WxLZveX+c1/Iq5anJKQy1mIK7SnGBP5AbEPfXbqFaGaI6yicuIJcMYeIZx07NWfgRzR 1gbCuk+SwdN63L0cCr4BLeFpFI1Y0a0aboPjVtxdaSBWRwBPZC40FSNr3dJuTQbG2jWL b3OHGklmQj4B54jaqqbwE33TihEawT9kd7grBVq0jj4Pm/ZaWMUoVkv5p0yFpVMwFAYU N1XCpWlO9ax6YXT5NMl38KrQrYefTFj+/PQ5OnxDMUkylwJwCM4KArHhh/Ni0WYE8xS8 kb0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f184-v6si2927389pfg.138.2018.10.26.00.35.44; Fri, 26 Oct 2018 00:36:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbeJZQLK (ORCPT + 99 others); Fri, 26 Oct 2018 12:11:10 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36163 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbeJZQLK (ORCPT ); Fri, 26 Oct 2018 12:11:10 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w9Q7Z4RW137317 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 26 Oct 2018 00:35:05 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w9Q7Z01S137272; Fri, 26 Oct 2018 00:35:00 -0700 Date: Fri, 26 Oct 2018 00:35:00 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Milian Wolff Message-ID: Cc: acme@redhat.com, tglx@linutronix.de, milian.wolff@kdab.com, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, jolsa@kernel.org Reply-To: acme@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, milian.wolff@kdab.com, hpa@zytor.com, mingo@kernel.org In-Reply-To: <20181021191424.16183-2-milian.wolff@kdab.com> References: <20181021191424.16183-2-milian.wolff@kdab.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf script: Flush output stream after events in verbose mode Git-Commit-ID: 7ee40678af935fb489b0c6cf0f75808175214cd7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 7ee40678af935fb489b0c6cf0f75808175214cd7 Gitweb: https://git.kernel.org/tip/7ee40678af935fb489b0c6cf0f75808175214cd7 Author: Milian Wolff AuthorDate: Sun, 21 Oct 2018 21:14:24 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 22 Oct 2018 14:27:11 -0300 perf script: Flush output stream after events in verbose mode 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 = 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 = 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 = 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 = 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 = 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 Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20181021191424.16183-2-milian.wolff@kdab.com Signed-off-by: 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 *script, if (PRINT_FIELD(METRIC)) perf_sample__fprint_metric(script, thread, evsel, sample, fp); + + if (verbose) + fflush(fp); } static struct scripting_ops *scripting_ops;