Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp876259lqs; Fri, 14 Jun 2024 08:08:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgNFiUrUYbfojxn4Ww7UprfBzHQIkFnHx9QsSRBLguc/S0iz+4K+MmFLEN9yjqLuKGAQIzHBqMJmxAzCuFHkzqWRkFtt1SRDntzbLC5A== X-Google-Smtp-Source: AGHT+IGajG5w7pTy5ayjgvhSD6wLCKPs50uMZIPeJQBbNJObEdO20q8/xC+Z9pC5UR1qKh6Qj9Fr X-Received: by 2002:aa7:8604:0:b0:704:2362:335b with SMTP id d2e1a72fcca58-705d71e3436mr2929945b3a.26.1718377692893; Fri, 14 Jun 2024 08:08:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718377692; cv=pass; d=google.com; s=arc-20160816; b=zunjM4hSu57VPPddmAKSKXS3KFtj/rBAvvKdQR+iZj8ArbDf/dKqlhWYcVFbhMJu7v N/M+8FNKcxVqhFFeV59Fc7w+GK6loYyrPP0GGNUakM2wncoa6bSnJILlmqQCB13dYa23 KysmWEg0w3BQNRMFB8G2AoEXJK3F63CwQ/E3Ow31u7BijCokCqjWJmSVQNP8xnR0ODIk eY6zmB0yWIg2x12YjkZ5VdLEdJn/rERJ+vq63olvYMt31op08rIImSpmc4LVPq9i2N9s c1cZZLlB3PiZloBY2FfrwVgkwXTVP1NeqvIK+TB+TaxCq/ozU4z+/P5CNSairAvIfFoK yvfA== 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=49DJQ2EofGLJY2yt6zQDNZOjIMtYBh/flsZul4Lv9NA=; fh=ZzIMw8TvFOndukyZ2OYtyPajIHhdrLW0CERhi5Mu63Y=; b=H2rA41fvjH4yGuj4qrCRPioCVInpAvYgbwc4ZG5T+a3kArmri5ecV45l7AU7WoUIz2 v+myC1sS7EubDB1/PcR61GW7seDGJiA5fGisYknch43Fn7YyyGMv5FyhE2Zo4149/3ye bFeovB2RgpxiWZfg+PKoQJDsUtuUU7vMcDRpew9mxtDi90vcw0NA7++ZKLR1BJZM+2Ep G3yDucB7MChYO+BZS+ZJfHvSYP6hkSV4Nu3eZEwh2LJ0WiUjk1iC9b4hUL8J9+XHnn2U sr6iKYUWgb+Aq5xkQclTRts2BZKdXOIAqhxe79vP0vPCDPjaS0FYqdz6vLC3DsmqOvI4 PWMw==; 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-215082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee453f1a2si3717406a12.576.2024.06.14.08.08.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-215082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215082-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5379928A44F for ; Fri, 14 Jun 2024 15:04:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDE3B19B3E6; Fri, 14 Jun 2024 15:02:04 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDB5619CCE8 for ; Fri, 14 Jun 2024 15:02: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=1718377324; cv=none; b=ly/Rwq7VoKXbpoZAPcYRMbBIQEyIaf1gJiW11j/Z/dq6bjTTJFNP+lTXeBPgDR0gVEm3fH4m7nlZxL5pl/zN9pn5CkcTCVkdakcKYQxKQrVLN5jKRWfri2Siza/mm9zQqh0z7CMmc+iBWbG4qhpqH1B/xjSjhhD2C4erp3qShzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377324; c=relaxed/simple; bh=dytUJvk3Im6Kg8NyEKhy6ybidwmIpB7gyhGKTch8tHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TificQDdbOyiohtP7yDHV+VKgMO3GShp9jdBvTLBB1LiwPZfU90nkSr3/bnaztRI1PP9qFtbST20PkHT6wehx7mcYTf+pxH/jYwDZDp/GEo2xJVnRPZw+cNF/dyylFAfwbBle8vJs88R2wdu9YwiC7DhvAWdyWz2pcnlYRmH61A= 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 CC872176A; Fri, 14 Jun 2024 08:02:26 -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 1258B3F5A1; Fri, 14 Jun 2024 08:01: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 , Shaopeng Tan Subject: [PATCH v3 16/38] x86/resctrl: Move monitor init work to a resctrl init call Date: Fri, 14 Jun 2024 15:00:11 +0000 Message-Id: <20240614150033.10454-17-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 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 Tested-by: Peter Newman Tested-by: Shaopeng Tan --- Changes since v2: * Added error handling for the case sysfs files can't be created. --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 24 +++++++++++++++++------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 ++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 9aa7f587484c..eaf458967fa1 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -542,6 +542,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 7d6aebce75c1..527c0e9d7b2e 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1016,12 +1016,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; @@ -1049,10 +1065,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; @@ -1070,8 +1082,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 8c380f389b93..9c03e973a5f6 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4168,9 +4168,15 @@ 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) + if (ret) { + resctrl_mon_resource_exit(); return ret; + } ret = register_filesystem(&rdt_fs_type); if (ret) @@ -4203,6 +4209,7 @@ int __init resctrl_init(void) cleanup_mountpoint: sysfs_remove_mount_point(fs_kobj, "resctrl"); + resctrl_mon_resource_exit(); return ret; } -- 2.39.2