Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2828827pxb; Mon, 19 Apr 2021 15:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQLtowsA5eUVYdCVvKBQqJLGPpLenI6D3qAh2PYeoKOXRGSyEdOcEBoHo/N+8m0tkhZ0t9 X-Received: by 2002:a65:61a1:: with SMTP id i1mr13864436pgv.411.1618870826941; Mon, 19 Apr 2021 15:20:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618870826; cv=pass; d=google.com; s=arc-20160816; b=tMfO6dPHWEKqpjZ7MHh+T+0SEXtSFXNqJtodyfulI1433rh4GpBLZv3QrmzHdVr1eQ Od6bKvM7ui8W/KprX9hg2ZBtR6CYoM451p5ArU5e0KMoDoWd4e4c1lWyJGr0rXDQ1DpB NVP67UPIzleYFD3qoBsFZqf89xdDhcqoZ1eEMzOXe0BEewQK7bs/ZjgpVCdtOiCSJQSo RVD3G9CYToHGJwllcZQDTK7Ti3Qae/YwSwpZYpC993weQX4A7tC5wudkWKhhMyeBI7ra ALC18lCKMmglmQ9bfF71td5+Z7p4J+s1hiHWdg0A5BJy90fFtGInXvwAMM2RBiTTMpB7 GZdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=WwVNcTabvRcHe0vhLgO/UQJVhorKbXwv7hY70YQMJB4=; b=xwcxlNHRQ3BBcvFNN/ngA8vKL7Stpvx8CYl8fsqxFemyQ4vvvfDo9g0YxbJ45K19VK uMkQCjuRyLdSi3gz9SG0NGSo0uWASV3PN0jWkxQ65yE2F43xKWBQBg+Qiyh/zB9Wy19X LA62jv4XIhjAMMaCq4EVUE4DWXv+iZw156mW988ba/Kf7NXz0GOC7JD0lprRiMCzV+J4 JM9jDii0dvv2ZH4vGSqx8vhBZTSVdP5sVvyeGMYqZX2d7jAl8wTLjSBT1Bu9eFfnIOXI KmxbETQ+bq2R6dh+LY6MX9mJhoyfLmXH4P7es9Sr/9gFZEQ/yth8fGL8xNWeIIeBzD8K +2iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=LbvaKZwS; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si14927388plr.328.2021.04.19.15.20.15; Mon, 19 Apr 2021 15:20:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=LbvaKZwS; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238260AbhDSU0k (ORCPT + 99 others); Mon, 19 Apr 2021 16:26:40 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:29014 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232318AbhDSU0j (ORCPT ); Mon, 19 Apr 2021 16:26:39 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.43/8.16.0.43) with SMTP id 13JKPBub025130; Mon, 19 Apr 2021 13:26:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=WwVNcTabvRcHe0vhLgO/UQJVhorKbXwv7hY70YQMJB4=; b=LbvaKZwSEy74v0f6Bodah6zB3nn+aOJD+nWwHEaLCHdtZv3dxb7WYpP1IdINN2kW5iBD 5SADTAXUvo18a1v1802YOmv9VkP8FhDQ19m+z1qymvfe+qehC0ia5D1t3WKnjecZYmLb kS4t2R4Vi1fpXdQRzSAfGZGUwdTLlGOX0N4= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net with ESMTP id 381deus9fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 19 Apr 2021 13:26:06 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (100.104.98.9) by o365-in.thefacebook.com (100.104.94.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 19 Apr 2021 13:26:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BykXEviJar+dztVKJW+X2Oa84o0P73TNcrk1YdvU8lp/tqIW98ntToUVhg/DiGZTl93RiYG6aL05q8UOUQkpb1cOKZwljtyYawuDxHvQbmIb+ug7lmkiFzHg0Hr/ZYEIYNgKBT24UiWtAdVyyR0P5OAyibLoc1A5SGBaU1ExTwe0+J3qS4/lJei2MZJUPi+ENYIKQ6iA2Sjk2j1Ai/NSjTfOI/3KFuGqiP0p7n45jVcY4bhx0GUGze773YpLEHys2U7MNXC9ybXSUPS2srW3V6pYsvCn696DYZ+0vA8ewKjVuVLIdfahlQce8rEIKJPYhbnb6nqNp24v/Epc5sMhTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WwVNcTabvRcHe0vhLgO/UQJVhorKbXwv7hY70YQMJB4=; b=Mvm7T86jAnJ0+iPcC01SgJZ0f2IuwFO2L7Yi+rPHl8cBIYVBLXUCe75+8zxWPJRUgrEJq/FbbxjGP6D34+7ZbkCXrl7yHzV8b8ragLf6XqXlkkWhzHzShX5S7WuslAa+R4jVaDr2w5gpn25LNHOIRnk1cRO7EyiEXZ9gw27amJ7CCYDM8mk4GioxwJKgWa4wE7kWxpAf1Nbl0AmF0Csb1WszfDBM+AWduRsouq5bVF7Zji4lt6mZdCPmHfMyhdDwFwmkEAL8D/u4oRYbdxc4DVuY7DB75bQA0U/134Cam9JS5CDRr0asc0o5q6ZHDmJVwPktxSQBGaXqFz2dZLnCBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none Received: from BYAPR15MB2999.namprd15.prod.outlook.com (2603:10b6:a03:fa::12) by BYAPR15MB3366.namprd15.prod.outlook.com (2603:10b6:a03:10d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.21; Mon, 19 Apr 2021 20:26:03 +0000 Received: from BYAPR15MB2999.namprd15.prod.outlook.com ([fe80::1ce0:8b27:f740:6b60]) by BYAPR15MB2999.namprd15.prod.outlook.com ([fe80::1ce0:8b27:f740:6b60%4]) with mapi id 15.20.3933.040; Mon, 19 Apr 2021 20:26:03 +0000 From: Song Liu To: Namhyung Kim CC: Song Liu , linux-kernel , Kernel Team , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Jiri Olsa Subject: Re: [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events Thread-Topic: [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events Thread-Index: AQHXMw3DyOxUaVUpS0ODNNUcJNtKe6q46/0AgANiUwA= Date: Mon, 19 Apr 2021 20:26:02 +0000 Message-ID: <71CC9E29-ECBD-47DB-AE85-1477BF54C45D@fb.com> References: <20210416221325.2373497-1-song@kernel.org> <20210416221325.2373497-4-song@kernel.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3654.60.0.2.21) authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=fb.com; x-originating-ip: [2620:10d:c090:400::5:83ef] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b6b79da2-2ec5-4b6d-7a6f-08d903715a50 x-ms-traffictypediagnostic: BYAPR15MB3366: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-fb-source: Internal x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Hnk8yaget5OZvkXyMltvC8yTqjG+yLnBP9TILn3vaaXZ0nTtMo93dFuN2MWvG82v68pn+2tl6G7ckIEbm3GQ3DL1+PIRX14x9Oc6Cq5hO4TySBUnNywInHMLqrHqW4h5CXbjXGnxiLDEP4Zy+YjIZ18tIB65TzkK5oFK8Qe9MAB591O9zQdlaObvuWPh9U8GKPlx9bniiPth68KwafAwixZnIQH5Icp56Wcr9rRowTYxFjEAbhucHunmFy774gmYiOxb/KtWfA4hjmeU4hPXuoaTxVImo1CjNZiE1UITiF4/HzImpZaxPOrVlAh4Cp6ZyKr+OoihP74OyWeBCs7BeFEFSwyLl9BC5Pslw2/NFRQoOLm6tCXEojrxnNEyMGZCAm890ajIp+PxW8b6PRpZYa/z/5zwO9p/vILaRKcveZR8ZTvk06cnyNhPu0t+ayS2Fjpi4fIU6O8tOM2orR21bO0IIffozhrJj4GEQ7uTlCJVx1YMo1brbjw5kjmvjCK+ohLKkfAJE3BXEh6n9wLbpw+Eu4rZzZEWbHv+7QPUfRFjnMVVCeUQM6k+U4dsT+mceu+mla2brKNNjQ9t3D4F/YAGMgBzaJwj3vP1d43I2Gmn6sypPNErHnqHRVCARVC+8N2alP0TTgFt0bdMmUD6TmKjyRI6FaHkWduWRrdoUKo= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR15MB2999.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(396003)(366004)(346002)(39860400002)(136003)(71200400001)(6512007)(38100700002)(122000001)(2906002)(2616005)(6916009)(6486002)(66946007)(33656002)(186003)(6506007)(478600001)(66446008)(66476007)(53546011)(66556008)(64756008)(316002)(36756003)(54906003)(5660300002)(76116006)(8676002)(91956017)(86362001)(8936002)(4326008)(45980500001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?aXHSfECGo1oha0XsA8oPAY+tIkKHijkbtdkpqrIDLP3cEKY5OxhIXPORO2D6?= =?us-ascii?Q?F4pcqjR+FWatjNdwmQtSNk0fh1YxMz2Ze3/bAZcF0mPxGOaiNRDwPeF42zI5?= =?us-ascii?Q?JLhZgnIKISOg8+aKqrMhQ+cwWWr4hnTk6JWHmQoivVOTl7YwBzNq6Pf2itmt?= =?us-ascii?Q?XEI7WLZid2F6BZNq39aotm7CUw6cQR4+MKNmOmKbunjrmTT5Up2mc49i/26C?= =?us-ascii?Q?OKpeQvjYdiv3XNPzMWrA2nkyFKbDJv8MYExE2ZmL/kDqWP9GJPg9Kbypj/6B?= =?us-ascii?Q?Itks1iIKck4bajbV0s3kdRfGlNjfkKord95V8NGCBPdbCDuNiRq4RuUDUtdT?= =?us-ascii?Q?+/X5uPcS9RpJUktFGzV94fyP2ig1rTtu32xrcP3iccarxV1JvRwAur6Wi/Rg?= =?us-ascii?Q?Ph3gII0m6anMxqFE35aRzLXk6kGtJDwIj4dTfX/vOfHYhoyqeJ5BYgM4Zryh?= =?us-ascii?Q?ug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jH8qM+z1VUdZCwjja8?= =?us-ascii?Q?WvaxT2o=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR15MB2999.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6b79da2-2ec5-4b6d-7a6f-08d903715a50 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2021 20:26:02.9997 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fCs1+Lyyc0eu5K2zfD7m6YmEUoWn3TWuKbK/nVN3Q8QVZaOjwAu7hptmeQF9A03mfVD40odZHjqq4SE0a9IEsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB3366 X-OriginatorOrg: fb.com X-Proofpoint-GUID: Jw-Z5gYRKiTfGlI90VmIQXz748czila3 X-Proofpoint-ORIG-GUID: Jw-Z5gYRKiTfGlI90VmIQXz748czila3 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_11:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190140 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 17, 2021, at 9:45 AM, Namhyung Kim wrote: >=20 > Hi Song, >=20 > On Sat, Apr 17, 2021 at 7:13 AM Song Liu wrote: >>=20 >> Currently, to use BPF to aggregate perf event counters, the user uses >> --bpf-counters option. Enable "use bpf by default" events with a config >> option, stat.bpf-counter-events. Events with name in the option will use >> BPF. >>=20 >> This also enables mixed BPF event and regular event in the same sesssion= . >> For example: >>=20 >> perf config stat.bpf-counter-events=3Dinstructions >> perf stat -e instructions,cs >>=20 >> The second command will use BPF for "instructions" but not "cs". >>=20 >> Signed-off-by: Song Liu >> --- >> @@ -535,12 +549,13 @@ static int enable_counters(void) >> struct evsel *evsel; >> int err; >>=20 >> - if (target__has_bpf(&target)) { >> - evlist__for_each_entry(evsel_list, evsel) { >> - err =3D bpf_counter__enable(evsel); >> - if (err) >> - return err; >> - } >> + evlist__for_each_entry(evsel_list, evsel) { >> + if (!evsel__is_bpf(evsel)) >> + continue; >> + >> + err =3D bpf_counter__enable(evsel); >> + if (err) >> + return err; >=20 > I just realized it doesn't have a disable counterpart. I guess it is not really necessary for perf-stat? It is probably good to have it though. How about we do it in a follow up patch? [...] >> + if (!evsel__bpf_counter_events) >> + return false; >> + >> + ptr =3D strstr(evsel__bpf_counter_events, name); >> + name_len =3D strlen(name); >> + >> + /* check name matches a full token in evsel__bpf_counter_events = */ >> + match =3D (ptr !=3D NULL) && >> + ((ptr =3D=3D evsel__bpf_counter_events) || (*(ptr - 1) = =3D=3D ',')) && >> + ((*(ptr + name_len) =3D=3D ',') || (*(ptr + name_len) = =3D=3D '\0')); >=20 > I'm not sure we have an event name which is a substring of another. > Maybe it can retry if it fails to match. We have ref-cycles and cycles. And some raw events may be substring of othe= rs? Thanks, Song [...]