Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp850006lqc; Fri, 8 Mar 2024 13:39:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsrLMO/6yEu3sQYvHcLEj9+pKq9gLzvLCN/1jPrd7bBqDr8c/H+i3F7jlRoJGar2eH3EOxisgjVEG9w6sUhm4ReEBzks480fxIke17Tw== X-Google-Smtp-Source: AGHT+IF5iiiF9ItxiEMSDAvK+At1rVmhD0xZLq8m3/rg2Fuwr+stftYPl8YTi/uSlZGS2MTnar+g X-Received: by 2002:a05:620a:2a02:b0:788:42fc:2f75 with SMTP id o2-20020a05620a2a0200b0078842fc2f75mr2660230qkp.30.1709933959347; Fri, 08 Mar 2024 13:39:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709933959; cv=pass; d=google.com; s=arc-20160816; b=XgFSODJbF4Mt3Ll31kZFD3bzHdnN40uOHtEIX0cZ67cVJ6W2kU0bNxfTIs6ncfiNmt 2vFmZxShgK5dpICTXGez7EMNKH3I+yebgADMCMy1+eNIadW3ooUrB//kNKMBD8KnRZsn G2PFi+tVBnaQW/l62anJLwDegPJjiz4Mj4fu22ha7ttImhDRTeUWk3wLz8TRR8PUsFVI KNznB9pZt1b2XJ/yKbQ9H+DOaYxw1RlItVozkxODYSFVZpTUakRtR8IeOK5QKke+8Otv EorYDrCxuYpmHsgIWXm57Pnm+toSGucE/vBOSnVaxcVK3GRx2nhH1S3JbDfONiNfOsZS 5CXw== 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:dkim-signature; bh=oTiaxBXt83zwVnxf3/siGgqXLzsKjvXLeF6d2/6Cs3Q=; fh=8DIsJ7WfrHWraKHUTDArLU4WNr9GUc66G7UiO4UXZF4=; b=Atqda2tjk36IfEUpH9YkZk97719RPfs1TJuyYTRXDeZrhGg2kR5Kku51kT7VJJPZP0 uXWtrfmYmxYxFDktaQTW2rUbGEtX+j5v+pjPhGt5eEWm36HUc/tJLq8aArlNk8mihFln UQeVcaDh/BmL6hY/+ZWx7J9B8Aj5zX/c99/r3dDkod0N2+dXJgQNlDgHlBpyVdraIgcY kadT6qscYkXorh5UWkUVoZj9N3ua6y9r6epMKQDFzd/NwTqaOEgU8HYN89lZz6wbE2Mj ulf398+amVbjPNZJH/72O/Gms+xj2Bcx/CfDhtaOyjeuWSYPUHhbc2H8Zr8yMCRwFpuP d97A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UJ/IzyeA"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-97612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u5-20020a05620a022500b007883f9d5c91si331043qkm.286.2024.03.08.13.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 13:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UJ/IzyeA"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-97612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0853A1C217D5 for ; Fri, 8 Mar 2024 21:39:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5CAB5FEED; Fri, 8 Mar 2024 21:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UJ/IzyeA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2F765F578 for ; Fri, 8 Mar 2024 21:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709933941; cv=none; b=I37vZCt8IpVVaDvxexYw77uteJHUwFK59WaKM1oqIpqjVDfyZ61jvVZqSt7JloXuIrsHFPWum1LxBQ2JoBrrKY0q0KWk4G4Sjebpnpd4EoA8Aywn9Z9gJlX1Lo2SBxo/pKFV52OyfcHPDEgT0VEiwp9XyL8cn9bqNXwgFrUNjU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709933941; c=relaxed/simple; bh=5+syQIWZZ3Wnr9rjayrBOZvvjhoz7t4wc/c7M6jQ40Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ARWI2g6KRKG9JfCufViXQcl0ztpKTyYIUJG2Vnuy0nTYO4jTEzP8r2dW5XmgQTzhXseqYkkME3zB7EvNKpY2hdesDxq2p2bGhJmSFkxK6Ke/H8j3x/VrlGuCDXMoMwecKIX4WoaP6X6dgFTfHCQIAcPTGwkDwtFLb9aAhQzLig8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UJ/IzyeA; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709933940; x=1741469940; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5+syQIWZZ3Wnr9rjayrBOZvvjhoz7t4wc/c7M6jQ40Y=; b=UJ/IzyeARVxl1ef27ivgjE2cc3x1g7zLeuFYqUZZLxmhhkR4r6yUKJD8 H46hHFABb410uCdtvp+URq/tXPJgH2QbvZTfYf8Xup2I16HE21H4mID6I at9Q5pi/wc9iBbUO6YmlwbXrMYpONO9hgUvpgVNGJawsLlUsw/uJiMBlb cg4tHNMynE+QFeO3IU7JL0j6XLy2rQ7U0v/QdCxX7m4ljw2aO9VgC/z+0 QMhTnUBwdRNyD2xzTz3YqPxSrgu4CAgkOMpezHSj+8/pb+jsxFwXUPwO5 ShH1ZKNNmMZkdTDHDPNLLr/SEoDjqWrkbM3T5dzcUAr1s7UKZQj5Apxkj A==; X-IronPort-AV: E=McAfee;i="6600,9927,11007"; a="4811416" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4811416" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 13:38:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="15295091" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 13:38:57 -0800 From: Tony Luck To: "Chatre, Reinette" , Borislav Petkov , James Morse Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, "Yu, Fenghua" , Ingo Molnar , 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, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Tony Luck , Maciej Wieczor-Retman Subject: [PATCH v5 2/2] x86/resctrl: Simplify call convention for MSR update functions Date: Fri, 8 Mar 2024 13:38:46 -0800 Message-ID: <20240308213846.77075-3-tony.luck@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308213846.77075-1-tony.luck@intel.com> References: <20240308213846.77075-1-tony.luck@intel.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 The per-resource MSR update functions cat_wrmsr(), mba_wrmsr_intel(), and mba_wrmsr_amd() all take three arguments: (struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r) struct msr_param contains pointers to both struct rdt_resource and struct rdt_domain, thus only struct msr_param is necessary. Pass struct msr_param as a single parameter. Clean up formatting and fix some fir tree declaration ordering. No functional change. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Tested-by: Maciej Wieczor-Retman Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/internal.h | 3 +- arch/x86/kernel/cpu/resctrl/core.c | 40 +++++++++-------------- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index bc999471f072..8f40fb35db78 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -444,8 +444,7 @@ struct rdt_hw_resource { struct rdt_resource r_resctrl; u32 num_closid; unsigned int msr_base; - void (*msr_update) (struct rdt_domain *d, struct msr_param *m, - struct rdt_resource *r); + void (*msr_update)(struct msr_param *m); unsigned int mon_scale; unsigned int mbm_width; unsigned int mbm_cfg_mask; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index acf52aa185e0..7751eea19fd2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -56,14 +56,9 @@ int max_name_width, max_data_width; */ bool rdt_alloc_capable; -static void -mba_wrmsr_intel(struct rdt_domain *d, struct msr_param *m, - struct rdt_resource *r); -static void -cat_wrmsr(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r); -static void -mba_wrmsr_amd(struct rdt_domain *d, struct msr_param *m, - struct rdt_resource *r); +static void mba_wrmsr_intel(struct msr_param *m); +static void cat_wrmsr(struct msr_param *m); +static void mba_wrmsr_amd(struct msr_param *m); #define domain_init(id) LIST_HEAD_INIT(rdt_resources_all[id].r_resctrl.domains) @@ -309,12 +304,11 @@ static void rdt_get_cdp_l2_config(void) rdt_get_cdp_config(RDT_RESOURCE_L2); } -static void -mba_wrmsr_amd(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r) +static void mba_wrmsr_amd(struct msr_param *m) { + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); + struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom); unsigned int i; - struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); for (i = m->low; i < m->high; i++) wrmsrl(hw_res->msr_base + i, hw_dom->ctrl_val[i]); @@ -334,25 +328,22 @@ static u32 delay_bw_map(unsigned long bw, struct rdt_resource *r) return r->default_ctrl; } -static void -mba_wrmsr_intel(struct rdt_domain *d, struct msr_param *m, - struct rdt_resource *r) +static void mba_wrmsr_intel(struct msr_param *m) { + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); + struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom); unsigned int i; - struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); /* Write the delay values for mba. */ for (i = m->low; i < m->high; i++) - wrmsrl(hw_res->msr_base + i, delay_bw_map(hw_dom->ctrl_val[i], r)); + wrmsrl(hw_res->msr_base + i, delay_bw_map(hw_dom->ctrl_val[i], m->res)); } -static void -cat_wrmsr(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r) +static void cat_wrmsr(struct msr_param *m) { + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); + struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom); unsigned int i; - struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); - struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); for (i = m->low; i < m->high; i++) wrmsrl(hw_res->msr_base + i, hw_dom->ctrl_val[i]); @@ -384,7 +375,7 @@ void rdt_ctrl_update(void *arg) struct msr_param *m = arg; hw_res = resctrl_to_arch_res(m->res); - hw_res->msr_update(m->dom, m, m->res); + hw_res->msr_update(m); } /* @@ -457,10 +448,11 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) hw_dom->ctrl_val = dc; setup_default_ctrlval(r, dc); + m.res = r; m.dom = d; m.low = 0; m.high = hw_res->num_closid; - hw_res->msr_update(d, &m, r); + hw_res->msr_update(&m); return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index 165d8d453c04..b7291f60399c 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -289,7 +289,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, msr_param.dom = d; msr_param.low = idx; msr_param.high = idx + 1; - hw_res->msr_update(d, &msr_param, r); + hw_res->msr_update(&msr_param); return 0; } -- 2.43.0