Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1082612ybd; Wed, 26 Jun 2019 10:53:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKislU+N+qtbSohN2fswsREanvFKT++YYI6kmrqGHpQrUreKdK1Bot8Nqm+wBVGSPNISKA X-Received: by 2002:a17:90a:2768:: with SMTP id o95mr332013pje.37.1561571607192; Wed, 26 Jun 2019 10:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561571607; cv=none; d=google.com; s=arc-20160816; b=ybpRYPqwA1IXf1hK4ou2BaiIOZsv0TR6Rp5ooKwcPMfy37zyO5lhbvb+hYB9aoJX5u 1Vg/TfnO13hQbwADV/PGddm/8+vQBaOrRl64VQwH0+nr3N1iSeDyG9xWwyHYRQ3tEEFu fN9kEZ0GNXFFvyne60X0B8W+UFiFHlQh2iSBPtRxk9lkdWiiZAZ3lKsRRpjaIbq4lOLb ilvenkb3YCxNXxfMwP0koLAj3uvGbqLvoK7LCcp9AXK+ped0VvdjKWEPBnbTgPm4A/TA fj8Tpfhb/tK39bqfbBhUpT87h8GxkdlAu2POJTf3BvFRJsDuLf4bQb2nLp0bJ1q2DxcE 0CBg== 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=Y3qL/tNxz5rB/AIa1iqHcYsJOMjDzsg6Q7gpH7rR4SY=; b=divU2MJFGvXfiq885Ozq+osVZ7LBssJ5x4THCCWotz8NAeof8tjpkawzBFLLCoEEWM ftgMaS5qWlVYyIcb023+nAwnostV0RfzAS1XK+pkQs5bIMmDxcXV1dJp/DpY9jh7mnkF 765EGoKh+3a498KS9VbaZwwVCxvp1iKefjDwMh1wSrkBsLIwsU+xCoaWvGEb32faJUKf zTUh9sVzahD6kyxyfWYM0BUxxdiQRtk1wPtuL20MHbr6BeX80k+hGseQuwek8b7jHxAB f+H7nfj7ZQozcJlbipWC4uytcGH+xzh78IpwCDNcMAL0LJtB//MiXhhATMpILvElYRG/ DslQ== 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 w10si15924072pgs.50.2019.06.26.10.53.10; Wed, 26 Jun 2019 10:53:27 -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 S1726677AbfFZRv3 (ORCPT + 99 others); Wed, 26 Jun 2019 13:51:29 -0400 Received: from mga01.intel.com ([192.55.52.88]:49817 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726559AbfFZRvL (ORCPT ); Wed, 26 Jun 2019 13:51:11 -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:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,420,1557212400"; d="scan'208";a="337288610" 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 10/10] x86/resctrl: Only pseudo-lock L3 cache when inclusive Date: Wed, 26 Jun 2019 10:48:49 -0700 Message-Id: <1e53b953147bca171814305ff764931d71eec09a.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 Cache pseudo-locking is a model specific feature and platforms supporting this feature are added by adding the x86 model data to the source code after cache pseudo-locking has been validated for the particular platform. Indicating support for cache pseudo-locking for an entire platform is sufficient when the cache characteristics of the platform is the same for all instances of the platform. If this is not the case then an additional check needs to be added. In particular, it is currently only possible to pseudo-lock an L3 cache region if the L3 cache is inclusive of lower level caches. If the L3 cache is not inclusive then any pseudo-locked data would be evicted from the pseudo-locked region when it is moved to the L2 cache. When some SKUs of a platform may have inclusive cache while other SKUs may have non inclusive cache it is necessary to, in addition of checking if the platform supports cache pseudo-locking, also check if the cache being pseudo-locked is inclusive. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index 4e47ad582db6..e79f555d5226 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -125,6 +125,30 @@ static unsigned int get_cache_line_size(unsigned int cpu, int level) return 0; } +/** + * get_cache_inclusive - Determine if cache is inclusive of lower levels + * @cpu: CPU with which cache is associated + * @level: Cache level + * + * Context: @cpu has to be online. + * Return: 1 if cache is inclusive of lower cache levels, 0 if cache is not + * inclusive of lower cache levels or on failure. + */ +static unsigned int get_cache_inclusive(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].inclusive; + } + + return 0; +} + /** * pseudo_lock_minor_get - Obtain available minor number * @minor: Pointer to where new minor number will be stored @@ -317,6 +341,12 @@ static int pseudo_lock_single_portion_valid(struct pseudo_lock_region *plr, goto err_cpu; } + if (p->r->cache_level == 3 && + !get_cache_inclusive(plr->cpu, p->r->cache_level)) { + rdt_last_cmd_puts("L3 cache not inclusive\n"); + goto err_cpu; + } + plr->line_size = get_cache_line_size(plr->cpu, p->r->cache_level); if (plr->line_size == 0) { rdt_last_cmd_puts("Unable to compute cache line length\n"); @@ -418,6 +448,11 @@ static int pseudo_lock_l2_l3_portions_valid(struct pseudo_lock_region *plr, goto err_cpu; } + if (!get_cache_inclusive(plr->cpu, l3_p->r->cache_level)) { + rdt_last_cmd_puts("L3 cache not inclusive\n"); + goto err_cpu; + } + return 0; err_cpu: -- 2.17.2