Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp45849lqg; Fri, 26 Apr 2024 08:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbVFib0WsM2yBk9pEE89TbAF3kJR0pIfYnVDWmFGTSzDzxY2jrzfDy72puFhBFP8cd7mccYeVeHR0jFqQLTDDh5xDm07n9lzJ9jY2Wlg== X-Google-Smtp-Source: AGHT+IHhLj+k3rsI9OhjUk/5KsWtY3p3AMWIyqipiUXpYPylqLcj+tqxiNQoRlYfNbu8TCVZEH/E X-Received: by 2002:aa7:cb8c:0:b0:572:637b:c7e1 with SMTP id r12-20020aa7cb8c000000b00572637bc7e1mr567740edt.21.1714144911713; Fri, 26 Apr 2024 08:21:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714144911; cv=pass; d=google.com; s=arc-20160816; b=BrqrXKsxaFGVcGgDx1uIZOa7ucV+ohIi4FkJvptUpO3lBaSrt8lfgL0UhWs9o6Q84f 336PxJUi2X9a16putHAiSX0GtktajBShfcK+diUVe5YYumHujaz67+dcJGyeHkQL7hrH PNbPfqgBqSNxUnZUjgjYIOCO9Eb7lUp84R0Az+W7ifpSUWTlZFgCHt7Afky9C0FzVd1k jxzMKaRoO+rw84VOf1vZYkzCsLxCiuBgYW3UbpZ+JNtn1wyP8DT08/SdZo0FakydTyXm vciHmPzZGnk4wQHhD5nkG06h8Fq8PS43ufqoY+pJ2vHWaQR+YGfNn97MTFrTKS8bfcxD YqyA== 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=/aWj7ZBQaDzvfLcK8XmALXA5gE8tPJ6XUI2dWBy95X4=; fh=Vo4MxA0u7CmSKYL/GjcyKHwusyvU+nKR43bqJem+vcY=; b=q9UjcrQClJ15Ib6Tmnu3bNu4YzRAz1qzzM2uoaYKw7jYa9kyuop5D/p+96QscaTmPY VgSgikv7Fex5ohLeB3/6sAq5GnIvftRURskrrE3wzvnLQmh2DguLjIk0isOtNF/HjZNF 5mfKDjLVHxlUgmBgJexjoUSuyL/b6VN0afAOHkUisdibbp7JJbpFGakN/TG0WAjKcgiF warVHLs7V52o6H5p79rMBfcK5cLk8hQo3LvVVOVJe7vSFXaA4f+PR8+XXrj/Frv1cCRO zChjSSUjfrBQF7ZMnA1bn3aJFj4OJ2usMkppa6rbQAFGWuJo+zbQYoGqWvRjK0QGY0wk xZNw==; 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-160228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f16-20020a50d550000000b00572040d55c4si4746657edj.609.2024.04.26.08.21.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-160228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160228-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AE2B21F2672D for ; Fri, 26 Apr 2024 15:11:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 940CC158DA6; Fri, 26 Apr 2024 15:09:51 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A84F7158D94 for ; Fri, 26 Apr 2024 15:09:49 +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=1714144191; cv=none; b=WytcL2+k0i3e5fwfjdvyf1TfbcwEeA+8bhdfAu1RNv037zROImyA4AuqFBINrESUCnHRyek4foJSAdKt+is6yeOlYf4D87zBhloqR/DGk65cPolXyVV2Tgi6dp9GASvA4aDG/vExchrfjStSwdPN4aFsRoYwfSaW5mMvMYnnwKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144191; c=relaxed/simple; bh=y3SHjI1WPJKaVkLA0EeIeM+HCs2Us0QAiObxG2+dupI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qKXJeQNdHi2SUhe0+CJPtJz4N11KlpjY1moJOBbBxQ+yASu/WvUmtNqvg8L8jcvau/qxJhEsl7rdgU21BAXRy2yYH/M2EOVHeePtPTnUFcSV5d2eD03YVygkUqFp9DOnkIaiLoNTelxohROzSUAvCe8989gnJCYs4dZ2qxLQWeo= 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 18BD015DB; Fri, 26 Apr 2024 08:10:17 -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 216EA3F73F; Fri, 26 Apr 2024 08:09:46 -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 12/35] x86/resctrl: Move max_{name,data}_width into resctrl code Date: Fri, 26 Apr 2024 16:08:41 +0100 Message-Id: <20240426150904.8854-12-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 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 Signed-off-by: Dave Martin --- Changes in v2: * Up-case "CBM" in the comment retained from rdt_init_padding(), for consistency with usage in comments elsewhere in the resctrl code. No functional change. --- 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 58b59b102986..9d4c8d641615 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]; @@ -2593,6 +2599,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.34.1