Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1081293ybd; Wed, 26 Jun 2019 10:51:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGcfeDjpCHeOIEVbg0K9E/XQ1pnUg0aqpuh6mAWlHE5KYpfM1Rb1F0Bn/kS0iPyF5S9mwX X-Received: by 2002:a17:902:6b86:: with SMTP id p6mr7076013plk.14.1561571517025; Wed, 26 Jun 2019 10:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561571517; cv=none; d=google.com; s=arc-20160816; b=v5BB0bFuS0NGOK8DYyW1yGylVWvuzRIaLOlc3eiF620Bhc87SCf/9P0Z/Fq4tinON2 C665jN/GltKdF2id9uBXOrQ13GdYFKF+ItN7e/AkUcEhdARIYBpZB6kHBjogRNlKprDX e8GW2IKOEWRxBAOWe7ojQogY8MLLmua8FWNVszL7FiljrJxfibHAydWyL6ub5J96O6Vs 9ZJhyBCuolGfGs4GTvEkSHMcMa3vaiyfpHwkyk0/TJI3Zwl0A1VGKYgfS2fmXm6GSHYk jzF/X0cNqfegvrHFlKOfQBn7XkxcCL9sT2YMkCCXT6Sya1Q/yHrkO8sjft5oL7fIWzRi gieQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=S4Ud9z/WBSNBBQaOhk95RfBQawTaHjT2EwBJO6aZ/Og=; b=saR97Rfbw2FJKcdk2BB+HtSk4bg8bAinQjSzZOPoSbYcr/gQqOb+a6tpQcfP90HoIP aO5UuWi209AUlFSNS2IpviUpHWJfjyb5XSv1PSGxv4wQEc3d5Ha0aBf+rHacksMxgqOV bCeCZGZGhR+ND9YpZGPGKaxzoQHOS83Xnu1Xyr4ZQNnejaD9YlbV1Cxp73eBkS+2fgCc 72kaGFdbJRRfzby3TTq45Mjuf4hOVWL7frsYsOEUcI+pz4iDJnrLtLpQMIaS3jndw2Vh 0dG2F77oLl8n1zFRwwpz7KKES1w3+dwXvPi+xLp9y621E72+XPkTU3QMwKpWF821xcjD rS2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si2571582pjr.65.2019.06.26.10.51.40; Wed, 26 Jun 2019 10:51:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbfFZRvR (ORCPT + 99 others); Wed, 26 Jun 2019 13:51:17 -0400 Received: from mga01.intel.com ([192.55.52.88]:49814 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbfFZRvK (ORCPT ); Wed, 26 Jun 2019 13:51:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 10:51:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,420,1557212400"; d="scan'208";a="337288591" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga005.jf.intel.com with ESMTP; 26 Jun 2019 10:51:08 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH 04/10] x86/resctrl: Set cache line size using new utility Date: Wed, 26 Jun 2019 10:48:43 -0700 Message-Id: <4f97fcb9c4bd36d5378b6bf3c67710dcf2b53be3.1561569068.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for support of pseudo-locked regions spanning two cache levels the cache line size computation is moved to a utility. Setting of the cache line size is moved a few lines earlier, before the C-states are constrained, to reduce the amount of cleanup needed on failure. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 42 +++++++++++++++++------ 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index 519057b6741f..3d73b08871cc 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -101,6 +101,30 @@ static u64 get_prefetch_disable_bits(void) return 0; } +/** + * get_cache_line_size - Determine the cache coherency line size + * @cpu: CPU with which cache is associated + * @level: Cache level + * + * Context: @cpu has to be online. + * Return: The cache coherency line size for cache level @level associated + * with CPU @cpu. Zero on failure. + */ +static unsigned int get_cache_line_size(unsigned int cpu, int level) +{ + struct cpu_cacheinfo *ci; + int i; + + ci = get_cpu_cacheinfo(cpu); + + for (i = 0; i < ci->num_leaves; i++) { + if (ci->info_list[i].level == level) + return ci->info_list[i].coherency_line_size; + } + + return 0; +} + /** * pseudo_lock_minor_get - Obtain available minor number * @minor: Pointer to where new minor number will be stored @@ -281,9 +305,7 @@ 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; int ret; - int i; /* Pick the first cpu we find that is associated with the cache. */ plr->cpu = cpumask_first(&plr->d->cpu_mask); @@ -295,7 +317,12 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) goto out_region; } - ci = get_cpu_cacheinfo(plr->cpu); + plr->line_size = get_cache_line_size(plr->cpu, plr->r->cache_level); + if (plr->line_size == 0) { + rdt_last_cmd_puts("Unable to determine cache line size\n"); + ret = -1; + goto out_region; + } plr->size = rdtgroup_cbm_to_size(plr->r, plr->d, plr->cbm); @@ -303,15 +330,8 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) if (ret < 0) goto out_region; - for (i = 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level == plr->r->cache_level) { - plr->line_size = ci->info_list[i].coherency_line_size; - return 0; - } - } + return 0; - ret = -1; - rdt_last_cmd_puts("Unable to determine cache line size\n"); out_region: pseudo_lock_region_clear(plr); return ret; -- 2.17.2