Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp413422lqr; Wed, 5 Jun 2024 09:29:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYsUEOlTAse09fhO6kzi2Em1bTMWoRHdbVnHFh0Hr2wbQt+tEA4cwNzjnY+pLIwRQgCERZhWYsub5MbP4eDdI/lfMH64H7B2+PwUiWJA== X-Google-Smtp-Source: AGHT+IFeJOPtWJr5YvJ0ln4QCW677Vnr6oqm/j8w0oVVKrpDJY7F6viwmQGd62xC+fEq39QHrW4d X-Received: by 2002:a05:6358:949d:b0:199:d2a:1eba with SMTP id e5c5f4694b2df-19c66ea57b5mr341670555d.6.1717604980964; Wed, 05 Jun 2024 09:29:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717604980; cv=pass; d=google.com; s=arc-20160816; b=b7Cx7Aj5pFb8O4mpmUR3FruFs2NZjt9ZQqK7csGZFKOjKUaggL5+KUO2DPlgRv/Jif rgKRJ+slkD6x947Xd7Yu16+41riB7DK5Y/XaXKbBrwrfUnTYleMGbs9B1O5L6T153aCw gN7wJTDnycHGlykpGZbp4R23mm15YC6pz+f/aYVHJ3toP7W1FssdHUu/eccFCdNGCPGT sXdZrdUBYuOODNg6y8qqlVTchZHOKHl0CHI0elJSPXJUQYlEwzIt8MCS9c4OQ3+MlQWi SUv/ZzBlGabFKlyczxepkV3usoIh+W6ohQ0X0F3wZXZ/Jr1K/cZvaAm79UtxY5n8MG03 di+w== 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=plA/1k1b4m3nAnLu/XdKuXjcGiexvjsWYLGSc15Jllw=; fh=zrVDlrC06DAIec5BvDl2IM9WrZzuc2uxw+nPFYRCHpQ=; b=O59IN43LH7sJylw5V8I+fMZpkQj5Nqtm5TVVHqKBRHwVMInmYNoKo8+HufCtvYoNMT 45xXqie8tsaxZayn5TKkCd15jaHh/9vgU9INWWTl9UluVcuc93AbkrsddrjSLQ+KCUxu B4LpBzFYyAQfz/JTKzEcHF5vlpwG2KHQ1XowzGn1moLm5bcASJyL/gUoOcgFaUNU3I9o TWvSsb2MgRdqKyqke3Htdcoq0R2jnz68xDzIl72Yw7b7b8BRiSnuU5L/T/FcAVjej3n9 Zaz7ipvTb10sqRoEjcCjsUiCmMmQnRgPCdpBE8fBgajCl0mrMDUSa9goPpGgGDwdO1xb SvCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LiyqIBvQ; 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-202897-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202897-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35b40c671si2394892a12.573.2024.06.05.09.29.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 09:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202897-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LiyqIBvQ; 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-202897-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202897-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BDC52B2392B for ; Wed, 5 Jun 2024 16:15:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C9481922CC; Wed, 5 Jun 2024 16:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LiyqIBvQ" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 27250188CAE for ; Wed, 5 Jun 2024 16:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717604082; cv=none; b=lAo3hFbTLRTPP/USxVyGsvxqgU+qQbHZ86+GRzfahmTmzi+ELmkRxxeb9RacnDbJTFY23YyswuHmNxPXcGNAyRU/LQpgCuVUkUpSlRiHrnokUyXkLorqNruN2g7jGC1sGbalXNMThtsaIBTpM1TqFBtVHbRHvrtWjqnynJv5wjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717604082; c=relaxed/simple; bh=mtXhJIqFcxEurjVvwCm6Vo/pYjEoRRPxXTYeDGZw23k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgKKEPg5c0LuiD4LO6CchFr1fE9tunOHay9HgMzzLNrK8j4ukEmdW95jVYPyKDvABPO7Vmtwqc/h5miOJACfE12TeobTmUvh6HDpGDx0eUSKEbEcWqHpVgdX/ouCErRXLJjMyMfuXOkNVIXo3ohuDE4IP0r8BRP+qQVxL8C0gzI= 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=LiyqIBvQ; arc=none smtp.client-ip=192.198.163.8 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=1717604081; x=1749140081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mtXhJIqFcxEurjVvwCm6Vo/pYjEoRRPxXTYeDGZw23k=; b=LiyqIBvQkX4JvoGSHg99JRD5qJDQ8uwtxfnL/lmnA+oDz63O0aYNMmqE 4jlUpiYvTHn9yoCcsZ9hEBFezg1jrB20uVB2uVvnNwiggrbOBD4bGfkmD B0SV/6Fjy5FXlbWKrhIAVzIDOLRUN3Y6WIpsG0vM5N/Lao/3PQ48tf+G/ K1IigpDR2RPgADF5JqCcvXkgCFCbjTUkHIHZ6aVgocQsZOTtWfnviB/V6 3owGh+EtWz6Iy11onmWfT3QDw46RPhmC1sGYxuiP1ktcrpbakovTfchyB 49YUxHEwnS4Pr+TDHGYzwMJ6o11NxyAK7hZ3tg1iXDvVUHYVJ2ua4tFRa A==; X-CSE-ConnectionGUID: kcvSYQfgSGGVB6IndcXSDw== X-CSE-MsgGUID: wYLpIuQ7QWSVf738/Ti/5A== X-IronPort-AV: E=McAfee;i="6600,9927,11094"; a="31772306" X-IronPort-AV: E=Sophos;i="6.08,217,1712646000"; d="scan'208";a="31772306" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 09:14:37 -0700 X-CSE-ConnectionGUID: rT5y1NMdTs2EDzChbX7i+Q== X-CSE-MsgGUID: H0F+atmnTIOAf2GYbyjy8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,217,1712646000"; d="scan'208";a="42581905" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 09:14:37 -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 v2 3/3] x86/resctrl: Replace open code cacheinfo search in rdtgroup_cbm_to_size() Date: Wed, 5 Jun 2024 09:14:27 -0700 Message-ID: <20240605161427.312994-4-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240605161427.312994-1-tony.luck@intel.com> References: <20240605161427.312994-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 Use get_cpu_cacheinfo_level() instead of open coded search. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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