Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2046335ima; Mon, 22 Oct 2018 03:21:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV62o9Fn3It1DR3l+SN5Q6BHGsThY9/43y7aE4nLB5iqysMD3Xy5/DlbU55Dcd3J6AGklq/Up X-Received: by 2002:a63:8f09:: with SMTP id n9-v6mr41760913pgd.222.1540203670436; Mon, 22 Oct 2018 03:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540203670; cv=none; d=google.com; s=arc-20160816; b=neHL0z/YZt72jfmNgYnoZFeWgb3uX5yiqpN6U8ZOGbvEKysYgZ4D0F34k3rhe/W0v8 W2HSJPe443m5ujl0NmcVczrTolJ9amM5ts/Z/NRcPwKrGeQsEQDNZFepzX9ktjVM4uXt 4E3a1klzw0+Ewx0vITQh/O5ezMZKGRYaYUgSxI10B9fk7wOBn9HPk1Y6vVNURYhJGa0Z euTGm5+I4hU9ijGXaKh2EYw1pX/CrM9f1udhSfOvGi0vnNBnIF4dYobnEUIEcbaLQMPK /4l3fF/6vjGxrpi0xZe7lWUP+wiH1+mtPQTip1h22mUR8QtMop6oTpVPYmx+AFAWgbsV A38A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=W5HBHUEll3+AgXsKLshCiJVsosfh3RZCw2JLV0jQ/UM=; b=aED08ZnlEZKX1U+7Nzuk7eQDuBwPmIpyrvMQZXVl2BE+UQn3X841zHMsRh1frBGrH/ /XsyiUSQVAeEGOf1mrIBql/H9NxiaHnADCfmuTIPTwcAmV9oFNp/N0dcFR28KzvjfrdK DVC3IJq0Q8S3zwuiNpaOBPCYjd+a/G6V2GF5IAs0FsZkJ1EcMAZjnFHc4UKTb+2TFiY0 wJRuFr014XsYFQqX/woaNAAjhQ1yFrkFBbAoE41J93m2rTjo0w7OLoRF8RyNDHm7ZcMr eTsNK/0KxLJnlxyAguYw2PmkEqKhaoWW3gY8yEp8CwaZdmihA8NdvGEQaY2q0jPAdnz3 Dm3A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s10-v6si35889536pgf.434.2018.10.22.03.20.55; Mon, 22 Oct 2018 03:21:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbeJVSeN (ORCPT + 99 others); Mon, 22 Oct 2018 14:34:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44684 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbeJVSeN (ORCPT ); Mon, 22 Oct 2018 14:34:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05E2A3082125; Mon, 22 Oct 2018 10:16:20 +0000 (UTC) Received: from krava (unknown [10.43.17.150]) by smtp.corp.redhat.com (Postfix) with SMTP id CA2545DA67; Mon, 22 Oct 2018 10:16:18 +0000 (UTC) Date: Mon, 22 Oct 2018 12:16:18 +0200 From: Jiri Olsa To: Milian Wolff Cc: acme@kernel.org, jolsa@kernel.org, Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 2/2] perf script: flush output stream after events in verbose mode Message-ID: <20181022101618.GH2452@krava> References: <20181021191424.16183-1-milian.wolff@kdab.com> <20181021191424.16183-2-milian.wolff@kdab.com> <20181022094317.GG2452@krava> <4444017.LnbBPIbh24@agathebauer> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4444017.LnbBPIbh24@agathebauer> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 22 Oct 2018 10:16:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 22, 2018 at 12:09:22PM +0200, Milian Wolff wrote: > On Montag, 22. Oktober 2018 11:43:17 CEST Jiri Olsa wrote: > > On Sun, Oct 21, 2018 at 09:14:24PM +0200, Milian Wolff wrote: > > > 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. > > > > yep, I plan to check on this ;-) > > > > > 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 > > > *script, > > > > > > if (PRINT_FIELD(METRIC)) > > > > > > perf_sample__fprint_metric(script, thread, evsel, sample, fp); > > > > > > + > > > + if (verbose) > > > + fflush(fp); > > > > should we call fflush(NULL) to dump all the streams? > > > > the verbose goes to stderr and fp seems to be stdout byt default > > stderr isn't buffered, so we don't need to flush it. So personally, I don't > see a need to dump all streams - fp should be enough? Can you maybe explain > where it would be required to flush more buffers? hum, did not know stderr wasn't buffer I think there's perf script feature to store the events data to separate files per each event.. but I guess we don't need to flush them.. we just need to have stdout and stderr in sync IIUC jirka