Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2109187ima; Mon, 22 Oct 2018 04:33:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV60OAefh7OlIIU33psFfffjmn3hk+3Xb14+j4wZvkulx/GQcyz3t4okcTfEJb/0xpwiLg85z X-Received: by 2002:a65:40c2:: with SMTP id u2-v6mr42568172pgp.123.1540208025043; Mon, 22 Oct 2018 04:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540208024; cv=none; d=google.com; s=arc-20160816; b=kukH2tdLycsIe01yxeAmBHAEP5nwH/ZLWvxzImYGgYUw69VP0+FKMdJnoXvbba+UpH QiFe460h9Zt/c/iDh3wHo1R9xQ07UlFohrg6hwHQb36iX0ViLszWc1jult14fM2/yt8j 2Y+8TAK/l7KyWf6Nvgt8k+Ik7UlkWeZEfefOMFpWuFksyuc5uXoPJwXuv4jGCEJVcJBe TmpQY73PYfNt7Cy49BsUemAm69BxABMFer7tEefjr4+NuDeXY3LtZreSGAHasgvnsm5y yxaWUe693DTcWu8ZMulL81/22/KxTRE44Yz+Xz65jIk4VumU1oPkgFMZZs1w5LwIZKTd /LcQ== 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=XK+0f2NthNGHWAL093QGqGT71nXea1FsUufq2tPozew=; b=xCD3BbiLP843tL6jRPqZP0e+PRC1mBE9h+D/Izox1mp5OdiJHuo78rwkp6TnMh+/ou 22kv6Hfce8dbMKbDyhSwjQmQ0K90N8MuQ8Il5Hz6Jw5xtPkdCyRYJbYSrsN8pJ0NA3nt buMmT5XbBVzoUuYnIAEwLRWQlve7+WNjAdFpFyeaV0OemBKtluh4BL0PvbSx+gYMc1J1 IKsAs0MGHxnOkQxxqbSMwjwKcbHrY1vXHQxQWDZ3T4f9sw96JyFE0YaxeXPe5aa2e7MW 5RzU2Q4vpDIZeGqSsGwzpO/sm9yxPA4Qn0t8o6egDPPhOHWHgFo2lRI3fcq5t8navR0e xUFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=VKXdzszu; 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 f62-v6si35238787plf.288.2018.10.22.04.33.28; Mon, 22 Oct 2018 04:33:44 -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=VKXdzszu; 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 S1728352AbeJVS1Y (ORCPT + 99 others); Mon, 22 Oct 2018 14:27:24 -0400 Received: from mail.kdab.com ([176.9.126.58]:60187 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbeJVS1X (ORCPT ); Mon, 22 Oct 2018 14:27:23 -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=1540202966; x=1541066967; bh=XK+0f2NthNGHWAL093QGqGT71nX ea1FsUufq2tPozew=; b=VKXdzszuQBTE2mU0fvzo9aTBMCIxt09l7cC2MAgq5sP oA7wwxV+rw6c6VzqR3KxgBlfG4QeFPdFvggIlrG0euClFCPNz9VCikPH1ReJR0ig H5s1P39szlFOSI7D+xVZ61DwejO3LJ2ywsDHt9uRKsjVYLCwlO4DRVNhLYoelTE8 = 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:09:22 +0200 Message-ID: <4444017.LnbBPIbh24@agathebauer> Organization: KDAB In-Reply-To: <20181022094317.GG2452@krava> References: <20181021191424.16183-1-milian.wolff@kdab.com> <20181021191424.16183-2-milian.wolff@kdab.com> <20181022094317.GG2452@krava> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3629398.2PHXbrJRRo"; 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 --nextPart3629398.2PHXbrJRRo Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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? 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 --nextPart3629398.2PHXbrJRRo Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCDEIw ggXmMIIDzqADAgECAhBqm+E4O/8ra58B1dm4p1JWMA0GCSqGSIb3DQEBDAUAMIGFMQswCQYDVQQG EwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYD VQQKExFDT01PRE8gQ0EgTGltaXRlZDErMCkGA1UEAxMiQ09NT0RPIFJTQSBDZXJ0aWZpY2F0aW9u IEF1dGhvcml0eTAeFw0xMzAxMTAwMDAwMDBaFw0yODAxMDkyMzU5NTlaMIGXMQswCQYDVQQGEwJH QjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQK ExFDT01PRE8gQ0EgTGltaXRlZDE9MDsGA1UEAxM0Q09NT0RPIFJTQSBDbGllbnQgQXV0aGVudGlj YXRpb24gYW5kIFNlY3VyZSBFbWFpbCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB AL6znlesKHZ1QBbHOAOY08YYdiFQ8yV5C0y1oNF9Olg+nKcxLqf2NHbZhGra0D00SOTq9bus3/m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