Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp76631lqp; Sun, 9 Jun 2024 17:40:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeRxgEgqCIgxC7hzbbucbgS0WDmab33MeN2JgLj0cvtdnreYlo/H9086OtLLKgeUBTIGrodVS5c5V7wVHaikYBVW2jf1u9M1N/Mju1iw== X-Google-Smtp-Source: AGHT+IFuiUgqfILJkaXpTWkVUnepsgREHZVlII9APeNsdPh0162kqwMX+LgKZIPeZF3UN33wEbry X-Received: by 2002:a05:6870:15c2:b0:254:acd1:52a with SMTP id 586e51a60fabf-254acd180c5mr3461403fac.20.1717980016563; Sun, 09 Jun 2024 17:40:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717980016; cv=pass; d=google.com; s=arc-20160816; b=VGHTKT3uVxQ6ZDO7KIwom66/dyXCB0YAp3Aolrmg0jn+sAXOEY8gBGvwxrD6xroqFw Yg/FK/nMgidab5m878XRkbSwZL/I0XL9mxu8riqzu2WAq1rx5EzwI/R+738jcCRGinE3 bBFpssbdpmNXkc700RbmThaALRZpK0rr5ilcfwHtE67b45txB57X1PUIpU2wsq2ixOH2 C7/yPBUPPa/2MklTQxCVvQxFea/XjnXEbsMAWeXc7yhsKqLYQiplVVlNaFUXyMsopC23 I6ZVF7WBN1W+996eEdqM3iGZL8waLTIs2M5MNd6dLF11X6ud3nWWLUZPnNWn/L+B/0YQ rjaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0VYZX9HWZlYQ6exuMoCLzN9R2S+o/vonkXCiskCZJXY=; fh=zrVDlrC06DAIec5BvDl2IM9WrZzuc2uxw+nPFYRCHpQ=; b=MBdpE5ZRs/1uvVjkWibjEvdCZ6YtHTPoYHBtqgMaLh4qVgArFXykEAdnB9BcIIxnan tWY6PIUHUEMuC5BPsmflaWHrT8IgqyuFZoAizDl2k+Qo9Sitj4ytazYFQ7INhdGFx0b1 naXzqfErxQbXVKVN9S/KpSoUKYSPgEZX8vkDb/cQl+b5SY9XvA3+mzKowwJT0mgKxJCS 3Z4OLNRCde0pDegJnGj+lvqKR33XJ3x6rViq49HC3S43rycjNFXihWPxJXDfjJaQuapI RKIARWewthdyPaWqRJObPMIBod20bKCoeRZasKPFPk4p8GpX+AxHQaWcOM3TohVX9H1s DECQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nlHU+imG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-207577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e5ad02a9fdsi3818216a12.420.2024.06.09.17.40.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 17:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nlHU+imG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-207577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 305C4281D4F for ; Mon, 10 Jun 2024 00:40:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E165B65E; Mon, 10 Jun 2024 00:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nlHU+imG" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1B9D1879 for ; Mon, 10 Jun 2024 00:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717979980; cv=none; b=SPRmahg3COdPxqGwYUAKz9sXgSTc9I7zCBn0x30gRkJAGOytd9Cx6D2ZZ2ppHuQzghZYJVEQak+HwdMcnCjKCvnNbUYt7vO02DEKTXplxl4vOf7kRw31ZnwEJa33KCOUuX4TEgYDV7VQ7RC5/JEFCdOkVZ189Xg3WdsvpUruWI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717979980; c=relaxed/simple; bh=RmlyFZFXIPl3nE3NosJA82cQlJCREl1lNzarMkr1BuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RDcuUL/JVP33fQlcB+uIx1qNW/3nPYAG8miiFl8qeCA7+7IVrI7Tx9us6ORqjlsRVsJUE2rZGHbf0CBvDY3ab0Ew8o6fR2QJNnaKmiDenscXaZa9BNGn7gET/7/Mio1COneK6RgUT83Yu+efXBzpOux4BiEe1Ho+OoRRWcgnRQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nlHU+imG; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717979978; x=1749515978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RmlyFZFXIPl3nE3NosJA82cQlJCREl1lNzarMkr1BuQ=; b=nlHU+imGRdR2MZ15/V1Pc1HwzmcDDJCHikw1y9gWXfZq0qzp85o+e1lW c4/xHzMUEA4MWiVn6ztTlwr/Yt52RHl99FqX8lx9fhEG7D5jaIjRaFZ/l JztjkzvzeKGvsPEKB0fgLQdUFAzdwtFUfhcXZawqAyQ+lMuS0wftQUolS ZbFRZQE2pCTjcYXJG4Q+rifQhSTRLE1+EIiZBaeac3WTiamgMQ6huS/CH PH2eytDC5nBJlhUIekMv624kvmIEygGJR/i0d9buazzZaUXg/RVUXQ6CL GVoqySE+Fr3H1ew9YikWmunvpHVjvew/TvDa3mfjdwZ4NFqf3KePdr+I0 A==; X-CSE-ConnectionGUID: zB6OoPN/RjyIkVuNqf1c6A== X-CSE-MsgGUID: ltqxHOSCTziKkzs25pzebg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="37154986" X-IronPort-AV: E=Sophos;i="6.08,226,1712646000"; d="scan'208";a="37154986" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 17:39:36 -0700 X-CSE-ConnectionGUID: 7h+fxINfQfe2DNAQAI8j7Q== X-CSE-MsgGUID: XBNWwJQeQFCgJi5+7zGlvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,226,1712646000"; d="scan'208";a="38829888" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 17:39:36 -0700 From: Tony Luck To: Borislav Petkov Cc: x86@kernel.org, Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v4 4/4] x86/resctrl: Replace open code cacheinfo searches Date: Sun, 9 Jun 2024 17:39:27 -0700 Message-ID: <20240610003927.341707-5-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240610003927.341707-1-tony.luck@intel.com> References: <20240610003927.341707-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit pseudo_lock_region_init() and rdtgroup_cbm_to_size() open code a search for details of a particular cache level. Replace with get_cpu_cacheinfo_level() Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 17 ++++++----------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +++++--------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index aacf236dfe3b..1bbfd3c1e300 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -292,9 +292,8 @@ static void pseudo_lock_region_clear(struct pseudo_lock_region *plr) */ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) { - struct cpu_cacheinfo *ci; + struct cacheinfo *ci; int ret; - int i; /* Pick the first cpu we find that is associated with the cache. */ plr->cpu = cpumask_first(&plr->d->cpu_mask); @@ -306,15 +305,11 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) goto out_region; } - ci = get_cpu_cacheinfo(plr->cpu); - - plr->size = rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); - - for (i = 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level == plr->s->res->cache_level) { - plr->line_size = ci->info_list[i].coherency_line_size; - return 0; - } + ci = get_cpu_cacheinfo_level(plr->cpu, plr->s->res->cache_level); + if (ci) { + plr->line_size = ci->coherency_line_size; + plr->size = rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); + return 0; } ret = -1; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 02f213f1c51c..cb68a121dabb 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1450,18 +1450,14 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of, unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, unsigned long cbm) { - struct cpu_cacheinfo *ci; unsigned int size = 0; - int num_b, i; + struct cacheinfo *ci; + int num_b; num_b = bitmap_weight(&cbm, r->cache.cbm_len); - ci = get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); - for (i = 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level == r->cache_level) { - size = ci->info_list[i].size / r->cache.cbm_len * num_b; - break; - } - } + ci = get_cpu_cacheinfo_level(cpumask_any(&d->cpu_mask), r->cache_level); + if (ci) + size = ci->size / r->cache.cbm_len * num_b; return size; } -- 2.45.0