Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7289199ybh; Thu, 8 Aug 2019 13:11:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7+9S94sWL/JM+7qLfzyjacJVeGQifGfSXu2s5Yh/YVOimBiz+35HvvUuv7d4ZLh7hfSCU X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr5759792pjo.94.1565295080927; Thu, 08 Aug 2019 13:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565295080; cv=none; d=google.com; s=arc-20160816; b=OsgatvYFi7NARQf+zpG0adiI0utfby23Vjpf3YWGQ8Y8nCWIIGDgezpRZEGLlO7FjY /FubIZkVk0YAFg04FWHriQCfG31JTw8WF8uMsC2OXA+kcEpYWYqHysFjwHRelwem/2hk SqrxtXt9Xwce6Z7WEjbScxGHYUOLpk9s5DqYHKCyeI4nPwVQ5a04A9D2PRLEMeu0WeMN BkEnzs5MA/P+OV776QhNxDLeXGUj86qYwCbHZIi+w4pCXlkJs/wWAWDs4ncAZIfevypV z+GrXoRbEnH80axvwyoGxAQCtgQE5QbWm3fmHETsJuX8qM3c6U15kUceThrhDZde4D8c 0UcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rhD5l6/DW/MzjHDKyQOg4XJx7eqsL0gPhZJdiMn5/I0=; b=YowTFvo+eYx9QH6AjdsLot7ILXl/aAXW7UOeTZyAKhpqImZk5ByBs9FaoXHZCYDiXO o7TWynLCiY9yWvDX1DqfMJLKKfrD+Nh/Pkzfj81wiS6eiSX7wJL6rD+vpj8Kq/yP0Xfy 4AlPGV0G+SgvQ1qcrwWSu+A3bj1kGb6IMYFjbBioDfGkleU1uCZCaYR7SjZV5palBXmz hUbMlkD8z1pl29/KR2E5QY+I0WCjQ5FEeWjsJQoMjzP2TPX81foy7PYpvx4MqldmN1YQ 5W2UFpIw8YNKKYvq+ZxIXWyxn+NBOgegzj2V+C0YTiu01idpQAb5Nn9To3jhzapLJtKo 5o+A== 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 c5si54163086pfr.25.2019.08.08.13.11.05; Thu, 08 Aug 2019 13:11:20 -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 S2404451AbfHHUJC (ORCPT + 99 others); Thu, 8 Aug 2019 16:09:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:7358 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390202AbfHHUJC (ORCPT ); Thu, 8 Aug 2019 16:09:02 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2019 13:09:01 -0700 X-IronPort-AV: E=Sophos;i="5.64,362,1559545200"; d="scan'208";a="186459097" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.251.6.227]) ([10.251.6.227]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 08 Aug 2019 13:09:00 -0700 Subject: Re: [PATCH V2 01/10] x86/CPU: Expose if cache is inclusive of lower level caches To: Borislav Petkov Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, kuo-lang.tseng@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <151002be-33e6-20d6-7699-bc9be7e51f33@intel.com> <20190806173300.GF25897@zn.tnic> <20190806183333.GA4698@zn.tnic> <20190806191559.GB4698@zn.tnic> <18004821-577d-b0dd-62b8-13b6f9264e72@intel.com> <20190806204054.GD4698@zn.tnic> <98eeaa53-d100-28ff-0b68-ba57e0ea90fb@intel.com> <20190808080841.GA20745@zn.tnic> <20190808081342.GB20745@zn.tnic> From: Reinette Chatre Message-ID: <1b0b14aa-2c78-8259-9fdc-06ee7f6050f4@intel.com> Date: Thu, 8 Aug 2019 13:08:59 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190808081342.GB20745@zn.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Borislav, On 8/8/2019 1:13 AM, Borislav Petkov wrote: > On Thu, Aug 08, 2019 at 10:08:41AM +0200, Borislav Petkov wrote: >> Ok, tglx and I talked it over a bit on IRC: so your 1/10 patch is pretty >> close - just leave out the generic struct cacheinfo bits and put the >> cache inclusivity property in a static variable there. > > ... and by "there" I mean arch/x86/kernel/cpu/cacheinfo.c which contains > all cache properties etc on x86 and is the proper place to put stuff > like that. With the goal of following these guidelines exactly I came up with the below that is an incremental diff on top of what this review started out as. Some changes to highlight that may be of concern: * In your previous email you do mention that this will be a "single bit of information". Please note that I did not specifically use an actual bit to capture this information but an unsigned int (I am very aware that you also commented on this initially). If you do mean that this should be stored as an actual bit, could you please help me by elaborating how you would like to see this implemented? * Please note that I moved the initialization to init_intel_cacheinfo() to be specific to Intel. I did so because from what I understand there are some AMD platforms for which this information cannot be determined and I thought it simpler to make it specific to Intel with the new single static variable. * Please note that while this is a single global static variable it will be set over and over for each CPU on the system. diff --git a/arch/x86/include/asm/cacheinfo.h b/arch/x86/include/asm/cacheinfo.h index 86b63c7feab7..97be5141bb4b 100644 --- a/arch/x86/include/asm/cacheinfo.h +++ b/arch/x86/include/asm/cacheinfo.h @@ -5,4 +5,6 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id); void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id); +unsigned int cacheinfo_intel_l3_inclusive(void); + #endif /* _ASM_X86_CACHEINFO_H */ diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c index 733874f84f41..247b6a9b5c88 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -187,6 +187,7 @@ struct _cpuid4_info_regs { }; static unsigned short num_cache_leaves; +static unsigned l3_inclusive; /* AMD doesn't have CPUID4. Emulate it here to report the same information to the user. This makes some assumptions about the machine: @@ -745,6 +746,11 @@ void init_hygon_cacheinfo(struct cpuinfo_x86 *c) num_cache_leaves = find_num_cache_leaves(c); } +unsigned int cacheinfo_intel_l3_inclusive(void) +{ + return l3_inclusive; +} + void init_intel_cacheinfo(struct cpuinfo_x86 *c) { /* Cache sizes */ @@ -795,6 +801,7 @@ void init_intel_cacheinfo(struct cpuinfo_x86 *c) num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing; index_msb = get_count_order(num_threads_sharing); l3_id = c->apicid & ~((1 << index_msb) - 1); + l3_inclusive = this_leaf.edx.split.inclusive; break; default: break; @@ -1010,13 +1017,6 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, this_leaf->physical_line_partition = base->ebx.split.physical_line_partition + 1; - if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD && - boot_cpu_has(X86_FEATURE_TOPOEXT)) || - boot_cpu_data.x86_vendor == X86_VENDOR_HYGON || - boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { - this_leaf->attributes |= CACHE_INCLUSIVE_SET; - this_leaf->inclusive = base->edx.split.inclusive; - } this_leaf->priv = base->nb; } What do you think? Reinette