From patchwork Wed Oct 25 20:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 158267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp213763vqb; Wed, 25 Oct 2023 13:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvQloR/z7Hwfdyj0Q3WqlT6pQ3pq/fBzlUriz2Uscg8xbsJtOgr66HFu1RuRbjpspxj5dJ X-Received: by 2002:a05:6808:1a88:b0:3ad:fe8d:dfae with SMTP id bm8-20020a0568081a8800b003adfe8ddfaemr12302572oib.57.1698265029854; Wed, 25 Oct 2023 13:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698265029; cv=none; d=google.com; s=arc-20160816; b=FpFmoEoCdEEcOOzSrSEu6+bm1C+RFZt2XmbEhy6pjR+/AZL9NkNd6uIJurhKOiOPHG 1n2ZZpYHpsXr1OTcECKz4J/M02HsIg/LWOKlo9/mqnixPMKmOXw9Qar6ucTBI9BSv23y fSMDgknkqAf4+SKGqeGoV3bNITFludeYixEemI6doY2nLaxXO5cZUKvRZ7Lj6pq9D5lC PdMSLTNMaML3ax4vUJqYIucbTjNcGSwnMafxuRw5Eef5PGLmosvvrD78JyfG5odJ3bjw XZtbTQIw1cAMg8R+14tbN8SZmFcAl4kNTwqvGNgofJdPUVoqy3mAIHbZJBs0oqoIrHAd cvwg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6oW8vQEnVAmw8152qrBg7bS1XHaWh0ZP8sRZSbMY86I=; fh=PWMgxgslqMjOtye8I2qVy8I5pPekyJtpFTusQltnkEg=; b=rwXzY7lMBb03fq3EQFbL08h+h6qnRw01TFfUHZL/mbJ4/6GWKJeo3ZmeF62P7oa7al 7yfRFl5vXLD53KTNhnuSyOjIUtxybIYeAzxpGUKVt2ONlWwY0vni6YiJUeJ+RQtRRVmZ TpCZxLlH5v3BPWBJDzk7ZCnzZg8u5IyPArbMchAtGwjRj/JMBXKtKA/p4zOLo1ygw/vA 3q64mb50qSdoRzPLFl9j+2EIkgh9+yC12e7uuFelL93YpERD1+yKRKX8YbzRR9n0daTB Z5E/g2SFLwgg/ZINw5f+pjxSvDCUCrO75YM9eFdTzlAdClK7YAspY6EfA7egiLr9bJaz Nm9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jDNesEt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i8-20020a256d08000000b00d9cf811eb97si10338352ybc.327.2023.10.25.13.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:17:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jDNesEt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 2AE578022AB3; Wed, 25 Oct 2023 13:17:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234863AbjJYUQj (ORCPT + 25 others); Wed, 25 Oct 2023 16:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234337AbjJYUQ1 (ORCPT ); Wed, 25 Oct 2023 16:16:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 967B5136 for ; Wed, 25 Oct 2023 13:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698264985; x=1729800985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cq41MKhmxSv+VmENwgWIgLLnJ6HE1k26gc7pRvVAMjw=; b=jDNesEt/WbgZTaYdX2mO3cUxTfr4nwqbsV2dIWLtbgIPbX60chXdZ85g aDgJQV+cc4nNjcx5485RUaX7loKGq13HdYo3VlXyEtTMREYxVVFfBByXH bpzXelOKmAuBs7NAnU6Cp7rTadQ80FnK9buHeh8ooWTpWTu3mtDPDXCuU vfzCnYfnifQwWWo+ZaPMVexGRxVRp4XkwEDdwJaBNU3VDhLHpvqhMKHnZ fjeNHKSYXpEiOOrzCl0XtgEn0SK7BgUN1Yl7msTDHcuU26qtXfkfoCgps 3g/361KB9ocRabQiURXcF6kCdb43UkM0SSVxn38hI63wltjQXH8TE1+1r Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="377758213" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="377758213" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 13:16:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="752459071" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="752459071" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga007.jf.intel.com with ESMTP; 25 Oct 2023 13:16:22 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, ak@linux.intel.com, eranian@google.com, alexey.v.bayduraev@linux.intel.com, tinghao.zhang@intel.com, Kan Liang Subject: [PATCH V5 4/8] perf/x86/intel: Reorganize attrs and is_visible Date: Wed, 25 Oct 2023 13:16:22 -0700 Message-Id: <20231025201626.3000228-4-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231025201626.3000228-1-kan.liang@linux.intel.com> References: <20231025201626.3000228-1-kan.liang@linux.intel.com> 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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 13:17:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780759951974928016 X-GMAIL-MSGID: 1780759951974928016 From: Kan Liang Some attrs and is_visible implementations are rather far away from one another which makes the whole thing hard to interpret. There are only two attribute groups which have both .attrs and .is_visible, group_default and group_caps_lbr. Move them together. No functional changes. Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Kan Liang --- New patch arch/x86/events/intel/core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index a99449c0d77c..584b58df7bf6 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5540,6 +5540,12 @@ static struct attribute *lbr_attrs[] = { NULL }; +static umode_t +lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i) +{ + return x86_pmu.lbr_nr ? attr->mode : 0; +} + static char pmu_name_str[30]; static ssize_t pmu_name_show(struct device *cdev, @@ -5566,6 +5572,15 @@ static struct attribute *intel_pmu_attrs[] = { NULL, }; +static umode_t +default_is_visible(struct kobject *kobj, struct attribute *attr, int i) +{ + if (attr == &dev_attr_allow_tsx_force_abort.attr) + return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0; + + return attr->mode; +} + static umode_t tsx_is_visible(struct kobject *kobj, struct attribute *attr, int i) { @@ -5587,27 +5602,12 @@ mem_is_visible(struct kobject *kobj, struct attribute *attr, int i) return pebs_is_visible(kobj, attr, i); } -static umode_t -lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i) -{ - return x86_pmu.lbr_nr ? attr->mode : 0; -} - static umode_t exra_is_visible(struct kobject *kobj, struct attribute *attr, int i) { return x86_pmu.version >= 2 ? attr->mode : 0; } -static umode_t -default_is_visible(struct kobject *kobj, struct attribute *attr, int i) -{ - if (attr == &dev_attr_allow_tsx_force_abort.attr) - return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0; - - return attr->mode; -} - static struct attribute_group group_events_td = { .name = "events", };