Received: by 10.213.65.68 with SMTP id h4csp2115496imn; Sun, 8 Apr 2018 20:06:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4840EiJfpQOmffePbfb5YgYvS6P4QzeOR994Z4B7x+/llJHhzlqqb/H3ZjNH1jgCmYq/4y+ X-Received: by 10.99.171.72 with SMTP id k8mr24448249pgp.355.1523243166065; Sun, 08 Apr 2018 20:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243166; cv=none; d=google.com; s=arc-20160816; b=ceuZ/NMhoQxaeHVb9qWxhNJdhUhCDg6N2Krn0h1gSjwZiDarUa6YMz/vH/fEQJ3YMz OlJ6qEnIniS0GEfuO2dk0SQ3zHyvGBjKczqOZ2WlwWCKsi4krtn1liarNLV86Bmmo/NE GuadtDcf5X3EtfuYuAO/CK/lu0T+uweBHnBOhgLVxjyQPkY38bm73kKell9AFsDCNn9u t0sfFR9oYJesgB3gYYdTIZHwAaQSWYBJZHLBqBF2aXbq3zHBLiRZtr1V1uk0dCOE1K1d qfib+FiRbHXh8Yyok8dpzfH8E58UL3eBHlVJnifTEYA3qjKK/osvzLDL9BGBJht0eZIu CH9g== 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=dFjE5+Dmta7yu0tsbMQggNFUCa6RAaOTMGlPFACV7II=; b=wiPvH+Pv/OObWIAr0hspfwqlPDndqeHcNLYUJCY5gtMa7B62TI1PSk7xdWv2gI9kLm hw2OszeTVeHrpUiNPhhJX3B4wsSRmLZYfJubzvIAQ06wRpQbFDCzJw4Es7BPBMlljMju EfE8zrELpgJAnxljgbYxutLev1N6RdTHpjUl50sP2WkcOpHCtkjL9BAsutOUACz1ZjR9 ZbS13uC8JQ3MLwpIbwt5zFMpCR/icsnODtagR+FAC1SYFRtS3CzeIFuFsAnkHPN9GvwF 5KA9HyyJTIX2KgU8RnzisZ3uQV0QQQKxg9wdFQfxKoaBN/oZUK9RSK0iolzsfSUODjnh nHjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=X47fHjs2; 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 44-v6si15804817plb.635.2018.04.08.20.05.29; Sun, 08 Apr 2018 20:06:06 -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=X47fHjs2; 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 S1755857AbeDIA2e (ORCPT + 99 others); Sun, 8 Apr 2018 20:28:34 -0400 Received: from mail-sn1nam02on0093.outbound.protection.outlook.com ([104.47.36.93]:56217 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755842AbeDIA23 (ORCPT ); Sun, 8 Apr 2018 20:28:29 -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=dFjE5+Dmta7yu0tsbMQggNFUCa6RAaOTMGlPFACV7II=; b=X47fHjs2nPCGuk2qqvpW7DIfIVSnF4RceW6xRBEaH4q4codHKZln/IYyJ/bmnNsI+sxA1h+cNoE9i+hftmehn8tNOzr2XtATpJcN4urcHTZDSBMDQ0hIcFzvflLyVneMvegvR67WG2khle427eDVniku4S3usBhZtBajy/Nn9nI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0871.namprd21.prod.outlook.com (10.167.110.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.2; Mon, 9 Apr 2018 00:28:20 +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:28:20 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Arnaldo Carvalho de Melo , Adrian Hunter , Alexander Shishkin , David Ahern , Namhyung Kim , Peter Zijlstra , Wang Nan , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 072/293] perf evsel: Fix probing of precise_ip level for default cycles event Thread-Topic: [PATCH AUTOSEL for 4.9 072/293] perf evsel: Fix probing of precise_ip level for default cycles event Thread-Index: AQHTz5kIwDEed94dWUuuEtJTFzE3zA== Date: Mon, 9 Apr 2018 00:23:50 +0000 Message-ID: <20180409002239.163177-72-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0871;7:2q3pzIqtmu868Tcy6kb7Nl83jVhNBgkLCr7eyS6Fl9fClt6GPbpnhAzJZBRFUWAxzC2uYYbPLrSl4I/3BnahnN6tGbuIlNUAnSff3ZuvhxD40xR7zCtBCtQ9x9z5/iE0QOy9ZePFgzGvO2lNBYW8FYHZtrBMg7IAqMDbxvbyRqlneLLxloSp1qjhryfD5YavoKrLqD+2eKWbhxnxljceyCh0hzNPKhYh6oKhX3oFYgQlzc6sbpvMUnZhV+RhzuTI;20:DEDFIYeNPOqNL4eQs6chTVraSg/pEdjlGJoz82rTkeFAhEztBEQKi9yIYGbBffUfofwzwY7zH+S8kf1c4L1HbWNlkdi1jSAeEEStRbiGACCzV1FfUjOWmtRIrpXbbuHcgwptGPJ79ZiGEUkUEEp9DKe4z2c1XzWjia87AMUSqDA= X-MS-Office365-Filtering-Correlation-Id: 5b7b7759-14ee-449e-62d0-08d59db0cc48 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB0871; x-ms-traffictypediagnostic: DM5PR2101MB0871: 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)(84791874153150)(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:DM5PR2101MB0871;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0871; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(396003)(39380400002)(376002)(39860400002)(199004)(189003)(105586002)(8676002)(59450400001)(3660700001)(3280700002)(6506007)(81156014)(81166006)(14454004)(99286004)(72206003)(110136005)(8936002)(54906003)(305945005)(2906002)(316002)(966005)(10290500003)(478600001)(7736002)(53936002)(6512007)(486006)(11346002)(39060400002)(4326008)(6306002)(86362001)(575784001)(446003)(3846002)(102836004)(76176011)(476003)(25786009)(22452003)(36756003)(107886003)(6666003)(10090500001)(5660300001)(6486002)(86612001)(6436002)(2616005)(68736007)(26005)(1076002)(186003)(2501003)(5250100002)(2900100001)(106356001)(66066001)(6116002)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0871;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bIm1Tn1L/Z6sfA3MzZXJSco5/nIZWkhsv32/6TQsD100c5QQuom2gtW5SH2ep/oSm+CAeGnSUbGZTx9aVurSA2Q50GEIe6FR5eAk/hI5S6g4fN6dEiarLynASuR3edt+mk6Lzmg6RH2LH0t3WUpEKHwmUF6EAX2SVmhS1MdteJJUR2huh0z2nOzC2mYbHOgIJNP0kCG558vprYHWPPRfl8FQo/LP4fYb9TBWvh+NfbCSAnfzOtiSjz/oy7LI/Vp/QTVi3ksCmD6pAAiuR2zHdrlwwMi+uDXyZqub2ZeKYehEtNo4/aBwd1jmy1fQdaU3s7rnUN1dh1mCvbA0MC92xCp5qPQxm5kpFX7+/W0Kqphb58l+eeFdJArzMipTrs6RSttWSykM9BUU+MZCyIV2tgEiYMlVns+8dm8LrHJdoks= 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: 5b7b7759-14ee-449e-62d0-08d59db0cc48 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:23:50.2218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0871 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 7a1ac110c22eb726684c837544a2d42c33e07be7 ] Since commit 18e7a45af91a ("perf/x86: Reject non sampling events with precise_ip") returns -EINVAL for sys_perf_event_open() with an attribute with (attr.precise_ip > 0 && attr.sample_period =3D=3D 0), just like is don= e in the routine used to probe the max precise level when no events were passed to 'perf record' or 'perf top', i.e.: perf_evsel__new_cycles() perf_event_attr__set_max_precise_ip() The x86 code, in x86_pmu_hw_config(), which is called all the way from sys_perf_event_open() did, starting with the aforementioned commit: /* There's no sense in having PEBS for non sampling events:= */ if (!is_sampling_event(event)) return -EINVAL; Which makes it fail for cycles:ppp, cycles:pp and cycles:p, always using just the non precise cycles variant. To make sure that this is the case, I tested it, before this patch, with: # perf probe -L x86_pmu_hw_config 0 int x86_pmu_hw_config(struct perf_event *event) 1 { 2 if (event->attr.precise_ip) { 17 if (event->attr.precise_ip > precise) 18 return -EOPNOTSUPP; /* There's no sense in having PEBS for non sampli= ng events: */ 21 if (!is_sampling_event(event)) 22 return -EINVAL; } # perf probe x86_pmu_hw_config:22 Added new events: probe:x86_pmu_hw_config (on x86_pmu_hw_config:22) probe:x86_pmu_hw_config_1 (on x86_pmu_hw_config:22) You can now use it in all perf tools, such as: perf record -e probe:x86_pmu_hw_config_1 -aR sleep 1 # perf trace -e perf_event_open,probe:x86_pmu_hwconfig*/max-stack=3D16/ p= erf record usleep 1 0.000 ( 0.015 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110= , cpu: -1, group_fd: -1 ) ... 0.015 ( ): probe:x86_pmu_hw_config:(ffffffff9c0065e1)) x86_pmu_hw_config ([kernel.kallsyms]= ) hsw_hw_config ([kernel.kallsyms]) x86_pmu_event_init ([kernel.kallsyms= ]) perf_try_init_event ([kernel.kallsym= s]) perf_event_alloc ([kernel.kallsyms]) SYSC_perf_event_open ([kernel.kallsy= ms]) sys_perf_event_open ([kernel.kallsym= s]) do_syscall_64 ([kernel.kallsyms]) return_from_SYSCALL_64 ([kernel.kall= syms]) syscall (/usr/lib64/libc-2.24.so) perf_event_attr__set_max_precise_ip = (/home/acme/bin/perf) perf_evsel__new_cycles (/home/acme/b= in/perf) perf_evlist__add_default (/home/acme= /bin/perf) cmd_record (/home/acme/bin/perf) run_builtin (/home/acme/bin/perf) handle_internal_command (/home/acme/= bin/perf) 0.000 ( 0.021 ms): perf/4150 ... [continued]: perf_event_open()) =3D = -1 EINVAL Invalid argument 0.023 ( 0.002 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110= , cpu: -1, group_fd: -1 ) ... 0.025 ( ): probe:x86_pmu_hw_config:(ffffffff9c0065e1)) x86_pmu_hw_config ([kernel.kallsyms]= ) hsw_hw_config ([kernel.kallsyms]) x86_pmu_event_init ([kernel.kallsyms= ]) perf_try_init_event ([kernel.kallsym= s]) perf_event_alloc ([kernel.kallsyms]) SYSC_perf_event_open ([kernel.kallsy= ms]) sys_perf_event_open ([kernel.kallsym= s]) do_syscall_64 ([kernel.kallsyms]) return_from_SYSCALL_64 ([kernel.kall= syms]) syscall (/usr/lib64/libc-2.24.so) perf_event_attr__set_max_precise_ip = (/home/acme/bin/perf) perf_evsel__new_cycles (/home/acme/b= in/perf) perf_evlist__add_default (/home/acme= /bin/perf) cmd_record (/home/acme/bin/perf) run_builtin (/home/acme/bin/perf) handle_internal_command (/home/acme/= bin/perf) 0.023 ( 0.004 ms): perf/4150 ... [continued]: perf_event_open()) =3D = -1 EINVAL Invalid argument 0.028 ( 0.002 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110= , cpu: -1, group_fd: -1 ) ... 0.030 ( ): probe:x86_pmu_hw_config:(ffffffff9c0065e1)) x86_pmu_hw_config ([kernel.kallsyms]= ) hsw_hw_config ([kernel.kallsyms]) x86_pmu_event_init ([kernel.kallsyms= ]) perf_try_init_event ([kernel.kallsym= s]) perf_event_alloc ([kernel.kallsyms]) SYSC_perf_event_open ([kernel.kallsy= ms]) sys_perf_event_open ([kernel.kallsym= s]) do_syscall_64 ([kernel.kallsyms]) return_from_SYSCALL_64 ([kernel.kall= syms]) syscall (/usr/lib64/libc-2.24.so) perf_event_attr__set_max_precise_ip = (/home/acme/bin/perf) perf_evsel__new_cycles (/home/acme/b= in/perf) perf_evlist__add_default (/home/acme= /bin/perf) cmd_record (/home/acme/bin/perf) run_builtin (/home/acme/bin/perf) handle_internal_command (/home/acme/= bin/perf) 0.028 ( 0.004 ms): perf/4150 ... [continued]: perf_event_open()) =3D = -1 EINVAL Invalid argument 41.018 ( 0.012 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8b5dd0= , pid: -1, group_fd: -1, flags: FD_CLOEXEC) =3D 4 41.065 ( 0.011 ms): perf/4150 perf_event_open(attr_uptr: 0x3c7db78, pid= : -1, group_fd: -1, flags: FD_CLOEXEC) =3D 4 41.080 ( 0.006 ms): perf/4150 perf_event_open(attr_uptr: 0x3c7db78, pid= : -1, group_fd: -1, flags: FD_CLOEXEC) =3D 4 41.103 ( 0.010 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid= : 4151 (perf), group_fd: -1, flags: FD_CLOEXEC) =3D 4 41.115 ( 0.006 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid= : 4151 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) =3D 5 41.122 ( 0.004 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid= : 4151 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) =3D 6 41.128 ( 0.008 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid= : 4151 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) =3D 8 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ] # I.e. that return -EINVAL in x86_pmu_hw_config() is hit three times. So fix it by just setting attr.sample_period Now, after this patch: # perf trace --max-stack=3D2 -e perf_event_open,probe:x86_pmu_hw_config* = perf record usleep 1 [ perf record: Woken up 1 times to write data ] 0.000 ( 0.017 ms): perf/8469 perf_event_open(attr_uptr: 0x7ffe36c27d10= , pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) =3D 4 syscall (/usr/lib64/libc-2.24.so) perf_event_open_cloexec_flag (/home/= acme/bin/perf) 0.050 ( 0.031 ms): perf/8469 perf_event_open(attr_uptr: 0x24ebb78, pid= : -1, group_fd: -1, flags: FD_CLOEXEC) =3D 4 syscall (/usr/lib64/libc-2.24.so) perf_evlist__config (/home/acme/bin/= perf) 0.092 ( 0.040 ms): perf/8469 perf_event_open(attr_uptr: 0x24ebb78, pid= : -1, group_fd: -1, flags: FD_CLOEXEC) =3D 4 syscall (/usr/lib64/libc-2.24.so) perf_evlist__config (/home/acme/bin/= perf) 0.143 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, cpu= : -1, group_fd: -1 ) =3D 4 syscall (/usr/lib64/libc-2.24.so) perf_event_attr__set_max_precise_ip = (/home/acme/bin/perf) 0.161 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid= : 8470 (perf), group_fd: -1, flags: FD_CLOEXEC) =3D 4 syscall (/usr/lib64/libc-2.24.so) perf_evsel__open (/home/acme/bin/per= f) 0.171 ( 0.005 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid= : 8470 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) =3D 5 syscall (/usr/lib64/libc-2.24.so) perf_evsel__open (/home/acme/bin/per= f) 0.180 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid= : 8470 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) =3D 6 syscall (/usr/lib64/libc-2.24.so) perf_evsel__open (/home/acme/bin/per= f) 0.190 ( 0.005 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid= : 8470 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) =3D 8 syscall (/usr/lib64/libc-2.24.so) perf_evsel__open (/home/acme/bin/per= f) [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ] # The probe one called from perf_event_attr__set_max_precise_ip() works the first time, with attr.precise_ip =3D 3, wit hthe next ones being the per cpu ones for the cycles:ppp event. And here is the text from a report and alternative proposed patch by Thomas-Mich Richter: --- On s390 the counter and sampling facility do not support a precise IP skid level and sometimes returns EOPNOTSUPP when structure member precise_ip in struct perf_event_attr is not set to zero. On s390 commnd 'perf record -- true' fails with error EOPNOTSUPP. This happens only when no events are specified on command line. The functions called are ... --> perf_evlist__add_default --> perf_evsel__new_cycles --> perf_event_attr__set_max_precise_ip The last function determines the value of structure member precise_ip by invoking the perf_event_open() system call and checking the return code. The first successful open is the value for precise_ip. However the value is determined without setting member sample_period and indicates no sampling. On s390 the counter facility and sampling facility are different. The above procedure determines a precise_ip value of 3 using the counter facility. Later it uses the sampling facility with a value of 3 and fails with EOPNOTSUPP. --- v2: Older compilers (e.g. gcc 4.4.7) don't support referencing members of unnamed union members in the container struct initialization, so move from: struct perf_event_attr attr =3D { ... .sample_period =3D 1, }; to right after it as: struct perf_event_attr attr =3D { ... }; attr.sample_period =3D 1; v3: We need to reset .sample_period to 0 to let the users of perf_evsel__new_cycles() to properly setup attr.sample_period or attr.sample_freq. Reported by Ingo Molnar. Reported-and-Acked-by: Thomas-Mich Richter Acked-by: Hendrik Brueckner Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Fixes: 18e7a45af91a ("perf/x86: Reject non sampling events with precise_ip"= ) Link: http://lkml.kernel.org/n/tip-yv6nnkl7tzqocrm0hl3x7vf1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/task-exit.c | 2 +- tools/perf/util/evsel.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 01a5ba2788c6..b0d005d295a9 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -82,7 +82,7 @@ int test__task_exit(int subtest __maybe_unused) =20 evsel =3D perf_evlist__first(evlist); evsel->attr.task =3D 1; - evsel->attr.sample_freq =3D 0; + evsel->attr.sample_freq =3D 1; evsel->attr.inherit =3D 0; evsel->attr.watermark =3D 0; evsel->attr.wakeup_events =3D 1; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index bce80f866dd0..97fe0c80ff02 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -262,8 +262,20 @@ struct perf_evsel *perf_evsel__new_cycles(void) struct perf_evsel *evsel; =20 event_attr_init(&attr); + /* + * Unnamed union member, not supported as struct member named + * initializer in older compilers such as gcc 4.4.7 + * + * Just for probing the precise_ip: + */ + attr.sample_period =3D 1; =20 perf_event_attr__set_max_precise_ip(&attr); + /* + * Now let the usual logic to set up the perf_event_attr defaults + * to kick in when we return and before perf_evsel__open() is called. + */ + attr.sample_period =3D 0; =20 evsel =3D perf_evsel__new(&attr); if (evsel =3D=3D NULL) --=20 2.15.1