Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp606933lqp; Thu, 21 Mar 2024 10:04:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGSNWq/FwY34g4lGyhn7uoT0CZPTiLz/jEwF/G2HC4OsoNKU2o2/zj7SRcuMAQ+iI6hIqcWuG1OAOVg3sNwyeKi2KOKbP1R/ZhOum+EA== X-Google-Smtp-Source: AGHT+IEHHonre7X4JuEWvJiVUShDj84WAE2hWQw81Ct5MMmW0Ts1zlS61CAoZWNyCuGC7+L4CjFQ X-Received: by 2002:a17:902:b70e:b0:1dd:de1a:bd02 with SMTP id d14-20020a170902b70e00b001ddde1abd02mr7967388pls.41.1711040655220; Thu, 21 Mar 2024 10:04:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040655; cv=pass; d=google.com; s=arc-20160816; b=DR0AViuEvNydbGjFi/jK1aJ1hSgMsZGe4t8cNwNwVDUl0LiiuwXlFQTJLNdrKYLUhP wgLFbgtAzyeUa7uSu6v+KCGU2msgsAhY5PGKkwGtvhnc2a3LPmTO9ZZ5/SNlAlpAD5zY i5IqTf1uyB9Ti5rY7cUcR4IblMNxm/h8Z9wiNRVTwT2Dgwremkxl2lJgOC06tB0lIWrh DVrDr5P562fh6gVPZriVC4/avRePfoxIjwT0vs3D5/dJ9+g6zADazWL6X8hTft4wJtvw Io99HSJzzrX0ZNLyN0FK2PjR/OEpYWvb/c5WI45pQB8NKanhGWZo7U5bBgRLT3t7h6KR vkrQ== 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=KTCbwSllRA19/zaku6J+xOhPO5pEaaAQ8D5/W9fCc0Y=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=vGzF/6ZAOScAB1A/VLyYEnJlvY9Uu2OnmTbqWUwwfJFKBZgNEKMrAiUW10OG50fYG2 eSY7noTWJBKJgJfZuYEsaLASLjLVDREQmy09RKDf+y11Wi78zG2WCKWjYwWVTC1juvrP Dhg4zwpa2slhobPNBURcEQh5Y4d9htKBMzkARvMO0DvwxXYLeYoMPV6z2hmAqb0QvWWP a77qZ/wYGPHrohdwmReFCuDKN2GDkkwKSghvTkJ2htTj/QQVgFrYNxfyIUuHUzllc6Rk 6MytdI7p1wpGwCVUSYdZrJpbx+ilD21D33jLdt+nhsj0yBo3ZWMfywgkfqwwLuVCB9mD PJ3A==; 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-110441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110441-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 z1-20020a170902d54100b001dede582a3dsi77019plf.480.2024.03.21.10.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110441-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-110441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110441-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 6B3922823EA for ; Thu, 21 Mar 2024 17:03:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF8FC1419B0; Thu, 21 Mar 2024 16:52:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBDCA14198A for ; Thu, 21 Mar 2024 16:52:47 +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=1711039969; cv=none; b=YS0EgKJnDQ77SLZtmwd/MAEiUn4AXKhcy69Bpqc39Wj5zIM0KZicoh1W+u51/OYhaIgyDjDUf4qTG+CPih8mBriVWG1tBS/MfmcXF4iqWCYSTCS7f3U2MPL3VatcElXCWVzGSL59vcMGiwZ+SC41d+aXvCPMpiQcBW4a3OZcZVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039969; c=relaxed/simple; bh=EHmCqdeWUD6WihUI6mjaYB9rK2M5Wu13mgqfMW/3Ui8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o1EvGzfNws4L8+EwldVGMY06D50RmvYA4UxwouEAqufKxrXEruG6uTj1yLrqXh7iLpsY/8OjQnalzuyopjHJYxfjQvcx+G5aUTGombnQ3tqML33l3rMNJKmfIWZ/FiMY0+QmOD82vTEtC+1yhXJIwWlZsUA1VqQDgzIV5vswWbM= 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 9EC5C1688; Thu, 21 Mar 2024 09:53:21 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5FECA3F67D; Thu, 21 Mar 2024 09:52:44 -0700 (PDT) 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, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie , Dave Martin Subject: [PATCH v1 24/31] x86/resctrl: Move get_config_index() to a header Date: Thu, 21 Mar 2024 16:50:59 +0000 Message-Id: <20240321165106.31602-25-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240321165106.31602-1-james.morse@arm.com> References: <20240321165106.31602-1-james.morse@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 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 --- 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 3de5bc63ace0..73c111963433 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -258,6 +258,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.39.2