Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp889792lqs; Fri, 14 Jun 2024 08:27:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUffqqNJt01AaKEWY8IyVX2ccXf7dzHrezCImQecGSogW+h7aOAKTY38JJ6gG9n9RaHACZnA4VC8Azv6J/gbYWpsZFDXG6tuB4t/uXgMw== X-Google-Smtp-Source: AGHT+IEZTUrWVgR1wz7u5oro7qeUEwlx3txJszj9XPDObdZw58aF+N0bI7f2Uh3mcK+Hzg3X+fq4 X-Received: by 2002:a05:6a00:1d19:b0:704:12fc:7b30 with SMTP id d2e1a72fcca58-705d716e49bmr3704261b3a.17.1718378874386; Fri, 14 Jun 2024 08:27:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718378874; cv=pass; d=google.com; s=arc-20160816; b=UkIiN+NolPKe7nN/Mr8KPPHeqXTxF1Zi7ANOMSDxzcdzk9tSDpOnPVywfox6yoC11S H72cHlAOujGSq8imA+RMefB3A5ixd2iR57nUAKQtmIbW+QqqVmkfC46ggVyYGt63pIyx KvpAFibxlG4JzjneGivDcrUz2IG6hd/otS1/nyEA2EmeJNgwCiJRIpcJWTfL3gVJRRW/ KwXREWfFObXZsdBQxojxgEz4K+kOBhJRVpATjaYXFxRw5Z0HM891CqwOvvYWqDGu3kig FV9HOQf/8xan5ZUFzlHR+I5X3uCnC8Kwm2Hl0il0ZlXramXgT4dIQXzLuUsN4Cc4sreX sblg== 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=QvDVyeemjIxGe2RMaVvtumVJISgrbqlnkH6R9d7fPl8=; fh=ZzIMw8TvFOndukyZ2OYtyPajIHhdrLW0CERhi5Mu63Y=; b=Teh9o/HDQWGhNCfDzUkAgHbReCgGKf58OCqkUxaEKsVebbjkeh0kiqubcHiGmzLYIA OJDJ0b/dSMUw0dweE7+MYVlohzGU8Y9iH7eF2JK/vzBpsMYtjsKLIdhMl4AaMcW+Xr0q ncjHbNn3u6JfR2SkQ2fmWA4t7jOODfeKfc6tsjJcQ0QXdpbaXRU/LMyTy3HXYVbAzCDO /qcUeqXJCyQoxIvITGDc64d5YrdzHeUHWU2q5ULIBkePb/EnM+ZAdm7mtj9bkXwYi3PO 0KfuwgtjtcypOZGLvPEBvDlTpvUxrUiPJbUapSbqRGGE2GAf2WJdeQVFwUmYharuVSji lNkg==; 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-215081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-705ccb3bfd4si4010833b3a.177.2024.06.14.08.27.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-215081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215081-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 575E5B29B2C for ; Fri, 14 Jun 2024 15:04:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53A0F16C691; Fri, 14 Jun 2024 15:02:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62BC119FA66 for ; Fri, 14 Jun 2024 15:01:59 +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=1718377320; cv=none; b=hM5QwbPy7cszRpYbTDsF50ipX4Bi92j7emkQ9ajTrke0gZlRPY+O9lN/pxguxgRgyXiNj6GUm/4/i1El6CIieK7WcjCkJNAsJ9+0J+TLT9pcZOQrUN5tauLb7/4gCFqPxWQ0nlA7eYininXUBU2vIMmIB0X3WuWIm8mVQOhI5G8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377320; c=relaxed/simple; bh=yzp6jmMt7TuJ5X/8yq2bFXKbXSrfaiGiAXhGXXyMabs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ihLxmrLzQ2aOfd2BTIoCvMTmngX75/He/8P/FqXyg6i8rLZ+cFhLmisxMeNFwYrsk2CMZpnoGAG1+lZ9s6Efh5c0MnPxpSr2yv6EQBQ8KRTZAavvcD4vUsQ/vh1yMBKzHjKMYBCpj0TnnaxsDL6okexBdophmRH7F13JhvnjkFA= 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 608F71764; Fri, 14 Jun 2024 08:02:23 -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 99D813F5A1; Fri, 14 Jun 2024 08:01:55 -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 15/38] x86/resctrl: Move monitor exit work to a restrl exit call Date: Fri, 14 Jun 2024 15:00:10 +0000 Message-Id: <20240614150033.10454-16-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_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. 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 Tested-by: Peter Newman Tested-by: Shaopeng Tan --- Changes since v2: * Dropped __exit as needed in the next patch. Change since v1: * [Commit message only] Typo fixes: s/restrl/resctrl/g s/resctl/resctrl/g * [Commit message only] Reword second paragraph to remove reference to the MPAM error interrupt, which provides background rationale for a later patch rather than for this patch, and so it is not really relevant here. --- 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 9ad660b2b097..2540a7cb11b0 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -950,14 +950,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 7ede340b1301..9aa7f587484c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -535,7 +535,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 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 3e5375c365e6..7d6aebce75c1 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -965,10 +965,12 @@ static int dom_data_init(struct rdt_resource *r) return err; } -static void __exit dom_data_exit(void) +static void 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; @@ -1075,9 +1077,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) return 0; } -void __exit rdt_put_mon_l3_config(void) +void 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 82d64885c6c0..8c380f389b93 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4212,4 +4212,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