Received: by 10.213.65.68 with SMTP id h4csp2120401imn; Sun, 8 Apr 2018 20:12:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48E9aFplAgBD/RqKNV6jppiaaC78DZbiI8J9SKxql1l0gEhJFFkudy5P3hdb3u7AOfNYII7 X-Received: by 2002:a17:902:8f8c:: with SMTP id z12-v6mr37312344plo.400.1523243548547; Sun, 08 Apr 2018 20:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243548; cv=none; d=google.com; s=arc-20160816; b=mNi5IU+y6vfzXdRU0EY85KxMuMSZ5GQFlVckm2FKGkHZCPhnmhfXo1BAmej7eJA0bZ yyEnYSxOZtgJFj0FCEHxAvl6N2VraX4v5c/SXIXHytBff2R+4CUTaMxWR2P3zbS0+Ty8 9ahNYhF+v87NcgpNtLGpC4Cmab/E5fz98kDqurkJZALrFr9S1chL1CoIRqb1uPGYW5sx HKNa651BELb58qDovlHDfUpchMLMPa1lGCtUtj68jQaUJG9dtvR9TlmWl608DsFILelU 0jCRe7pKvPecc7MakhjJHvlB+x3+2QssY23OQ3jwVU6O1NK7S0XK5B/hVlf4GMa/en1b eNfw== 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=MLYrJxpnk6NYeGLyFIiD/EVGa4QbvIrRgWhvqHyqj/Y=; b=xdse77sCR6Zkf0tcCq66BPhYc6VgIA3wWlEqodCHo4hByb+9DcCDNVw8WzcivqJusJ AN2xg9iYx3eh2cAGj+0s99iOu4iqq20xIhfh3nh73BcM2fp27Qr6v9+wr9b4pIil46UY bSfuJMSmW4mAF89Lma/r9RYa3om7PhCNx+1U6CHrKNsNrD+RnWRVHPrpqQKEb5QIKAHp vuPqLTT347Z+b/19SEdUoFmEoAsqUjP8Oz9A6bXGqUYox2E7JZ4esNCJ+rG9L6rMeV5/ vSaVCNAWwXwthFdIry3tyTS69jOrj8X0f5X3fHtRgJba0n3iyY1+sZRVGoRzD1O//iPh 0Tsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=CvjWn81s; 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 d13si5975459pgu.626.2018.04.08.20.11.51; Sun, 08 Apr 2018 20:12:28 -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=CvjWn81s; 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 S1756316AbeDICr6 (ORCPT + 99 others); Sun, 8 Apr 2018 22:47:58 -0400 Received: from mail-by2nam01on0099.outbound.protection.outlook.com ([104.47.34.99]:2811 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755393AbeDIA0j (ORCPT ); Sun, 8 Apr 2018 20:26:39 -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=MLYrJxpnk6NYeGLyFIiD/EVGa4QbvIrRgWhvqHyqj/Y=; b=CvjWn81sAcniOaCgh7kfcS4rDLn6BaC+9CmvJbz0Po947RNdza/AXXGwYAa5cdhWYZcqm/qlIuG3uz0FuwZYqtPvYwvQ83DMIlyFd1Q01A9D9jTFiyyzpp9SOoeD8woO94ILfbZvDj0O/L1m5YRnnzVMKy7MNA4mrnujIlgqX/c= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) 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:26:33 +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:26:33 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 006/293] perf/core: Correct event creation with PERF_FORMAT_GROUP Thread-Topic: [PATCH AUTOSEL for 4.9 006/293] perf/core: Correct event creation with PERF_FORMAT_GROUP Thread-Index: AQHTz5jlREnPcUaLyECsKahc5X+CJg== Date: Mon, 9 Apr 2018 00:22:51 +0000 Message-ID: <20180409002239.163177-6-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;DM5PR2101MB1015;7:fPsr7eczgChn7HgEMVXP+iagAHoSr9SGT1M1xWxLOmCoLicyvgbMC594MnW6dwuZYDgyFv3RF81N8ELd5kbtPXCHcBYqXjkBOSp5sAlXmhrq61qbZ630mQweYEkgf+mKJF8z28gF9qUhiA3iMW8skLWJj7SPUNgFqxeYd1bYuZQCqzVGssUfQo42VzuKilscwIbehvZk3vsl6ghe1BcUJGLw7XV5I0HOrg8LO+tNtPyMieerkWLY7Mwv6YhmMewz;20:G99FHXz/fwrZSltwnDbF2kzDle9b0zwSM+hs1ktFVEj0mplew6lyBENOu8CfdNM4FdTrYCMcKyrNCOQSsZpvukuiHMUwAfU74LGyLXR3bSymtyPPCxOYB+C7RH/TpeKNgKnz3j4ohYsDtTTfkD/KO0nPEObMEx70sVRKsDHJ0kw= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: fcb9a3b4-dffe-4b27-b990-08d59db08c26 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: 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)(211936372134217)(42068640409301)(153496737603132)(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:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(39380400002)(376002)(346002)(366004)(189003)(199004)(53936002)(4326008)(478600001)(72206003)(3280700002)(2616005)(14454004)(305945005)(5250100002)(3660700001)(2501003)(2900100001)(54906003)(110136005)(86362001)(1076002)(966005)(107886003)(6506007)(36756003)(446003)(68736007)(6512007)(7736002)(486006)(2906002)(6306002)(5660300001)(6436002)(3846002)(86612001)(6486002)(66066001)(11346002)(7416002)(476003)(6666003)(26005)(10090500001)(316002)(22452003)(8676002)(81156014)(81166006)(6116002)(105586002)(99286004)(186003)(106356001)(76176011)(25786009)(97736004)(10290500003)(102836004)(8936002)(22906009)(21314002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;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: hjCg4LEfIMVIO8oaP3U0xKhP7DjPi7cITobtfEHqjYNem3p320ArftO86NzJlp4AqvemWBanIQrxjmY14o4u7/Bo1qSA9iY7lmU+ZLwnEvJBWIKFeOPe927P/rg7SaLiPoFGJo5NhJ0ihkElNHDm5EWKPCp2pr7fcUShMpURh7FzsIbi8Z6pRFLUmBa/6I6Jm8NkuesgyRUM3b51NmR1trIAW9H0vfSmlPR16tXNGX9GyTiFhHd6fXKlO3bw2CVG6Uhba79FHSP9lVlV1B1APWWHsGc9KNilJjSMgRDtqxI7/buJbULBBm9I5lzA5xFu3/HdSmbOXgeUI6bJnYNsBDb9aX6qCptG/p9fjPqTYiPDRyq/g36n7njF+U+mK20vR+OeK1XUVXq7QqoLMmzYFYb2BbiAvyfjWzTEAxfnn/Y= 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: fcb9a3b4-dffe-4b27-b990-08d59db08c26 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:22:51.1904 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit ba5213ae6b88fb170c4771fef6553f759c7d8cdd ] Andi was asking about PERF_FORMAT_GROUP vs inherited events, which led to the discovery of a bug from commit: 3dab77fb1bf8 ("perf: Rework/fix the whole read vs group stuff") - PERF_SAMPLE_GROUP =3D 1U << 4, + PERF_SAMPLE_READ =3D 1U << 4, - if (attr->inherit && (attr->sample_type & PERF_SAMPLE_GROUP)) + if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP)) is a clear fail :/ While this changes user visible behaviour; it was previously possible to create an inherited event with PERF_SAMPLE_READ; this is deemed acceptible because its results were always incorrect. Reported-by: Andi Kleen Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: 3dab77fb1bf8 ("perf: Rework/fix the whole read vs group stuff") Link: http://lkml.kernel.org/r/20170530094512.dy2nljns2uq7qa3j@hirez.progra= mming.kicks-ass.net Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/events/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 13b9784427b0..4d6f2cd59696 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5669,9 +5669,6 @@ static void perf_output_read_one(struct perf_output_h= andle *handle, __output_copy(handle, values, n * sizeof(u64)); } =20 -/* - * XXX PERF_FORMAT_GROUP vs inherited events seems difficult. - */ static void perf_output_read_group(struct perf_output_handle *handle, struct perf_event *event, u64 enabled, u64 running) @@ -5716,6 +5713,13 @@ static void perf_output_read_group(struct perf_outpu= t_handle *handle, #define PERF_FORMAT_TOTAL_TIMES (PERF_FORMAT_TOTAL_TIME_ENABLED|\ PERF_FORMAT_TOTAL_TIME_RUNNING) =20 +/* + * XXX PERF_SAMPLE_READ vs inherited events seems difficult. + * + * The problem is that its both hard and excessively expensive to iterate = the + * child list, not to mention that its impossible to IPI the children runn= ing + * on another CPU, from interrupt/NMI context. + */ static void perf_output_read(struct perf_output_handle *handle, struct perf_event *event) { @@ -9259,9 +9263,10 @@ perf_event_alloc(struct perf_event_attr *attr, int c= pu, local64_set(&hwc->period_left, hwc->sample_period); =20 /* - * we currently do not support PERF_FORMAT_GROUP on inherited events + * We currently do not support PERF_SAMPLE_READ on inherited events. + * See perf_output_read(). */ - if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP)) + if (attr->inherit && (attr->sample_type & PERF_SAMPLE_READ)) goto err_ns; =20 if (!has_branch_stack(event)) --=20 2.15.1