Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2061574ima; Mon, 22 Oct 2018 03:39:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60FKYt15ZDgzS+fRU8Ghgz0NYsd9RZZ1dZ8t+Ocq63Z8ZexPevxnvXMk/BSWMk63hIBvd/L X-Received: by 2002:a62:2683:: with SMTP id m125-v6mr20963549pfm.74.1540204794199; Mon, 22 Oct 2018 03:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540204794; cv=none; d=google.com; s=arc-20160816; b=uFHq5K8mjLIPMHWZojcVLLtVwL8pd0BmtIozwbHiu95c/3Mc7+ItYLHoVu3nHnMZxx /RxsAZaYmT4LFDVV+qvYX2jZnCps0kIapdA24AOafc49KkQbHKTyChCMUyVJp/0Pi2eC l/FauS/cTNbi4Fd+G9LxS1cdxct/n5ZePWIMUqFQ6O0ckVwtzaJ+2p/b7g2LkO4gThvs /T21vBd/P7oo9sZ5eXqLsIoWl0J01CoIGjZgRAdA4dfvLh29M7rkeQnzaej94hmxOjuk UaoeoYW4gp7aVstUOOLX+M3VG/LezV1f6cOkzPA4PgOiZzWYlDNvuf+HZ+630iiMTmnn qVKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:dkim-signature; bh=AwOxzojX3NgSc1VFeI7VzQ1aMKiLcrsYE3HU/8yyyEE=; b=exe/BOZS99rHuTRckGTV+8S86LuCScOZEAIF+aM7GVHknw8OU9aLj5AmuoVoouBLyY gTLcrBLipnr46Xr4ROkXfFS0hPJsbWH8jaaDRp3+TdMdCEIW4SYUbUJElWdGoaNuKB6H HTMk52mg8nVXUl0qF4CSxDf/tYBu4BNhYxnr0oByruC8B47QJPU732gf7M99HzLVdBuL q9r/nUHzj2H4yiWJJ3BarSdXokq14WE72sQqbK/HV9KZi9qUJWkLhu0SXiVnzyHIISls wDvhbW0mJhNLkQUh4YzEas+a5GjKHVewCnQntiKhA3m4ht/oNdAGBB87Usu4Af87QU0R t3JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=Pkz6zlSd; 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 z27-v6si33364307pgk.297.2018.10.22.03.39.38; Mon, 22 Oct 2018 03:39:53 -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=Pkz6zlSd; 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 S1728564AbeJVS5D (ORCPT + 99 others); Mon, 22 Oct 2018 14:57:03 -0400 Received: from mail.kdab.com ([176.9.126.58]:7788 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbeJVS5D (ORCPT ); Mon, 22 Oct 2018 14:57:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdab.com; h= content-type:content-type:mime-version:references:in-reply-to :organization:message-id:date:date:subject:subject:from:from; s= dkim; t=1540204738; x=1541068739; bh=AwOxzojX3NgSc1VFeI7VzQ1aMKi LcrsYE3HU/8yyyEE=; b=Pkz6zlSdw4lZqAi84k6xvkqpuKVAkWY1X+gL/mehJT4 icekfajdxCa3s7o1qtITMQn2e1XJIYmmszi3lTtKodk75Eh62OThiD90CSGOxI2f Jz2Rk0oG8lp7I8f+19e+vJYbQelBDa5mvSc21m/pn6fCTwlOjR0XUMgEJyE10sbo = X-Virus-Scanned: amavisd-new at kdab.com From: Milian Wolff To: Jiri Olsa 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 Date: Mon, 22 Oct 2018 12:38:57 +0200 Message-ID: <1755624.MxyOU8z0WO@agathebauer> Organization: KDAB In-Reply-To: <20181022101618.GH2452@krava> References: <20181021191424.16183-1-milian.wolff@kdab.com> <4444017.LnbBPIbh24@agathebauer> <20181022101618.GH2452@krava> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2852350.Qm4K0Tgxqp"; micalg="sha256"; protocol="application/pkcs7-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart2852350.Qm4K0Tgxqp Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Montag, 22. Oktober 2018 12:16:18 CEST Jiri Olsa wrote: > 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 Exactly, and that's achieved with this patch form what I see :) Or should we maybe instead call setbuf(fp, NULL); in verbose mode? Thanks -- Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt, C++ and OpenGL Experts --nextPart2852350.Qm4K0Tgxqp Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCDEIw ggXmMIIDzqADAgECAhBqm+E4O/8ra58B1dm4p1JWMA0GCSqGSIb3DQEBDAUAMIGFMQswCQYDVQQG EwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYD VQQKExFDT01PRE8gQ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