Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp41343lqg; Fri, 26 Apr 2024 08:15:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWplRWDvpQWkktoB/9eDIbC3hEPEbaeLQY/oW/IB8xtzshejuiHpLhvT0JbObIf9jF4tacY9yr5PsGFThx5Vd/jOQSVbIucBIpkXNZ0Pg== X-Google-Smtp-Source: AGHT+IEb+66R7/XgJXSE2EIVhtBlpweGEuph1h5KhvqTfLAnqxeIyq64F6F4fiFFQuMLDTcMTX2q X-Received: by 2002:a05:6a00:1942:b0:6e7:48e3:7895 with SMTP id s2-20020a056a00194200b006e748e37895mr43123pfk.2.1714144548413; Fri, 26 Apr 2024 08:15:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714144548; cv=pass; d=google.com; s=arc-20160816; b=O1OqsOIuIjkOGOYWrFvKyIjv9VsC1CxEGtmcOkYNkkfHeKF2J1naNEgORKCjQoMpKZ 5fNvkzloPUqnHYejbqbvH0xEXeWyWDT8JQvS8brPLmE6XrVCsvEWqVX2MH7O6Y7XXUft bX3wzo109BxAXhuS7i+P4RM3/kA+kDWszyqvO19f4npNtciY38XgoJaCuMLDPI8j9x9a QTCNp7CvdwLC6gNXL2XzDF2n7mAK+3aMjTfW1Hsgkyobe08viJqJ2Vh9/273u2UU/Owy o+C1/ChdUhdXRnMlu8rtVAaIgvzPaMMoNqj4M8IA7jNBfFMDKIRSiowQMzLPO1f6OmDN 8OxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NhNgGQ8heAmUbjXaI60KE1+7qWKgdHeQM5YzuBFZvVI=; fh=Vo4MxA0u7CmSKYL/GjcyKHwusyvU+nKR43bqJem+vcY=; b=FqwYBFTF/zgTh+bGg47SKWQGd4YlIZZ9AIsggr3CnmiPdu5tenBte/jBVGNWfPve07 DSHhRzbRhDKX8XoxWGgAzBAxvlXK07d7sGP0BMeuUMKOU6Xau6oB5aSm4ZOInh44hPTR NgXg7yMv/PW2T7D5GK3pCTFNwF5bKOdzsPv7k7G6FqcUryqjo0K7QQaPj4sdF0JTXJ9b rDKGFWDaF/nCoW0KteERu28ByurUWE6uOBHd6Ssatt+Kabxt9YFlIf6zPUWxKa9sdzY6 cC5tgjH9Tsp/2sUMHlOc5Ws9mJJnAm/WeE1Y+/ICf39zEEUh8yXlNUiNRUxklSGbob7w LutQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-160242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m13-20020a63f60d000000b005dc85e8a9e1si15153754pgh.45.2024.04.26.08.15.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-160242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B78292822C2 for ; Fri, 26 Apr 2024 15:15:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E10E617108A; Fri, 26 Apr 2024 15:10:29 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07BC916FF5F for ; Fri, 26 Apr 2024 15:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144229; cv=none; b=YVvDuxxgdk4buAF+iStdCievCYCcqTShNSKZnNR+wD9mqh4vYHPAD6H7f2dYVKikFpucJ0i249LuGLGnuZUoIQ6QiW5qUf6TYpodsQam5co0Zhb1naIazVX/iSmsUkYrsFXc7e7pwNy3MvNhCSp3Z0EUODXTaRpw5tcjiiG62m8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144229; c=relaxed/simple; bh=fykdwzJzD98BfFk4Jek2Q2DE+vtzqHXdg4p4qfxfTtA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cCHrzTnX5hyzeHJ6tAk+WEeZdGN4scuaEKMMjfmUolbGffon0XHqJEmuJPVSoVSyjzD7qcn/x0rW0u6m+zruC3WjHxgc6bI2KM3bHWdvWJ+wbobNVjuKwzxVQOHeEnVz261HVRLdpFc66bp5t86DinZwGzhGwHALAWNj8I7Bi7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 A5B1F15DB; Fri, 26 Apr 2024 08:10:55 -0700 (PDT) Received: from e133380.cambridge.arm.com (e133380.arm.com [10.1.197.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 530713F73F; Fri, 26 Apr 2024 08:10:24 -0700 (PDT) From: Dave Martin To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: James Morse , Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, "Shaopeng Tan (Fujitsu)" , baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , Peter Newman , dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie Subject: [PATCH v2 24/35] x86/resctrl: Move get_config_index() to a header Date: Fri, 26 Apr 2024 16:08:53 +0100 Message-Id: <20240426150904.8854-24-Dave.Martin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240426150904.8854-1-Dave.Martin@arm.com> References: <20240426150537.8094-1-Dave.Martin@arm.com> <20240426150904.8854-1-Dave.Martin@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: James Morse get_config_index() is used by the architecture specific code to map a CLOSID+type pair to an index in the configuration arrays. MPAM needs to do this too to preserve the ABI to user-space, there is no reason to do it differently. Move the helper to a header file. Signed-off-by: James Morse Signed-off-by: Dave Martin --- Changes in v2: * Reindent resctrl_get_config_index() as per coding-style.rst rules. * Remove redundant parentheses from arithmetic in resctrl_get_config_index(), so as to match the original source version of this moved code. No functional change. --- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 +++---------------- include/linux/resctrl.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index 3603ade95f1d..b4627ae19291 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -277,19 +277,6 @@ static int parse_line(char *line, struct resctrl_schema *s, return -EINVAL; } -static u32 get_config_index(u32 closid, enum resctrl_conf_type type) -{ - switch (type) { - default: - case CDP_NONE: - return closid; - case CDP_CODE: - return closid * 2 + 1; - case CDP_DATA: - return closid * 2; - } -} - static bool apply_config(struct rdt_hw_domain *hw_dom, struct resctrl_staged_config *cfg, u32 idx, cpumask_var_t cpu_mask) @@ -311,7 +298,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, { struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - u32 idx = get_config_index(closid, t); + u32 idx = resctrl_get_config_index(closid, t); struct msr_param msr_param; if (!cpumask_test_cpu(smp_processor_id(), &d->cpu_mask)) @@ -351,7 +338,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) if (!cfg->have_new_ctrl) continue; - idx = get_config_index(closid, t); + idx = resctrl_get_config_index(closid, t); if (!apply_config(hw_dom, cfg, idx, cpu_mask)) continue; @@ -476,7 +463,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type) { struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - u32 idx = get_config_index(closid, type); + u32 idx = resctrl_get_config_index(closid, type); return hw_dom->ctrl_val[idx]; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 18ef7de0aa47..7bbed5d8a155 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -269,6 +269,21 @@ bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); void resctrl_arch_mon_event_config_write(void *info); void resctrl_arch_mon_event_config_read(void *info); +/* For use by arch code to remap resctrl's smaller CDP CLOSID range */ +static inline u32 resctrl_get_config_index(u32 closid, + enum resctrl_conf_type type) +{ + switch (type) { + default: + case CDP_NONE: + return closid; + case CDP_CODE: + return closid * 2 + 1; + case CDP_DATA: + return closid * 2; + } +} + /* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs. -- 2.34.1