Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp678684lqh; Fri, 31 May 2024 12:58:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsmPsVUvKbottXx77eL+H2F7F7P6Kl/C6EjOtJnJPkSLqk8/V/nxh2z29xv9vMnmxoBZ0OClg88kzEfG0vFx4UfB0zZNmEuWbolDUXgg== X-Google-Smtp-Source: AGHT+IHs/cpZ3tTwAd2+/3sQko+mjKPI1oqbFPgadhEzguWxu0n2hHAm0VmubdHtfUKR/g6QDUuN X-Received: by 2002:a17:903:124f:b0:1e4:6938:6fe3 with SMTP id d9443c01a7336-1f6370bd2f3mr36915175ad.58.1717185498412; Fri, 31 May 2024 12:58:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717185498; cv=pass; d=google.com; s=arc-20160816; b=HbbQXqz2rOE0p1oIM25EeT5E3mtKDOKQ2/0L5OOu4qgukk3LWjAwhl4HWuwwm/SOEm 7fE79QFb96kpqY+n2X26AE0twE7gpJlnE5lvQA6St6SGdEmR+/MVPMRuC1JSfCazBVH0 kRvv0pv49u89PmSlXE3ZD/i4y1jztYCB3Bj8RJcbY3MMwUm0LOiDrrWVBZxPn18htAzc m3m4Pw7iYcoLy09Rrq02EZmg3DFHhqBpzwVvGRrefYKaYeUniq4f5en2iF+fhX8K2E/h ZXaqxnsSUnnt9gD80YT7i0DzzHhZUzkDvRmkbWwozHbWQl4prk4OcRuR1OLkU3fAiFcA opyg== 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=pRyI24QtZiGHPNLTYUWqnLUMCUNgW56VVwQ0KzANPCM=; fh=AgZH9hThf7iIjfvD+TZxXscuAfjnRLd+km2oMb6hQHg=; b=F46Phz+WT5Blbkw9vBqdgOUM0V2BFjR4JjpscUdKthfysp9DGYpK8yEeE6keq/cTO8 qTWVYGWzMPw6a64Tfte1YR+x/GjPjxqPwxK3gj5hmsl73pkp6ERwHWyyHlYAityV7p6E hhL9998OEfmkoX6kwBWZLEBEi8JhU/RbjSeFaOm9kJSBWXmlOqDeSdaEhbTanAQ7fU72 i+XdzobMp+noDyArFw8gjIRvEoo79PxWSYZSudhHqm8S5T/6JXzE61fhB9Ec94QhW/Qd Wl7Xh/RFce3+S6FcpJXqWT4yi00rlbL6P8t8ucUc+Ql1mQKnSGeUSYEdFmCykM8jCxiO TOUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SdsRnDqn; 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-197413-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197413-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 d9443c01a7336-1f6323dd885si20114805ad.201.2024.05.31.12.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 12:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197413-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=SdsRnDqn; 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-197413-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197413-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 A8DC3287BC3 for ; Fri, 31 May 2024 19:58:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C7E717E456; Fri, 31 May 2024 19:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SdsRnDqn" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 E74CA17D8B0 for ; Fri, 31 May 2024 19:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; cv=none; b=mL3vM2mbjZSyIWlSfoZgOKrg4Mo+POGoEOwyBu8ODFaNSdVxV37PwQUi2f97C//bqNnZeiNLrjdxGHX6/gTYaXSoCHNrhiELpEweMGHZYjf7sdUvkb7MCTY1vnxCaYYydhU0Vp983MFqQI7RNtAACQxz+/lo4gJ84FF+u1EKMaw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; c=relaxed/simple; bh=waO47AVKQXebwki+vP6AIbp5ruc9+vs3ozpJycT6ARA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t9pl5SBc6JO0BFeBXveDE87KbETbomPMk90SF+iJgH8xKwKfVxQ5VzMPnQys1t8/wWhv70+inArICNoZD4alJkyG/aJmvUCaBbl38zQfA3jwQtX50EyaMdsUVx8u+V94l9J3REBo7FGszlVVJQvXizzIvEFRpdTpjN8JKvQGcKk= 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=SdsRnDqn; arc=none smtp.client-ip=192.198.163.18 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=1717185457; x=1748721457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=waO47AVKQXebwki+vP6AIbp5ruc9+vs3ozpJycT6ARA=; b=SdsRnDqngIY/gjuwLjQHTaAEYGSlrWwhYxK27cycQkDKi8AIMzwQDw0u 92Rhd189cGUk3zV4GeSX1rsWyefdy+6JpDBkuO8uA4ebzBJvDgnUjAEAN EenGxak5rZZ4R+kktrJHsy4GYImlEvdjgidUafqm/9MwJjCfDZfrxL3d2 JmnSXVyOgCBo43huKKzmnt5dRnFQ/wcwCcQofQnOJqDdlHIxasY6a8AhQ 6eEQHjbNuIa4Vr993F0upzOOqQdseUBTaL59knz0kDaOBpN/q1aYzgrMB PqlqBuGbvN1kHKCDtqNrvvEJAXVNNj4pla55m5xxKwY9UixhOhtyDTYEZ w==; X-CSE-ConnectionGUID: ulTfKwJpS0S+Q+av3a/eTA== X-CSE-MsgGUID: Aojv2MvKTKSSd/CRU7UqcA== X-IronPort-AV: E=McAfee;i="6600,9927,11089"; a="13501156" X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="13501156" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:33 -0700 X-CSE-ConnectionGUID: /+Q61v0/Q8CNZEn5CRgApA== X-CSE-MsgGUID: ArwkRCBhT3WOD32XSQ+O9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="59438876" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:32 -0700 From: Tony Luck To: Greg Kroah-Hartman , Andrew Morton , Thomas Gleixner , Borislav Petkov Cc: 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 3/3] x86/resctrl: Replace open code cacheinfo search in rdtgroup_cbm_to_size() Date: Fri, 31 May 2024 12:57:20 -0700 Message-ID: <20240531195720.232561-4-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240531195720.232561-1-tony.luck@intel.com> References: <20240531195720.232561-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 --- 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..4a5ab0f6a412 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; + struct cacheinfo *ci; unsigned int size = 0; - int num_b, i; + 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