Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp604203lqp; Thu, 21 Mar 2024 10:01:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9aE6nDW3fe6oPzLbZS9SUGSj7SWViEN5LxNmwxTDbyW+b+5q0F32Mk4f05vYzSB9HoHfXI4+/Ox8SCZGtWCoOl3VrUzUXAD6Ch8Axhw== X-Google-Smtp-Source: AGHT+IEdZWg3VR12hTSiKeBMPUXhQa56CdDjOos02duKZt495JuUqYnjXbtUBBxo4tBej1sd4JhM X-Received: by 2002:a19:2d05:0:b0:513:cc7e:9919 with SMTP id k5-20020a192d05000000b00513cc7e9919mr2337946lfj.7.1711040476713; Thu, 21 Mar 2024 10:01:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040476; cv=pass; d=google.com; s=arc-20160816; b=REBb39KLPDoFI8UvYNN/kavdNLMt0UWE911E7//0FQZubIIyj4afkt2ZnNeE7WDSa5 +mZJ4tlSFdLOZUA4QRDISM+JYC6xxYK/NtNkvtXYZTJewgYuFyXlaeaUl8dX8cta1mUe IzR1Zd5fraJT6sjGCOw1G+qFmSjwZAa10VLqbboOLhld11OfbmFOZ8kV8o68LWCY7+0o MnEQm8kYuL1tgkxG++TQMGTtxS3xmM+SDIJlH/9P0BBRxnxB3T/+KpHELHJOewUnX/IL trStgpKPDAajidhLAKp73lOsFS++8eSQHjlbEvyAqvgV4voGDd/r8OILeWt0sJAzCh8z 5JkA== 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=iX/xwmJ1ODXwxuxEXiq4654l9f3ESqEGwMhqqAImezU=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=K4eTnMYdv0yo+q2pdXHeIUnW//cIWGjP4VhApIK9OF2DkbWuJsloqX9M3x0RygtMbr 2eMIFDey08hbi0MfIhBT3H9E9FdFpRyvRRoKD2Ne9lviKl2fcw0ZlEin4n5cLyvxmEpF cRiIdsJzZxTotECJlZrpmyKE7TBHQeNjOmo16UHrRYd7w2IRIHXptKkn5UT9uhZJyxKQ +SPXxOJ6CV231bv7ZYHoCY9mGP5ZSiwx+DiDGzQLLMofKDUtLyE6y5KPFtfLz7r6Rh8G SOmyaH62nY3A9we8msuYWmvNUf7fF5UMDaLzTesl1SRBCHEKUYwVJajUzrD9SAl6GzPa lw5g==; 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-110428-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110428-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 w26-20020a170906131a00b00a46bbeeb91dsi89683ejb.386.2024.03.21.10.01.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110428-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-110428-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110428-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 606001F22DF0 for ; Thu, 21 Mar 2024 17:01:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A27C13B282; Thu, 21 Mar 2024 16:52:07 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 780A713AA57 for ; Thu, 21 Mar 2024 16:52:05 +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=1711039927; cv=none; b=jODTV0rgYdpKRYfwUYBGZnzHfK7u0veViExSut22sAeAub/g7HoLLvZOdePlSZ3jyOKED8kWD/aiZK1sN3l0TQWRW1eAziCvA+Bj8ZNafn3DCzcnWhj88iFwvlkh7c+xwwDh2+HqvzuQlmZeeyZpM7rh4F6SqQDvBZENd1/JvhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039927; c=relaxed/simple; bh=vqr+bVuNpDSSbUmXfd59bUzP2gdnvPTI51shrq+BsM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FhIeS0P1yw0nXMjgAGDM617ikSpT3Y8rL90Tn/ux1kES9ph2Qjce/ygMOLbHqFkDIlNvdy7xUIPr5wLUb++GTjXzKj8SesUraazc1yGIet3Agf84/jbLBpbkP8RIVA1YH85a09mQ/Ub7XectAaVF75CsIs62aK8c+fKJViJ/Rvo= 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 5755B1063; Thu, 21 Mar 2024 09:52:39 -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 17CFF3F67D; Thu, 21 Mar 2024 09:52:01 -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 11/31] x86/resctrl: Move monitor exit work to a restrl exit call Date: Thu, 21 Mar 2024 16:50:46 +0000 Message-Id: <20240321165106.31602-12-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_put_mon_l3_config() is called via the architecture's resctrl_arch_exit() call, and appears to free the rmid_ptrs[] and closid_num_dirty_rmid[] arrays. In reality this code is marked __exit, and is removed by the linker as resctl can't be built as a module. MPAM can make use of this code from its error interrupt handler, a later patch drops all the __init/__exit annotations. To separate the filesystem and architecture parts of resctrl, this free()ing work needs to be triggered by the filesystem, as these structures belong to the filesystem code. Rename rdt_put_mon_l3_config() resctrl_mon_resource_exit() and call it from resctrl_exit(). The kfree() is currently dependent on r->mon_capable. resctrl_mon_resource_init() takes no arguments, so resctrl_mon_resource_exit() shouldn't take any either. Add the check to dom_data_exit(), making it take the resource as an argument. This makes it more symmetrical with dom_data_init(). Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/core.c | 5 ----- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 12 ++++++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 ++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 06dc12b08afc..9a09a64bbb7f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -988,14 +988,9 @@ late_initcall(resctrl_arch_late_init); static void __exit resctrl_arch_exit(void) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; - cpuhp_remove_state(rdt_online); resctrl_exit(); - - if (r->mon_capable) - rdt_put_mon_l3_config(); } __exitcall(resctrl_arch_exit); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 7a0c74779c53..01fcd4ef26ca 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -533,7 +533,7 @@ void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); int rdt_get_mon_l3_config(struct rdt_resource *r); -void __exit rdt_put_mon_l3_config(void); +void __exit resctrl_mon_resource_exit(void); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 929ec1430b45..2a1cbd4de6ee 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -954,10 +954,12 @@ static int dom_data_init(struct rdt_resource *r) return err; } -static void __exit dom_data_exit(void) +static void __exit dom_data_exit(struct rdt_resource *r) { - mutex_lock(&rdtgroup_mutex); + if (!r->mon_capable) + return; + mutex_lock(&rdtgroup_mutex); if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { kfree(closid_num_dirty_rmid); closid_num_dirty_rmid = NULL; @@ -1074,9 +1076,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) return 0; } -void __exit rdt_put_mon_l3_config(void) +void __exit resctrl_mon_resource_exit(void) { - dom_data_exit(); + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); + + dom_data_exit(r); } void __init intel_rdt_mbm_apply_quirk(void) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 7a9696f53f2b..6cf4ebe9c058 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4186,4 +4186,6 @@ void __exit resctrl_exit(void) debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl"); + + resctrl_mon_resource_exit(); } -- 2.39.2