Received: by 10.213.65.68 with SMTP id h4csp2177404imn; Sun, 8 Apr 2018 21:46:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx48qyg8nQB52av1dvSTCXFjSX3oeURxBSDis4HuvXRTLLebyDU2it9/mOwWclT20eQffkyML X-Received: by 10.99.148.17 with SMTP id m17mr24100469pge.140.1523249190766; Sun, 08 Apr 2018 21:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523249190; cv=none; d=google.com; s=arc-20160816; b=yQjLtab1EdNTfH1V7yvAwsIlgKUtujROstsgZK/+kVN7Qm4GrM1h4y5sgJX+0C1SB2 61mGiNy6fpiKMG9wSJiUEo94nNd3ZrW3hZGSxAl+EWXhjU72GCw/oc67PhKfX1FISyBh jOZ5QmEPuaHHBHV/9ryciTZQ5s3TrqDMkmb92MkkgXnatdrMnn0vK05aROxLuFgnb9Y5 FtOhOuBGmRYFBQZYW2k3TQNDAij31H+a+luzVgAsshlUboTPekI3AqCUe7ehyCWSfE9J w33+4pOR0r5mrJdpblmaAqSI+GzPSwQK18FAzcdE3/NU2GgnPoeypG5GTKD7yVBmp6s1 x7Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=5s21/pY34+iVyFaSQxhOWYVZ6j44ARxHpf71trwK5PE=; b=RzoqqtJklJfzzudOHXYN9dgUrSYxrgFKuWrEzx39PhkkzCtw/MvnuuomedzxqVlNrx 0zGvUAp5X+0VOFwXhT3D8rBi2XJnBH8LKDNmqofeL12NKpWdq98VyeY3HR9lUuSBjScr OEGpfOM6hKnPQuTXRuQPES5tDCyyzPWxAm2SSysSV5RDzRTbPZfPKVCIfPZXH+Xg/vjk 3As7tZOHAasQRXLX+yxEoftzH1BYGWiuXYIfzGRhLONZldESKOUc4XXbtgd2gXA+JA9G SaSrB0cLCPgJv+UgTw37i2iHAEGBeLKolVWR7N+T3M95k1uCZGaZ6r8LLgeDjHVaNnvs +yzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=G81suQ6K; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12-v6si4154995plt.336.2018.04.08.21.45.53; Sun, 08 Apr 2018 21:46:30 -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=@microsoft.com header.s=selector1 header.b=G81suQ6K; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144AbeDIARW (ORCPT + 99 others); Sun, 8 Apr 2018 20:17:22 -0400 Received: from mail-co1nam03on0128.outbound.protection.outlook.com ([104.47.40.128]:49080 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753096AbeDIARO (ORCPT ); Sun, 8 Apr 2018 20:17:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5s21/pY34+iVyFaSQxhOWYVZ6j44ARxHpf71trwK5PE=; b=G81suQ6K4YJuLPWc7rNkbeolZYSSwlHZNPg+8q7XGWr1YfoUZUpH9odDGpFOcY3f/D/+N/HFxW44cJYIhJW5NZKych8XKSmW3LPeKfNd5k9Tw1E+9dHzhci6lUaCxiLQ588em1wk8i21VGftdqnVMPaM24HMuAJQAPnXVYx/c88= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1127.namprd21.prod.outlook.com (52.132.132.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:17:08 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:17:08 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Hendrick Brueckner , Jiri Olsa , Thomas Richter , Wang Nan , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 028/189] perf unwind: Do not look just at the global callchain_param.record_mode Thread-Topic: [PATCH AUTOSEL for 4.15 028/189] perf unwind: Do not look just at the global callchain_param.record_mode Thread-Index: AQHTz5gYWn+VIaTY90aEkU/48zUiww== Date: Mon, 9 Apr 2018 00:17:08 +0000 Message-ID: <20180409001637.162453-28-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1127;7:R9wVOob46ulY3Y5w9ovk41mddfVqjD/lfZnzVcImzFrjz/sDYkUxMDGKdtiw3FK+tjhtbEsfUE4Yu41wex23XtYpyB6rEosbw0Kv2MlOxNzRWChijalrxtIta+eojT323zp4ASEk8wZf3H1s7DYNLE7JTqkDWhgNec7yRhMmFma4kg/CoYIHlVp+ge9ScyQfJvIwKpREEkc5vr5RVXk3EGv9gCjQoTSHEwoxGeuJzRs8lY1CISqGARLK9QlyoAWl;20:aBvra/T9UfiwfUtc5Q01bx+Nm3Iqf+qaG3Zx2MUikPKDkUygXQABH9BWxr+REps2h89xyndoIzXM4B3xJ2Hfb+Pv4keWLBXZq2xYYowNP2iPUAjxefVBPADDPMgb8FmkvxbReH6QOgWaV45gYgWL426KSu31VXRXUJkUTp0r3VM= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: dda97817-f392-46db-0eaf-08d59daf3b72 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1127; x-ms-traffictypediagnostic: DM5PR2101MB1127: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(50582790962513)(85827821059158)(42068640409301)(104084551191319)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1127;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1127; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(39860400002)(376002)(346002)(366004)(189003)(199004)(105586002)(186003)(66066001)(6486002)(54906003)(7736002)(26005)(575784001)(86362001)(316002)(305945005)(110136005)(478600001)(3280700002)(86612001)(10290500003)(25786009)(5250100002)(2616005)(99286004)(22452003)(5660300001)(966005)(3660700001)(2900100001)(81166006)(3846002)(2906002)(106356001)(6506007)(59450400001)(107886003)(486006)(39060400002)(8676002)(81156014)(14454004)(10090500001)(68736007)(4326008)(6116002)(1076002)(72206003)(102836004)(6306002)(97736004)(11346002)(8936002)(476003)(2501003)(6436002)(6512007)(446003)(76176011)(36756003)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1127;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: INsrEeIL7EG+5MfoWWJkpi6bnVBEOeN1Op/5B5c22VW9NingmgzuyUtodkb+qY4WgI618dCWmVtmeQVgiLxVetkaHplRsT6l0XPgugwJ+VLHYIzYlXnONQNO91jNO44iepakb1WrSuESwK0GTwiExOKJZrc0HzuVZNQi5RiZcw8dHXe6BGijJmzyCZQPxyydzuubUPXu2RNM1yVnhAcPXRRmwahGIBHEqBnd8lxWegfwOawcwFZ/aMpEytgTaztLUXFDl/NHM+wrNYrp/0w3sNdKHcOQDXg/WcYo+oxL/8ZUbtfqYKHAf1ktE9S3Pg49J4T52G/uiDboNcP1JX31i6A8NUZfgXdv0u0ppZAke1lZEwA47hLZRxGQpjPXyi/F9EiHJJJ7SnF77OGxb+pwZmuBIBXG91AQhJDU9s3rge8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dda97817-f392-46db-0eaf-08d59daf3b72 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:08.3867 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1127 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo [ Upstream commit eabad8c6856f185f876b54c426c2cc69fe0f0a7d ] When setting up DWARF callchains on specific events, without using 'record' or 'trace' --call-graph, but instead doing it like: perf trace -e cycles/call-graph=3Ddwarf/ The unwind__prepare_access() call in thread__insert_map() when we process PERF_RECORD_MMAP(2) metadata events were not being performed, precluding us from using per-event DWARF callchains, handling them just when we asked for all events to be DWARF, using "--call-graph dwarf". We do it in the PERF_RECORD_MMAP because we have to look at one of the executable maps to figure out the executable type (64-bit, 32-bit) of the DSO laid out in that mmap. Also to look at the architecture where the perf.data file was recorded. All this probably should be deferred to when we process a sample for some thread that has callchains, so that we do this processing only for the threads with samples, not for all of them. For now, fix using DWARF on specific events. Before: # perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=3Ddwarf/ pi= ng -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=3D1 ttl=3D64 time=3D0.048 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev =3D 0.048/0.048/0.048/0.000 ms 0.000 probe_libc:inet_pton:(7fe9597bb350)) Problem processing probe_libc:inet_pton callchain, skipping... # After: # perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=3Ddwarf/ pi= ng -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=3D1 ttl=3D64 time=3D0.060 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev =3D 0.060/0.060/0.060/0.000 ms 0.000 probe_libc:inet_pton:(7fd4aa930350)) __inet_pton (inlined) gaih_inet.constprop.7 (/usr/lib64/= libc-2.26.so) __GI_getaddrinfo (inlined) [0xffffaa804e51af3f] (/usr/bin/pin= g) __libc_start_main (/usr/lib64/libc= -2.26.so) [0xffffaa804e51b379] (/usr/bin/pin= g) # # perf trace --call-graph=3Ddwarf --no-syscalls -e probe_libc:inet_pton/c= all-graph=3Ddwarf/ ping -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=3D1 ttl=3D64 time=3D0.057 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev =3D 0.057/0.057/0.057/0.000 ms 0.000 probe_libc:inet_pton:(7f9363b9e350)) __inet_pton (inlined) gaih_inet.constprop.7 (/usr/lib64/= libc-2.26.so) __GI_getaddrinfo (inlined) [0xffffa9e8a14e0f3f] (/usr/bin/pin= g) __libc_start_main (/usr/lib64/libc= -2.26.so) [0xffffa9e8a14e1379] (/usr/bin/pin= g) # # perf trace --call-graph=3Dfp --no-syscalls -e probe_libc:inet_pton/call= -graph=3Ddwarf/ ping -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=3D1 ttl=3D64 time=3D0.077 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev =3D 0.077/0.077/0.077/0.000 ms 0.000 probe_libc:inet_pton:(7f4947e1c350)) __inet_pton (inlined) gaih_inet.constprop.7 (/usr/lib64/= libc-2.26.so) __GI_getaddrinfo (inlined) [0xffffaa716d88ef3f] (/usr/bin/pin= g) __libc_start_main (/usr/lib64/libc= -2.26.so) [0xffffaa716d88f379] (/usr/bin/pin= g) # # perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=3Dfp/ ping = -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=3D1 ttl=3D64 time=3D0.078 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev =3D 0.078/0.078/0.078/0.000 ms 0.000 probe_libc:inet_pton:(7fa157696350)) __GI___inet_pton (/usr/lib64/libc-= 2.26.so) getaddrinfo (/usr/lib64/libc-2.26.= so) [0xffffa9ba39c74f40] (/usr/bin/pin= g) # Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: David Ahern Cc: Hendrick Brueckner Cc: Jiri Olsa Cc: Thomas Richter Cc: Wang Nan Link: https://lkml.kernel.org/r/20180116182650.GE16107@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-c2c.c | 5 +++-- tools/perf/builtin-report.c | 5 +++-- tools/perf/builtin-script.c | 5 +++-- tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/util/callchain.c | 10 ++++++++++ tools/perf/util/callchain.h | 2 ++ tools/perf/util/unwind-libunwind-local.c | 9 +++------ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 17855c4626a0..c8a5faaca47f 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2393,9 +2393,10 @@ static int setup_callchain(struct perf_evlist *evlis= t) enum perf_call_graph_mode mode =3D CALLCHAIN_NONE; =20 if ((sample_type & PERF_SAMPLE_REGS_USER) && - (sample_type & PERF_SAMPLE_STACK_USER)) + (sample_type & PERF_SAMPLE_STACK_USER)) { mode =3D CALLCHAIN_DWARF; - else if (sample_type & PERF_SAMPLE_BRANCH_STACK) + dwarf_callchain_users =3D true; + } else if (sample_type & PERF_SAMPLE_BRANCH_STACK) mode =3D CALLCHAIN_LBR; else if (sample_type & PERF_SAMPLE_CALLCHAIN) mode =3D CALLCHAIN_FP; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index af5dd038195e..ca2ed616236e 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -312,9 +312,10 @@ static int report__setup_sample_type(struct report *re= p) =20 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) { if ((sample_type & PERF_SAMPLE_REGS_USER) && - (sample_type & PERF_SAMPLE_STACK_USER)) + (sample_type & PERF_SAMPLE_STACK_USER)) { callchain_param.record_mode =3D CALLCHAIN_DWARF; - else if (sample_type & PERF_SAMPLE_BRANCH_STACK) + dwarf_callchain_users =3D true; + } else if (sample_type & PERF_SAMPLE_BRANCH_STACK) callchain_param.record_mode =3D CALLCHAIN_LBR; else callchain_param.record_mode =3D CALLCHAIN_FP; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9b43bda45a41..fc3974b1d8fd 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2758,9 +2758,10 @@ static void script__setup_sample_type(struct perf_sc= ript *script) =20 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) { if ((sample_type & PERF_SAMPLE_REGS_USER) && - (sample_type & PERF_SAMPLE_STACK_USER)) + (sample_type & PERF_SAMPLE_STACK_USER)) { callchain_param.record_mode =3D CALLCHAIN_DWARF; - else if (sample_type & PERF_SAMPLE_BRANCH_STACK) + dwarf_callchain_users =3D true; + } else if (sample_type & PERF_SAMPLE_BRANCH_STACK) callchain_param.record_mode =3D CALLCHAIN_LBR; else callchain_param.record_mode =3D CALLCHAIN_FP; diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwin= d.c index ac40e05bcab4..260418969120 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -173,6 +173,7 @@ int test__dwarf_unwind(struct test *test __maybe_unused= , int subtest __maybe_unu } =20 callchain_param.record_mode =3D CALLCHAIN_DWARF; + dwarf_callchain_users =3D true; =20 if (init_live_machine(machine)) { pr_err("Could not init machine\n"); diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 082505d08d72..32ef7bdca1cf 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -37,6 +37,15 @@ struct callchain_param callchain_param =3D { CALLCHAIN_PARAM_DEFAULT }; =20 +/* + * Are there any events usind DWARF callchains? + * + * I.e. + * + * -e cycles/call-graph=3Ddwarf/ + */ +bool dwarf_callchain_users; + struct callchain_param callchain_param_default =3D { CALLCHAIN_PARAM_DEFAULT }; @@ -265,6 +274,7 @@ int parse_callchain_record(const char *arg, struct call= chain_param *param) ret =3D 0; param->record_mode =3D CALLCHAIN_DWARF; param->dump_size =3D default_stack_dump_size; + dwarf_callchain_users =3D true; =20 tok =3D strtok_r(NULL, ",", &saveptr); if (tok) { diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index b79ef2478a57..154560b1eb65 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -89,6 +89,8 @@ enum chain_value { CCVAL_COUNT, }; =20 +extern bool dwarf_callchain_users; + struct callchain_param { bool enabled; enum perf_call_graph_mode record_mode; diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unw= ind-libunwind-local.c index 7a42f703e858..af873044d33a 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -631,9 +631,8 @@ static unw_accessors_t accessors =3D { =20 static int _unwind__prepare_access(struct thread *thread) { - if (callchain_param.record_mode !=3D CALLCHAIN_DWARF) + if (!dwarf_callchain_users) return 0; - thread->addr_space =3D unw_create_addr_space(&accessors, 0); if (!thread->addr_space) { pr_err("unwind: Can't create unwind address space.\n"); @@ -646,17 +645,15 @@ static int _unwind__prepare_access(struct thread *thr= ead) =20 static void _unwind__flush_access(struct thread *thread) { - if (callchain_param.record_mode !=3D CALLCHAIN_DWARF) + if (!dwarf_callchain_users) return; - unw_flush_cache(thread->addr_space, 0, 0); } =20 static void _unwind__finish_access(struct thread *thread) { - if (callchain_param.record_mode !=3D CALLCHAIN_DWARF) + if (!dwarf_callchain_users) return; - unw_destroy_addr_space(thread->addr_space); } =20 --=20 2.15.1