Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp604451lqp; Thu, 21 Mar 2024 10:01:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5vyegzppXgOZhDsUO67zLCQS3/NujpTD09ByIB7vK5OpIhp66w1jgxv1HlGpb8kfWHZQPmE6EzdRudR33OD0L/6lHWWq7XX1xbxTvQw== X-Google-Smtp-Source: AGHT+IGhM96ktpRGaUPWfDc5G7yz6Sd7QOgUjrwWI7oSpxdFsNlWZeM6oIHIiR3pnt3BKYaIFN47 X-Received: by 2002:a05:620a:479e:b0:78a:78c:8920 with SMTP id dt30-20020a05620a479e00b0078a078c8920mr5178191qkb.61.1711040491570; Thu, 21 Mar 2024 10:01:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040491; cv=pass; d=google.com; s=arc-20160816; b=ZV68kEW8PSSIyKaNn9B2+IOwdHKw6oMHfSt4X16Rt7m/o6jvUndUyxJtIbmAYcw0Yn blk2cgl2zACio60za1yN/qz5RIUUnTGp3VEIb4DW3e4opYPtUK67mxYOmcntAAvohNRd lBMuZ6S8XSY+Otf7FgIgqcB/0B/JXC4wP8oYOND2NT7qpzvXSuX9UvCO8OMAgshlwNSy A6LV3znfepqvxeDpn/hLFH+9o1G0lhIEBRLz0vauhf6ptuz3QMRAGKfAgvc8z1m5+qyo JLOD+PYPWolTr2kVFjku3blt26R/1AnTtc9mZDVItofohr3dyTipISPhsWei5i3VvnQO iQ3g== 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=4C86tqrR6zCZYSHn1jHryD9nYGxlhK9fKKKglZuU8js=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=GtyiNp9iaYdpgZJy8BUuCYhbA2wHYi17Kqgiw714jDSPS9qSgNW/sh2xO6yfj+DzNs Dk52cOL7tmA7Qm9EKyLw1ISBsFs5DyX7NkG9o8H4CHAd6dZ5i40gHHe+nwGWOTVCJa64 I2NGx+yfk3+e2sx/kW7aRnMmUYUxKI3W94LDNhsduPSNN95jSSsI8mmZqnTjuCIeQs44 XzEE2CyHeeyXADkes+qHW+3S5QB7QMlE/nRQExjLNVyYZwOHhAEJnBsOjDn3EiRSsyGD k3GCYG1OaKzU5sgqZxsshAVTYLWYqqnICTStN/zQUU6YiZE8M+CCGyCV4uS6rWPXUoEF cI9w==; 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-110429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110429-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 vu27-20020a05620a561b00b0078a0d6a4ec6si102014qkn.685.2024.03.21.10.01.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:01:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110429-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-110429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110429-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 627041C2347D for ; Thu, 21 Mar 2024 17:01:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA3EE13B2A7; Thu, 21 Mar 2024 16:52:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7C3713AA57 for ; Thu, 21 Mar 2024 16:52:08 +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=1711039930; cv=none; b=D4R89x9CFIuooBOmrUed3wdNVxy3h7dmwEEUq2zV5kB9qw9sAqVG2Oa74XvQWo6h+dP7oWkebWat1Ve9RcvoLAVj9g2BT2t60Gi2hJBicgJbKhhLfgFbHWWoBZhmqHlLelTyJBw3IkjGadOJrzhFXKwVT6bhz7wolx6ksOVped8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039930; c=relaxed/simple; bh=qL+CEZKFNzM/T58NpznbtIj1E02zISZO6LxqIK6/ScA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OyH8owl4O9uJZvZ1zFlFwqV7EzsfUR12PhuJ/qwE56Z9y7BPFOSFIEygdXfxV0cyZK8aK3dq4IZt7e8XYefixvug27UaNSOF0JdqFK3AQZpmf4FCBOibcvCTcW9Qgtsg9DomkcL5AbRsgteQH99FcOT6poUThSmuRvMvn5fyrdM= 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 94CAB1688; Thu, 21 Mar 2024 09:52:42 -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 4FC1F3F67D; Thu, 21 Mar 2024 09:52:05 -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 12/31] x86/resctrl: Move max_{name,data}_width into resctrl code Date: Thu, 21 Mar 2024 16:50:47 +0000 Message-Id: <20240321165106.31602-13-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 max_name_width and max_data_width are used to pad the strings in the resctrl schemata file. This should be part of the fs code as it influences the user-space interface, but currently max_data_width is generated by the arch init code. max_name_width is already managed by schemata_list_add(). Move the variables and max_data_width's initialisation code to rdtgroup.c. There is no need for an extra rdt_init_padding() helper as the length of the name can be considered when schemata_list_add() creates each schema entry. Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/core.c | 22 ---------------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 9a09a64bbb7f..9551ca4a6480 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -44,12 +44,6 @@ static DEFINE_MUTEX(domain_list_lock); */ DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state); -/* - * Used to store the max resource name width and max resource data width - * to display the schemata in a tabular format - */ -int max_name_width, max_data_width; - /* * Global boolean for rdt_alloc which is true if any * resource allocation is enabled. @@ -648,20 +642,6 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } -/* - * Choose a width for the resource name and resource data based on the - * resource that has widest name and cbm. - */ -static __init void rdt_init_padding(void) -{ - struct rdt_resource *r; - - for_each_alloc_capable_rdt_resource(r) { - if (r->data_width > max_data_width) - max_data_width = r->data_width; - } -} - enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, @@ -959,8 +939,6 @@ static int __init resctrl_arch_late_init(void) if (!get_rdt_resources()) return -ENODEV; - rdt_init_padding(); - state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", resctrl_arch_online_cpu, diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 6cf4ebe9c058..e736e4d20f63 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -58,6 +58,12 @@ static struct kernfs_node *kn_mongrp; /* Kernel fs node for "mon_data" directory under root */ static struct kernfs_node *kn_mondata; +/* + * Used to store the max resource name width and max resource data width + * to display the schemata in a tabular format + */ +int max_name_width, max_data_width; + static struct seq_buf last_cmd_status; static char last_cmd_status_buf[512]; @@ -2595,6 +2601,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type if (cl > max_name_width) max_name_width = cl; + /* + * Choose a width for the resource data based on the resource that has + * widest name and cbm. + */ + max_data_width = max(max_data_width, r->data_width); + INIT_LIST_HEAD(&s->list); list_add(&s->list, &resctrl_schema_all); -- 2.39.2