Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2658434rdg; Mon, 16 Oct 2023 10:41:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4+TwfZXBnOBSeyRq/xYuBD8G96h+Xm8RX1uuCGuH9B8C/EaVjaiOBoAjioPlm+HpFUIsF X-Received: by 2002:a05:6a00:158e:b0:6bb:def8:b09c with SMTP id u14-20020a056a00158e00b006bbdef8b09cmr4554200pfk.1.1697478064168; Mon, 16 Oct 2023 10:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697478064; cv=none; d=google.com; s=arc-20160816; b=OrxhugR7D77PyrCSLXUGA++WmjttWA5wtzGc9f2Q+HqS8s1/9NjWNZyLzf5kpvMQRk 9FmF8uMyCJ0C4SBGK5bk+6onLqM9dCr4vZkUCvbGteGlYLsZib0nELOKqfG1kzX9Q2TI T0F2IKcL+Zmqf1BFRxrI6MjrrbqATT25JOs1IqMza+6sjqNliByH5aqz1zEvXslz/HA4 RcuY9tmmKX0TdroxogGUU2E+Sak4bvRJPODrQIlKtoxYJNe2qituClpBTpQKQ9Ngu36f dUP91bmDFC53esi1/uS4UURHPCY1a3pP9QwqbuuDGloA127yaqBR2mFfKqvC7cc1bHGE GBGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EM2uyD0ALKDajQamVcskfWytEzuAZ9KvnS9fF7OO3Y8=; fh=xH4moCvQzsN+9ugM7JX/UQN3H6rCLhcemTuT12mMY/c=; b=bncAvDt16WPmknOlAenRYQgEB57SEyey8VgB0uNO9WkkjFoAT6NsmvL6AgdR3NJ+Gj ukWHy6f+LCKOr87SKR/cx885A1wSFWmwkct77TDX1+1rmzlJc9/3sZTj+aYBvebXH04t 6TC6GIfzUe5qnAaykD/zd0WRki7/st0XbnquZtUaHe6vED9AzjrN58LfVBdzxVbzJ4Ex kms10anOpFMGmTkbSMU98Zec0wfN1iua0ktm591ROX02kvWlj/NJkCyhgW0OGZzV+mfl WpQMIX4Ij5P8b3Bo25YfMio4FpGx0QoikxxUKvwJh/NtmM9eBrXgixBoEEGrQvW4bwso yvUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l8c08qYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z10-20020aa79e4a000000b00690f9e835d8si265704pfq.132.2023.10.16.10.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 10:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l8c08qYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B4CC6809DE4C; Mon, 16 Oct 2023 10:40:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbjJPRkc (ORCPT + 99 others); Mon, 16 Oct 2023 13:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjJPRk2 (ORCPT ); Mon, 16 Oct 2023 13:40:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD85B83 for ; Mon, 16 Oct 2023 10:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697478023; x=1729014023; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=twF0yMuknuHU1zfCoxs5nE6Pr/iTI67oOU0Ux/+a/uk=; b=l8c08qYf2PIncopJRGWLAm1P/laIk/jbvwhq8tbmX490IhsuijewcoQw bC7HF8WZ5j8BO9OrLaHhn+RycwafCxPhUfOiEF5KG4uDMXvJMMyCu3o0i chuMe97pH4/Gid2PB6fANCSP8kNiac4EiWAE8Vn/L3DgInoDe/G92qJfj 8CSB1rV4yge3tnV+SggLgG8dWNjFONGzOVLPsHdXmeGe5zeHZUGkSKXEf 2emYNMP58WBloWFktwgyyPicg7gt7FBmcmUApQAshwW1OigOVR808V7Fw b7cw0I5ulP6PCjBGtSDmiQFM5WdcPbzhSef+ttNQ7XcXDQZ308g0C6cbO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="365858551" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="365858551" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:40:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="785175356" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="785175356" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga008.jf.intel.com with ESMTP; 16 Oct 2023 10:40:22 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: artem.bityutskiy@linux.intel.com, rui.zhang@intel.com, Kan Liang Subject: [PATCH 1/4] perf/x86/intel/cstate: Cleanup duplicate attr_groups Date: Mon, 16 Oct 2023 10:40:11 -0700 Message-Id: <20231016174014.453169-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 10:40:47 -0700 (PDT) From: Kan Liang The events of the cstate_core and cstate_pkg PMU have the same format. They both need to create a "events" group (with empty attrs). The attr_groups can be shared. Remove the dedicated attr_groups for each cstate PMU. Use the shared cstate_attr_groups to replace. Signed-off-by: Kan Liang --- arch/x86/events/intel/cstate.c | 44 +++++++++------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c index cbeb6d2bf5b4..693bdcd92e8c 100644 --- a/arch/x86/events/intel/cstate.c +++ b/arch/x86/events/intel/cstate.c @@ -189,20 +189,20 @@ static struct attribute *attrs_empty[] = { * "events" group (with empty attrs) before updating * it with detected events. */ -static struct attribute_group core_events_attr_group = { +static struct attribute_group cstate_events_attr_group = { .name = "events", .attrs = attrs_empty, }; -DEFINE_CSTATE_FORMAT_ATTR(core_event, event, "config:0-63"); -static struct attribute *core_format_attrs[] = { - &format_attr_core_event.attr, +DEFINE_CSTATE_FORMAT_ATTR(cstate_event, event, "config:0-63"); +static struct attribute *cstate_format_attrs[] = { + &format_attr_cstate_event.attr, NULL, }; -static struct attribute_group core_format_attr_group = { +static struct attribute_group cstate_format_attr_group = { .name = "format", - .attrs = core_format_attrs, + .attrs = cstate_format_attrs, }; static cpumask_t cstate_core_cpu_mask; @@ -217,9 +217,9 @@ static struct attribute_group cpumask_attr_group = { .attrs = cstate_cpumask_attrs, }; -static const struct attribute_group *core_attr_groups[] = { - &core_events_attr_group, - &core_format_attr_group, +static const struct attribute_group *cstate_attr_groups[] = { + &cstate_events_attr_group, + &cstate_format_attr_group, &cpumask_attr_group, NULL, }; @@ -268,30 +268,8 @@ static struct perf_msr pkg_msr[] = { [PERF_CSTATE_PKG_C10_RES] = { MSR_PKG_C10_RESIDENCY, &group_cstate_pkg_c10, test_msr }, }; -static struct attribute_group pkg_events_attr_group = { - .name = "events", - .attrs = attrs_empty, -}; - -DEFINE_CSTATE_FORMAT_ATTR(pkg_event, event, "config:0-63"); -static struct attribute *pkg_format_attrs[] = { - &format_attr_pkg_event.attr, - NULL, -}; -static struct attribute_group pkg_format_attr_group = { - .name = "format", - .attrs = pkg_format_attrs, -}; - static cpumask_t cstate_pkg_cpu_mask; -static const struct attribute_group *pkg_attr_groups[] = { - &pkg_events_attr_group, - &pkg_format_attr_group, - &cpumask_attr_group, - NULL, -}; - static ssize_t cstate_get_attr_cpumask(struct device *dev, struct device_attribute *attr, char *buf) @@ -478,7 +456,7 @@ static const struct attribute_group *pkg_attr_update[] = { }; static struct pmu cstate_core_pmu = { - .attr_groups = core_attr_groups, + .attr_groups = cstate_attr_groups, .attr_update = core_attr_update, .name = "cstate_core", .task_ctx_nr = perf_invalid_context, @@ -493,7 +471,7 @@ static struct pmu cstate_core_pmu = { }; static struct pmu cstate_pkg_pmu = { - .attr_groups = pkg_attr_groups, + .attr_groups = cstate_attr_groups, .attr_update = pkg_attr_update, .name = "cstate_pkg", .task_ctx_nr = perf_invalid_context, -- 2.35.1