Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp892999lqs; Fri, 14 Jun 2024 08:32:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8FPKEt8JAJV674EsJcS9XLhTMbKvJVjUA8AjeFmQm5ho5g8oP1QoReL5Mto9zqWjxUGlkHes6MlWRC203BcPV1fev42wrnOobsl4vWA== X-Google-Smtp-Source: AGHT+IHWHeZ9agSkW+7/slVjKmXvKGb6NKeoPUYtZ+tLbfTnZvUVOZ02FePM4nP1RSaj2o9llnsc X-Received: by 2002:aa7:998e:0:b0:704:331c:cfb6 with SMTP id d2e1a72fcca58-705d7105216mr2808611b3a.14.1718379167614; Fri, 14 Jun 2024 08:32:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718379167; cv=pass; d=google.com; s=arc-20160816; b=DpIVFcWvsY+BOBFGNYkFELCysvgHQEgodb5eef8u4hkt3M2IWF0xsDoJcYJKFzNEt2 xZdthZ0H66zh43fpyM/E7qreKBasq/JNv3vi9dTd1cz49uA5l03m1jcQ0Ioc/kpAID1C XSc6jaj06bQA2s3dADsSM2BdNkgiZxFIrNdLambWeNvyGfKQh4w5iNpfkWbZvBXlLTG4 bWJa3+SbMdG30eybAWCMZlXQzBL61DLHho2vetOD9kcF09J/8qM8u+G+MW4A1wRb4TPY WsOQMTzus3ZAV/mpK9gPlsH9Re0HLD/ZvTkqVPNC1wJU9GqeWpI+qrAq8ML1pcIqu7Ol V69w== 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=GJ4RoqIlMGgsMSseFgWUPeGWDuBIaR8lCKRSuryZEUw=; fh=AQRRtkmHyvZI0LQ5UvExX7X5tmBE1F1lr2MH+s0Lwao=; b=RxV9hpi9oS2uYH0zzJLLMOF29XTeB5Jqb3SYpVzOvb8V3ycQrbHo90vyyJ1QI4o1x7 nHOwhIgz3HD6fkeViO1XX/AJp6B5h6l3v/ubzGU+WHXoCxjk+dnKFQ0IIr2kKXVa5f+8 aG/rBI8CWtXc1Y0o6dL8kytZZXv7UJKGqWZXCh/jO6vKfqBTZzHXOaJE4OrXhlOtKcxi +wmWqnrpdqymlHQAPf8uHvWvwCea4B0iipClyXUvrvrE6rbsD58uRfS2IqNITv5v8uAU qdPKokdTSgUqqfdt1at01NO7VbJ44h6SA3PnDxTz6OzBO5kwcr5gd3MQV2fukhE6Kv5h RINw==; 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-215094-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fede81ff69si1047312a12.246.2024.06.14.08.32.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215094-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-215094-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215094-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 71116B28FC6 for ; Fri, 14 Jun 2024 15:07:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAE6B1AC249; Fri, 14 Jun 2024 15:02:41 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E55FC1AC22D for ; Fri, 14 Jun 2024 15:02:39 +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=1718377361; cv=none; b=sEXWwVvjTEXRRsXVwTs9devvEOdQeXS/fSpcjq/Uxu7vxewS1n21CZ7BM9dR6IKp+WFHoyZbquttzY09h3iD/9Fl8rMyxaF3Glu5qypMxPmO2K/EkMT+BQnUdUwB+Ie7TNlz4oMp4pH9Q4N6RzlWE9S/Pzb4pmV8ocjho+atFd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377361; c=relaxed/simple; bh=22tF9u9zn9sPAGrVeRI8EEeXemVt5Q9eKCLU8INeeVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uke7mydte/ZskgRNpvcwnO8R5bEakKBwXxCudoLXX1oUrs0ZgmUDxfJQLGbE7pBMtbbHQ3boFpP2Se1g4vm2RFI4FS67hw+esjG7BlTCLLYNVD2LE2+ocoA5XFcIx/ZvCcIhFnFJdU6Ntw4nYZuEqIgFpuWZrdX9HubOXuRQAEI= 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 EDE5F1BB2; Fri, 14 Jun 2024 08:03:03 -0700 (PDT) Received: from merodach.members.linode.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D2A43F5A1; Fri, 14 Jun 2024 08:02:36 -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 , Dave Martin , Shaopeng Tan Subject: [PATCH v3 27/38] x86/resctrl: Move get_config_index() to a header Date: Fri, 14 Jun 2024 15:00:22 +0000 Message-Id: <20240614150033.10454-28-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240614150033.10454-1-james.morse@arm.com> References: <20240614150033.10454-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. Co-developed-by: Dave Martin Signed-off-by: Dave Martin Signed-off-by: James Morse Tested-by: Peter Newman Tested-by: Shaopeng Tan --- Changes since v1: * 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 2100560dda6a..130583035d27 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -283,25 +283,12 @@ 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; - } -} - int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type t, u32 cfg_val) { 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)) @@ -338,7 +325,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 (cfg->new_ctrl == hw_dom->ctrl_val[idx]) continue; hw_dom->ctrl_val[idx] = cfg->new_ctrl; @@ -458,7 +445,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 0359746d45f5..e07d719ace33 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -315,6 +315,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