Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp603983lqp; Thu, 21 Mar 2024 10:01:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJtQRHKoZhO1EAGmVH9nS8WjJ9Rx4F5stTbmD+ak6FZeFDYrfR/4DpX2HezEsLL/8qnUGxtsmzDz3PeGxUMeduQxJvmmLtLGZBE219mw== X-Google-Smtp-Source: AGHT+IGo65oJ4zln/qHf3SNL2mMvKOExPD06sfRz4gwWSCbI6Y6YWadSix8ElOskEQ2yeWpyiHMy X-Received: by 2002:a05:6808:2202:b0:3c2:266e:4e38 with SMTP id bd2-20020a056808220200b003c2266e4e38mr11226758oib.25.1711040463647; Thu, 21 Mar 2024 10:01:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040463; cv=pass; d=google.com; s=arc-20160816; b=UiSUwifNVCwlj0JUnn79tkgAjfmLyS7ou5e91tRtIGz9EBlDsccuqI8eph9OyiBgJs jYE51wIyUslzJtoq6wAwOIEPS6MsMH7m6qlhrW+7Sncp/cendbcb7YWEuAqhvTCg2kOX mgEFYu2I99tsHVI7l+JFMweAfV3bnujGvdcMg1PTtAoMNbMhLOt7KZj+TKivreOrCc77 nwwL+U7JhaK5a79K/V2t55VFhcD0Pxq0CEQoYqtuMJQQZ9JOu+O66BRe1Gcu0a2VUdLw PpI6TatnoPZXfK8ftTYDh+a3S3YRCAIMGwOlslgTwcCE+I+tCEPRCZa7sjZ23INtsgTn 2udA== 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=V7C9nslmzKuDpxVTbkqC3wq+Yes5idV+PoYmS/qb5qg=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=g8JTGdwsZjqeaA3fcCYBLsZKFLRFRF4PD96uYS6JxxCWQdO7zhOTAZIRYpsVi+HQXg ka6ZFJY6Y4u9Gade2CQnDbzyFTiQg3OBKLGGWl0gj7fMuQu4hGjjgNi4QU/SijRdJ9dK iCRkYlXYDFhEpcWHm/+oqAm+M6eLaQ5KgPs/i9xN8ZNukhSbDWw4o+7GFRQP/aptUmfk JSfb0SDNAbhY/1KwJgL6QZOZkb4aXtvNhp0H7HkM5/Xr/mHwS3GMG+uYbhD7oc/BZNso rDKgKTG0XjSM4+BSQTBpC69D+gS7lS0Rtdi2ENrL/B5ejfNOuoOkssdeH5rSGzuFU03H +E9A==; 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-110427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110427-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 t23-20020a05622a181700b0042ea9d4f6cbsi108208qtc.527.2024.03.21.10.01.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110427-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-110427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110427-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 56A7B1C21EBD for ; Thu, 21 Mar 2024 17:01:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 607B513AA40; Thu, 21 Mar 2024 16:52:04 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6908113A871 for ; Thu, 21 Mar 2024 16:52:02 +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=1711039923; cv=none; b=g+SxNHmNJCpWDMDIpUufmqpeQ7FQlT8JoSMlS1axLrMOKqlCv1CzGSOGiPFNhK4AjjTlO7p8OIwoOuh3HfhrdvRdQMzhM4M72Nw8F3ufBy5WbOXhd4dTEKHaZUC/avhBeAj+2Vqf541z/XEcjewJEPbvHSIalscU9lfRZfcFvB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039923; c=relaxed/simple; bh=6l0woSci/M9LuyNXUr+GtqcEVurpBvAOSknwrS4QAIQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UV87nsivUyr7/HmXNvHNtQ6wjeu+Ma9ZXDmBWwfQfy/QajeXkbH7lbJQ/qhX/hpgVgILdD0Fj7iJd2DeIGXyqaFdgWf+vic51AEWZaa9Jpcn5XI7MkKi4PD+bPXmgfqx12ggrqFogzeJfU81aq9DTImYUQVtTNIvbp3GB/WGK3Q= 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 1EB281007; Thu, 21 Mar 2024 09:52:36 -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 D46373F67D; Thu, 21 Mar 2024 09:51:58 -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 10/31] x86/resctrl: Move monitor init work to a resctrl init call Date: Thu, 21 Mar 2024 16:50:45 +0000 Message-Id: <20240321165106.31602-11-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 rdt_get_mon_l3_config() is called from the architecture's resctrl_arch_late_init(), and initialises both architecture specific fields, such as hw_res->mon_scale and resctrl filesystem fields by calling dom_data_init(). To separate the filesystem and architecture parts of resctrl, this function needs splitting up. Add resctrl_mon_resource_init() to do the filesystem specific work, and call it from resctrl_init(). This runs later, but is still before the filesystem is mounted and the rmid_ptrs[] array can be used. Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 24 +++++++++++++++++------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 031948322eab..7a0c74779c53 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -540,6 +540,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg); void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_domain *d, struct rdtgroup *rdtgrp, int evtid, int first); +int resctrl_mon_resource_init(void); void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms, int exclude_cpu); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 06565153ceb2..929ec1430b45 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1003,12 +1003,28 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_local_event.list, &r->evt_list); } +int resctrl_mon_resource_init(void) +{ + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); + int ret; + + if (!r->mon_capable) + return 0; + + ret = dom_data_init(r); + if (ret) + return ret; + + l3_mon_evt_init(r); + + return 0; +} + int __init rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); unsigned int threshold; - int ret; resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size * 1024; hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale; @@ -1036,10 +1052,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) */ resctrl_rmid_realloc_threshold = resctrl_arch_round_mon_val(threshold); - ret = dom_data_init(r); - if (ret) - return ret; - if (rdt_cpu_has(X86_FEATURE_BMEC)) { u32 eax, ebx, ecx, edx; @@ -1057,8 +1069,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) } } - l3_mon_evt_init(r); - r->mon_capable = true; return 0; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 13c24cb18d76..7a9696f53f2b 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4138,6 +4138,10 @@ int __init resctrl_init(void) rdtgroup_setup_default(); + ret = resctrl_mon_resource_init(); + if (ret) + return ret; + ret = sysfs_create_mount_point(fs_kobj, "resctrl"); if (ret) return ret; -- 2.39.2