Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4733113pxt; Wed, 11 Aug 2021 12:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEJhAxHh0nOE1HoY3CfgR3yHL6+o4OY9MkO/4QaBf/INP5xPSwNILHvFR1q3Z7UNzUztzw X-Received: by 2002:aa7:ce96:: with SMTP id y22mr664945edv.115.1628711111388; Wed, 11 Aug 2021 12:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628711111; cv=none; d=google.com; s=arc-20160816; b=GAj3KnDRJH0Ixd0P7qkTXNJ8RQP7CvvPx7QXDvi9FNZmelR6RY6RXHZlxESMr9OdR0 JW9ej071YayJysTCyj0fcdu1AcswV7wIO08EChyf6HXvAa708X3IdiJeYFb6wOHj2UUu Y1xvz27mMqg+eyxKGHHaiUtjQS1MfxWQ21CKfvxGAG9jHXWKUuA3E1nSfuaI9q/WhETQ PSYFly10bjcbQO0PrgthKz8FhehOwHw9E95/++081dYMO79tl5EQTZ3tlVV8ApWdSDPH ZbpOOfbk6J0COuOsjbcBIv2oM4kDHgSFnXRaGfAXD1eIdJta+Xw7rIdGCv/WwC1pIutI eGag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=8i+CelH4393wqbFZLjyubJ9cJaYTL/Q9iy7HD+iNO+k=; b=RkS58hFjXBuBK5AVzak/QOH4tnmP3FJqmLw4cBTi9TWbkWdU2g+ZJc9O4u5sJWNM2k YtR8AZ1PUTp7B45yo0thG00kxPpQiB43j1iUxQr2KaGZd6VBu1QgtpBDaOxfmjVwwC6f pyJ/xvXS32oSqgcLrfQfgJojkT+fR3WX0jVjAsiS1S90qeIUqIWex8oxDj5vCLk16PsC /vfPUUQdQUA2YmTwHY7mOY1bCULY+Jk6uMMVROFw7o2UJj2f0RSeJnql/uTcNzTDoGyK /lt2KrktgUSP+nalveSxOZ5lgR53vEnN3DA2+U7OZb//StiSXAg8YPAHnjg48nU9/hmF 4vrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yQVO3Pju; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8ZWbQK8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si326325edc.51.2021.08.11.12.44.48; Wed, 11 Aug 2021 12:45:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yQVO3Pju; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8ZWbQK8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231948AbhHKTmC (ORCPT + 99 others); Wed, 11 Aug 2021 15:42:02 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:53602 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbhHKTlu (ORCPT ); Wed, 11 Aug 2021 15:41:50 -0400 Date: Wed, 11 Aug 2021 19:41:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628710885; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8i+CelH4393wqbFZLjyubJ9cJaYTL/Q9iy7HD+iNO+k=; b=yQVO3Pjui5s2248vP2uajJYNfUydrid9C5ZfoZ4dvZFwdk6OIFMSjhv6lso/RgpGUlsel9 58xu6iP+PHPWhBfBxcZP5PJw98vjhA92LORoVXD4AuEAIrCuxv7iDf4ND9Y4eNB5+LiRoy QRufBAlNM4fGGe+6MSIafZOYTDwDNL6TcyUKnXrJ6+qstdjUKKI6M5yz7J73ZsnMYIuOA2 DTvJ5DVtxQGgh23jbyKSRHiAvou0dy59PPAQFsPqogW/QbB3z31xEwWOf7Oq8KGJ7Remzs F4Uodey7zKI7007rcnV0sDIH3EAvkl0SIp3UwVAcGIxI894cp1SefaFChBWuBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628710885; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8i+CelH4393wqbFZLjyubJ9cJaYTL/Q9iy7HD+iNO+k=; b=8ZWbQK8Ux+U8kvHfbHXUXMxd7EIT3/jwTdhuSVYbS4Lp2qiv741EzaKzI9jmIrH8yNMjKF R3piund26hsCqACw== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Make ctrlval arrays the same size Cc: James Morse , Borislav Petkov , Jamie Iles , Reinette Chatre , Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210728170637.25610-19-james.morse@arm.com> References: <20210728170637.25610-19-james.morse@arm.com> MIME-Version: 1.0 Message-ID: <162871088496.395.3274537078640668710.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cache branch of tip: Commit-ID: 141739aa73505539f315d15068b9c0707ab5ecb4 Gitweb: https://git.kernel.org/tip/141739aa73505539f315d15068b9c0707ab5ecb4 Author: James Morse AuthorDate: Wed, 28 Jul 2021 17:06:31 Committer: Borislav Petkov CommitterDate: Wed, 11 Aug 2021 17:58:33 +02:00 x86/resctrl: Make ctrlval arrays the same size The CODE and DATA resources report a num_closid that is half the actual size supported by the hardware. This behaviour is visible to user-space when CDP is enabled. The CODE and DATA resources have their own ctrlval arrays which are half the size of the underlying hardware because num_closid was already adjusted. One holds the odd configurations values, the other even. Before the CDP resources can be merged, the 'half the closids' behaviour needs to be implemented by schemata_list_create(), but this causes the ctrl_val[] array to be full sized. Remove the logic from the architecture specific rdt_get_cdp_config() setup, and add it to schemata_list_create(). Functions that walk all the configurations, such as domain_setup_ctrlval() and reset_all_ctrls(), take num_closid directly from struct rdt_hw_resource also have to halve num_closid as only the lower half of each array is in use. domain_setup_ctrlval() and reset_all_ctrls() both copy struct rdt_hw_resource's num_closid to a struct msr_param. Correct the value here. This is temporary as a subsequent patch will merge all three ctrl_val[] arrays such that when CDP is in use, the CODA/DATA layout in the array matches the hardware. reset_all_ctrls()'s loop over the whole of ctrl_val[] is not touched as this is harmless, and will be required as it is once the resources are merged. Signed-off-by: James Morse Signed-off-by: Borislav Petkov Reviewed-by: Jamie Iles Reviewed-by: Reinette Chatre Tested-by: Babu Moger Link: https://lkml.kernel.org/r/20210728170637.25610-19-james.morse@arm.com --- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 755118a..9f8be5e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -363,7 +363,7 @@ static void rdt_get_cdp_config(int level, int type) struct rdt_resource *r = &rdt_resources_all[type].r_resctrl; struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); - hw_res->num_closid = hw_res_l->num_closid / 2; + hw_res->num_closid = hw_res_l->num_closid; r->cache.cbm_len = r_l->cache.cbm_len; r->default_ctrl = r_l->default_ctrl; r->cache.shareable_bits = r_l->cache.shareable_bits; @@ -549,6 +549,14 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) m.low = 0; m.high = hw_res->num_closid; + + /* + * temporary: the array is full-size, but cat_wrmsr() still re-maps + * the index. + */ + if (hw_res->conf_type != CDP_NONE) + m.high /= 2; + hw_res->msr_update(d, &m, r); return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 61037b2..299af12 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2154,6 +2154,8 @@ static int schemata_list_create(void) s->res = r; s->conf_type = resctrl_to_arch_res(r)->conf_type; s->num_closid = resctrl_arch_get_num_closid(r); + if (resctrl_arch_get_cdp_enabled(r->rid)) + s->num_closid /= 2; ret = snprintf(s->name, sizeof(s->name), r->name); if (ret >= sizeof(s->name)) { @@ -2377,6 +2379,13 @@ static int reset_all_ctrls(struct rdt_resource *r) msr_param.high = hw_res->num_closid; /* + * temporary: the array is full-sized, but cat_wrmsr() still re-maps + * the index. + */ + if (hw_res->cdp_enabled) + msr_param.high /= 2; + + /* * Disable resource control for this resource by setting all * CBMs in all domains to the maximum mask value. Pick one CPU * from each domain to update the MSRs below.