Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1464609pxf; Fri, 12 Mar 2021 10:04:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGUs+gjcSp2S/WKqIoxiGx/ySCLC5mb9DHml8/RgIfrjyv89nZxXvpwwM0lpNChNi66UtC X-Received: by 2002:aa7:dd49:: with SMTP id o9mr15568544edw.14.1615572274399; Fri, 12 Mar 2021 10:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615572274; cv=none; d=google.com; s=arc-20160816; b=NnbFbDczBO3f+91diBe2qD1YdFme8/PJZrL/w4vuBW8xNBxOF6EuvTTHF8qb/rtEg9 dBKrasO2ETaLESGXuKdXfbegi58cuMbFkQ9TQiqzYnW5zRyZE6OoJIIEZPVcWWFY2P/1 TE3juzWeLgt8oS3BRLkhQaTAZInkeEP61kPf3Up51cqL7b0qfISSyuiZmMSsjHLRX+vQ GpR5g2oBO0ejfrvQ9mT/5xD72JlzVl2oIrD8d/l3RRohu4EZPaugRgVIxrrBL5FhkOCv 1Bz26epm51L/eImv4wzCrwxJOBR8yoJLNb1ZlDnnsqGFWk52pbyvbiNN54yrDUEgJyaE uCUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YoTxtaY3WI8/oet6k3AdAiDEIIwHsNMdnXM8SGytkJI=; b=kPTlDF7l9Cs1RCpTMnqnmpCy+znV2uUZdmNjsiFVfCD4HR1UfAt0dqEvp8TTWFEz3Y jA/z9ZnFNLfs5eyDT3y9+9VZ83FbbVOUjMWTEn4loKRgX35dAOv1CHsy1yLM0S4e7p5t xlFeFN9u9eYRs5AfrAUzo3ALG5Qa9lbeXPnNxprH8Qp3fggWvE5kvUDSuaN67SRUxmlr eDXD3Jze9NSoerxAmJ4WlOfbpgn1XXLvnsQccCZ8gn0/lKZbkanDlgkQOIj5yg9hwI/t JHQ9ayPQucHl5QT//k7MCL7PmtQZfs0RyE5Jbbw7l1iagrNHOUKfOcG2dr83Sq8DcdDV +KwQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si4618352edw.190.2021.03.12.10.04.12; Fri, 12 Mar 2021 10:04:34 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233374AbhCLSBG (ORCPT + 99 others); Fri, 12 Mar 2021 13:01:06 -0500 Received: from foss.arm.com ([217.140.110.172]:58828 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbhCLSAf (ORCPT ); Fri, 12 Mar 2021 13:00:35 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D108C101E; Fri, 12 Mar 2021 10:00:34 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D7B53F7D7; Fri, 12 Mar 2021 10:00:32 -0800 (PST) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, Jamie Iles , D Scott Phillips OS Subject: [PATCH v2 21/24] x86/resctrl: Calculate the index from the configuration type Date: Fri, 12 Mar 2021 17:58:46 +0000 Message-Id: <20210312175849.8327-22-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312175849.8327-1-james.morse@arm.com> References: <20210312175849.8327-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org resctrl uses cbm_idx() to map a closid to an index in the configuration array. This is based on a multiplier and offset that are held in the resource. To merge the resources, the resctrl arch code needs to calculate the index from something else, as there will only be one resource. Decide based on the staged configuration type. This makes the static mult and offset parameters redundant. Reviewed-by: Jamie Iles Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/core.c | 12 ------------ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 17 +++++++++++------ include/linux/resctrl.h | 6 ------ 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index cb3186bc248b..8d5c1e9eefa1 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -69,8 +69,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 3, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 1, - .cbm_idx_offset = 0, }, .domains = domain_init(RDT_RESOURCE_L3), .parse_ctrlval = parse_cbm, @@ -89,8 +87,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 3, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 2, - .cbm_idx_offset = 0, }, .domains = domain_init(RDT_RESOURCE_L3DATA), .parse_ctrlval = parse_cbm, @@ -109,8 +105,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 3, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 2, - .cbm_idx_offset = 1, }, .domains = domain_init(RDT_RESOURCE_L3CODE), .parse_ctrlval = parse_cbm, @@ -129,8 +123,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 2, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 1, - .cbm_idx_offset = 0, }, .domains = domain_init(RDT_RESOURCE_L2), .parse_ctrlval = parse_cbm, @@ -149,8 +141,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 2, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 2, - .cbm_idx_offset = 0, }, .domains = domain_init(RDT_RESOURCE_L2DATA), .parse_ctrlval = parse_cbm, @@ -169,8 +159,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .cache_level = 2, .cache = { .min_cbm_bits = 1, - .cbm_idx_mult = 2, - .cbm_idx_offset = 1, }, .domains = domain_init(RDT_RESOURCE_L2CODE), .parse_ctrlval = parse_cbm, diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index 12a898d42689..50266b524222 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -246,12 +246,17 @@ static int parse_line(char *line, struct resctrl_schema *s, return -EINVAL; } -static unsigned int cbm_idx(struct rdt_resource *r, unsigned int closid) +static u32 get_config_index(u32 closid, enum resctrl_conf_type type) { - if (r->rid == RDT_RESOURCE_MBA) + switch (type) { + default: + case CDP_BOTH: return closid; - - return closid * r->cache.cbm_idx_mult + r->cache.cbm_idx_offset; + case CDP_CODE: + return (closid * 2) + 1; + case CDP_DATA: + return (closid * 2); + } } static bool apply_config(struct rdt_hw_domain *hw_dom, @@ -297,7 +302,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) if (!cfg->have_new_ctrl) continue; - idx = cbm_idx(r, closid); + idx = get_config_index(closid, t); if (!apply_config(hw_dom, cfg, idx, cpu_mask, mba_sc)) continue; @@ -430,7 +435,7 @@ void resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type, u32 *value) { struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - u32 idx = cbm_idx(r, closid); + u32 idx = get_config_index(closid, type); if (!is_mba_sc(r)) *value = hw_dom->ctrl_val[idx]; diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 250e96c073db..abe280f8a76b 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -68,10 +68,6 @@ struct rdt_domain { * struct resctrl_cache - Cache allocation related data * @cbm_len: Length of the cache bit mask * @min_cbm_bits: Minimum number of consecutive bits to be set - * @cbm_idx_mult: Multiplier of CBM index - * @cbm_idx_offset: Offset of CBM index. CBM index is computed by: - * closid * cbm_idx_multi + cbm_idx_offset - * in a cache bit mask * @shareable_bits: Bitmask of shareable resource with other * executing entities * @arch_has_sparse_bitmaps: True if a bitmap like f00f is valid. @@ -82,8 +78,6 @@ struct rdt_domain { struct resctrl_cache { unsigned int cbm_len; unsigned int min_cbm_bits; - unsigned int cbm_idx_mult; // TODO remove this - unsigned int cbm_idx_offset; // TODO remove this unsigned int shareable_bits; bool arch_has_sparse_bitmaps; bool arch_has_empty_bitmaps; -- 2.30.0