Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3764127pxj; Mon, 7 Jun 2021 20:36:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7auKuH6EnmS+xsbFJ7B8srUW3YCtIBwnZ4X/OpzRQ9IGRpm7snnFBMFxO/BWdwgyldeQQ X-Received: by 2002:a50:ee8b:: with SMTP id f11mr23118553edr.329.1623123387288; Mon, 07 Jun 2021 20:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623123387; cv=none; d=google.com; s=arc-20160816; b=ejf3k1Iz1Nqz34dsujYUuqEEV6CChnU6FefQtoHj00Mo8C9d1Ta7AguY8kDjza30GU agpAgtyT5o2oLvBTtumbhr55UIs8ZYUljyTr2cP8xbg78JkuAsEs2R1pTHBtwNlrtT7v xcIu8Dq/wHNyiMoqhSP/2dtrmCU6P6DH+1iEffdlTDakpWFsNS3ONBPeK+BoIOBgpdKb +GIK+9xGXo9MnMCul7sKdKH8qj8dO1vLIxhjveeYz2HSaibSkm2YGkrO0vlN8dvDOI8N ALGtXvPOLxSrQl77tLZKtHwsvWUvB1TEIGLFIKL43YdKhrJodn1k3mzOkUKUs62wRz7d hYrQ== 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=eNgazOeTdxytz0UA6Q1scHkH2ZKd52g22mAH93fJE8U=; b=RVPDDFvfhYXX0gAKzP+90ytCJCzchOMQCWN507hUUSfzz4Jmc7B6jWvwYrGKvyNXF9 n2d9i4Qxn474ImsMgxaAQHiMD2wDZ09SbJQyqNteByp21fmgY7jXFJqZp5CYvJ2tfAuh uqlJtuSeL2Nwsq5kiAzE3ybq638zh7XwLCRM+ku31C2QXgX0uNF03+G7Jtzw1PA74zrH yJ5nvXcVnhiYp7Pp+2jZC7IdUvra86o0GmrMc01vVjGdQfSS50fW5gO7dBw0VBeo2iEs cl6wudqCE8/d/PzvSELYWVsleJr9F9X6wfJGB1R+hw7SCbNkGUzBPlod9QJog3wfR//o nqhw== 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 9si216893ejf.340.2021.06.07.20.36.03; Mon, 07 Jun 2021 20:36:27 -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 S230519AbhFHDfj (ORCPT + 99 others); Mon, 7 Jun 2021 23:35:39 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3463 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbhFHDff (ORCPT ); Mon, 7 Jun 2021 23:35:35 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4FzbNb2CLsz6vv9; Tue, 8 Jun 2021 11:30:39 +0800 (CST) Received: from dggema757-chm.china.huawei.com (10.1.198.199) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 11:33:41 +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; Tue, 8 Jun 2021 11:33:41 +0800 From: Qi Liu To: , CC: , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin Subject: [PATCH v3 1/9] perf: Add EVENT_ATTR_ID to simplify event attributes Date: Tue, 8 Jun 2021 11:33:13 +0800 Message-ID: <1623123201-45634-2-git-send-email-liuqi115@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623123201-45634-1-git-send-email-liuqi115@huawei.com> References: <1623123201-45634-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 HiSilicon PMU driver, 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