Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2819649rda; Wed, 25 Oct 2023 13:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx/akRWYRr+1DTrxNYMmZaE/UvgTTCAmfAlWCSLEmghRE7nPGok4KgHQiKEleIjxW6JmrY X-Received: by 2002:a0d:e648:0:b0:5a7:fc84:4314 with SMTP id p69-20020a0de648000000b005a7fc844314mr15808975ywe.40.1698265022564; Wed, 25 Oct 2023 13:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698265022; cv=none; d=google.com; s=arc-20160816; b=yK3icpaCXqSgk/qR1eOgI/P2wWQC2IyjSE37j/TENWpeCa8/KvbcWympaQOja9wsPB X/iMISK5mV76VgaBypcimruByzhmNiUFat8Zfv4sJMnvwPWjbpg3Fq1mUROmVIUxDAya ejAk9bfHC98VfThFRy63Y/7rXF42NbWgID0D7sjGqNFIcKhevDPPFIsAP4XYl4rMwMTh vrWvm7fM74BrrQRVBF2rXk+orFi2URvGZGgEM1yPJTpcPhSL8oZHpu2KoliCEMW02ccv VsFXh25uqCa0HvKQ6r83/6iEbB0QaltL0gC8pf+uRfwzV309OFo6OYhUG1vvJrt8ujHB 0LJQ== 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 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 Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w15-20020a81a20f000000b005708b9a9193si12625811ywg.559.2023.10.25.13.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:17:02 -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="jDNesEt/"; 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 5409F817C8AB; Wed, 25 Oct 2023 13:16:54 -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 S234859AbjJYUQi (ORCPT + 99 others); Wed, 25 Oct 2023 16:16:38 -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 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 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]); Wed, 25 Oct 2023 13:16:54 -0700 (PDT) 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", }; -- 2.35.1