Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2015839ima; Mon, 22 Oct 2018 02:44:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV63GYNS3Mx5X+SQxhjOQBAC4jS+ksesQr7dmGzcvO9XQH33h7f076okpoFQYwqHMNcoh9Tsy X-Received: by 2002:a17:902:b58c:: with SMTP id a12-v6mr42785367pls.226.1540201457589; Mon, 22 Oct 2018 02:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540201457; cv=none; d=google.com; s=arc-20160816; b=h3B42dT9TvYt0pBQHk+/288/uUPVZvxk+FUdTRkzbdafkalKwggEctcc/3YgWqZied WeCcKatKlEsHwSn7DSF+6aO1saNf9Z1voAjmbTiSTZ8fEXAAm3/iAyyzV0Rz8pM3j7jm Q/VoLUyzDRgsXVREydY3dXCi1hsXTAcnHGcbU/BlwqTXGpVsE4NNdsAnQae4+ukm7TEZ ONBlp7yxa2ZS7mGOk1CL6EZsj2WPwbLv54iXh9ARTSiv60e3ylwoifrcBRnvU0YCOHF1 CFdgYrj7zKYk4vmUOGDmf1SyFABECVmtQAm/ipfn+CIF0AsMYLwWbPpJ79yttIjQW/bE xVtg== 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=NqGmMlMIMB5nl8bleSuDIorEtOqSsaz2cqD88vVE+94=; b=LodGA9Pq4m5ICOI0/JHzz9lQ8/1pe514FFsaXy5kBrUSIdEY3gnxAww0PA9s12K2WE UhtiZywkLOKJ0L28DO3K2pT/9POC67OytMNEFhOO6qO1dJoZ1dW+mOBotCIU/Gbuh4GA DabFd13tQAxFwDemFKwCM+RQX255rcDidJpbXeVSpdgBVt9GLAEJlhbTngU5PXN937uS XHQGf9lWv8h6T0m8mkk3km54Fk2OF5ty1tH4LMdypD/wh976HSFVnYLWAtBchOWkT+fS TD9/eXvKM9E4vngfe1xEZvZXNpykXCN6CsD23Z+TkunesOZkGk6azpE1E7ex4MHOryuI iEbg== 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 w19-v6si26780028pgf.197.2018.10.22.02.44.02; Mon, 22 Oct 2018 02:44:17 -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 S1728516AbeJVSBG (ORCPT + 99 others); Mon, 22 Oct 2018 14:01:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55438 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728348AbeJVSBG (ORCPT ); Mon, 22 Oct 2018 14:01:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1DAA5A1C4; Mon, 22 Oct 2018 09:43:19 +0000 (UTC) Received: from krava (unknown [10.43.17.150]) by smtp.corp.redhat.com (Postfix) with SMTP id 5B98A5D777; Mon, 22 Oct 2018 09:43:18 +0000 (UTC) Date: Mon, 22 Oct 2018 11:43:17 +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: <20181022094317.GG2452@krava> References: <20181021191424.16183-1-milian.wolff@kdab.com> <20181021191424.16183-2-milian.wolff@kdab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181021191424.16183-2-milian.wolff@kdab.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 22 Oct 2018 09:43:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 jirka