From patchwork Mon Oct 16 17:40:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 153704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3622278vqb; Mon, 16 Oct 2023 10:40:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFX9tPzKdRQqx45MiMtjj/h6p9PmfRVYLkJTA703Fp16f+xDMXItKlqeh8L1knumYnCVNxe X-Received: by 2002:a17:90a:9f83:b0:27c:fbf8:6c43 with SMTP id o3-20020a17090a9f8300b0027cfbf86c43mr17109771pjp.1.1697478055408; Mon, 16 Oct 2023 10:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697478055; cv=none; d=google.com; s=arc-20160816; b=Fvi9OdkCM036jbIR3ej6Y02+fHz7uRRM3S52FH39fSUhW0JYWWAtXu5hcxqzXAI42X gNGK8f0ds2R2q+VzSVc5ca3v+reAFO3y4XfYXAIVfIKgteTnSj1JRxzf+46//wxFE/CV +31QSYDRcIDyQ+1iAR/Bnfi7fjEER1rXkS34vv8F0bHXFWjY/PN/HrefW0XRnjmz49ae Q0ZmcMSyeSRlK5gjd4WSqk02dE9ZKDB4IeWX5l5z7dk9ZTOVoqRY+tg/bVh1gwWYGtfv gAAOB3fFztBqJl9VmR9FRENnVVWNS6X31j+G/m+Ic3qbH0Z9nQSOkED5Nq03tNPa2Mca FiqQ== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id a23-20020a17090acb9700b0027921228848si6562898pju.133.2023.10.16.10.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 10:40:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; 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:3 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 lipwig.vger.email (Postfix) with ESMTP id C5F34803BA88; Mon, 16 Oct 2023 10:40:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233580AbjJPRkc (ORCPT + 18 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 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 10:40:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779934748928487205 X-GMAIL-MSGID: 1779934748928487205 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,