Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5146724pxj; Wed, 9 Jun 2021 10:10:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2Lzx/2/X07v96d12Er4O2uIuB9C4hf5XJLpQW8T14n7Sf8wlBrfvA3UXOK4GtiLwZ0nV/ X-Received: by 2002:a05:6402:343:: with SMTP id r3mr489245edw.22.1623258611330; Wed, 09 Jun 2021 10:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258611; cv=none; d=google.com; s=arc-20160816; b=PVfW0O5ItwO48CcBWhnoxzUtKzAMep0ZA9k6qtiYlB7PbGNnPeJwWnjoVEp1AZ2At/ uuJpbpXzpX3B+IqMHO/Xd7fEi7qvyCQHvP82N0HsMiZkv9C2cquX5FxhmFsIWbN/8bZZ WIZa1e6fZchu6WTeHgNcUsX6HL+qHJUwGGHMyDaYVn1D0C/CP6zcylIxpNvDrUFP1sw+ xvETamg15t1AoHSqB8yW1GwPI6y++Yj8Pt2tOIBAaCySfTqTG9a4lhrsMbTxWad4A43a dlanUuweO9bX3VPEDY9KhuLReMEbbFLWYYGyCElBz+uxtuJybtYroWxcncEZNjnwE4hS r9FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=p7IMnIp+cPBcf9bRRlSf/OsmiUlncS5OLGam9eQxDhM=; b=BJM6KpHKXNVTvibyjLlWhMm6l2hmT64W6fIIKTwxirb4uqUs/XbX8jFdS5J5B2xrTv x3Z+bpCpnj1B5Q2tNqG0GertqWQAX3LK+lcJmAoeufBuFW87YpASmGGeR/o2lNTMfGi0 r4wFuswcfbjLMTnI9WjfH2evgqEReI+oQrx7qMCSH6k8lmTPezo1m5tT40SZQI2N4p08 jRYgs+c213TkLpj35ArhOMnpBiWZT+jcJT0MLXBFV/a96ZWEZwJHcZLk0oIj9PWlK/z9 aJSiuIN6cOULBybLDFdKnt4pRvLiyH8sxpho8ZtYHzS/9Q7w1zo/a/DvrXwR59oqEIgP x/Vw== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si150007edr.499.2021.06.09.10.09.47; Wed, 09 Jun 2021 10:10:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236863AbhFIGoJ (ORCPT + 99 others); Wed, 9 Jun 2021 02:44:09 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:5297 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233281AbhFIGn4 (ORCPT ); Wed, 9 Jun 2021 02:43:56 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4G0HTJ1HQnz1BKSk; Wed, 9 Jun 2021 14:37:08 +0800 (CST) Received: from dggema757-chm.china.huawei.com (10.1.198.199) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 9 Jun 2021 14:41:59 +0800 Received: from localhost.localdomain (10.69.192.56) by dggema757-chm.china.huawei.com (10.1.198.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 9 Jun 2021 14:41:58 +0800 From: Qi Liu To: , , CC: , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin Subject: [PATCH v4 1/7] perf: Add EVENT_ATTR_ID to simplify event attributes Date: Wed, 9 Jun 2021 14:40:57 +0800 Message-ID: <1623220863-58233-2-git-send-email-liuqi115@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623220863-58233-1-git-send-email-liuqi115@huawei.com> References: <1623220863-58233-1-git-send-email-liuqi115@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggema757-chm.china.huawei.com (10.1.198.199) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar EVENT_ATTR macros are defined in many PMU drivers, like Arm PMU driver, Arm SMMU PMU driver. So add a generic macro to simplify code. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Signed-off-by: Qi Liu --- include/linux/perf_event.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index f5a6a2f..2d510ad 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1576,6 +1576,12 @@ static struct perf_pmu_events_attr _var = { \ .event_str = _str, \ }; +#define PMU_EVENT_ATTR_ID(_name, _show, _id) \ + (&((struct perf_pmu_events_attr[]) { \ + { .attr = __ATTR(_name, 0444, _show, NULL), \ + .id = _id, } \ + })[0].attr.attr) + #define PMU_FORMAT_ATTR(_name, _format) \ static ssize_t \ _name##_show(struct device *dev, \ -- 2.7.4