Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4961687ybi; Tue, 30 Jul 2019 11:12:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTm6zTZEK6AjX//BogfEkKd28SEzVU7SKFqs/jdy+cd1GIepgxm7YIwVEuXlzBf24BYHqZ X-Received: by 2002:aa7:8d88:: with SMTP id i8mr43892598pfr.28.1564510343729; Tue, 30 Jul 2019 11:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564510343; cv=none; d=google.com; s=arc-20160816; b=Em1wlAm6WZTTuUTZrbKFxj4VMAdp+5oUYbA4xQVjx5vBWH7i9i4eukNNHmeAxzKPNp t10Qkfow5v6UOskrogmowhlQ5Iax/vEheUo2Ge0KSSz+9RVxttlhwzsW5JG700HCOYrw XRhTTZ26oG+AAeWc4kA3Oy+5RpenZETl1JlKaeQvVAQVrXHkH8rg6dKvVQz2tcCcYgYz v/ZELPbpI7yLbkb68bq0mSCN8RaRVhTKXfS3aAtMrnTfqRfCkDURYRuupIIdrvvyiPgk 26oHO3NqrOvlEoMoKamPovLGIQ8nkJUZYKbBnag0uXSd6Xy9rVC6chG3IhTry5D5GSyE 9BiQ== 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=KVVYLkZumkN+X5y8WJngT5ckd13XVs3zGm8XZ5AhW5I=; b=bKP/S1WkF8BUi/bKCIa3MMBZXCwq2tG/zQlu6Ss7IoNrzG8Y0V6Bi/CsrDCDGEw+js hjxI0zIe7zMahxa0b2Di/WK+smWjDUYAiVpAOj1svl7l/ELDuqqnzj/eg6/M+5+JlUS/ Ne7Kk9+LM8y5+x7Xkk96t1CWxE3TYlU9n/I3ezfnz5yhv76X80TiRUeVaq7ks7LSdiUo 8T5YWTX3WdjCVVfgEyEfq12m6u8MqNIJr4uyw6fuvGF4q2ZI7b2nj3+pdpgegtTPbyFq jx75GN9MouU2cbaYUx1nBGT7BKlJSpMTY5UD1j4MdTB9Rxfp4/9LMoBLqgL5lURo8Rl7 GgdA== 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 a15si18222247pgk.523.2019.07.30.11.12.08; Tue, 30 Jul 2019 11:12:23 -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 S1731118AbfG3RcV (ORCPT + 99 others); Tue, 30 Jul 2019 13:32:21 -0400 Received: from mga04.intel.com ([192.55.52.120]:3584 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbfG3RcS (ORCPT ); Tue, 30 Jul 2019 13:32:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 10:32:11 -0700 X-IronPort-AV: E=Sophos;i="5.64,327,1559545200"; d="scan'208";a="162655298" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 10:32:10 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: kuo-lang.tseng@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH V2 10/10] x86/resctrl: Only pseudo-lock L3 cache when inclusive Date: Tue, 30 Jul 2019 10:29:44 -0700 Message-Id: <08551f6aed73bbc122430c8e0c57bfe6c720a263.1564504902.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 7ab4e85a33a7..b4fff88572bd 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