From patchwork Mon Feb 19 18:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 203213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1468757dyc; Mon, 19 Feb 2024 10:42:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7Y8NFc1XiyjQoAcWm9KmnWTmp9xZ/rq4LRaM4+CHRfi27b/Mz2RrWk9H5/fNeaPFOxcfbQET1hWBkNWhUXR1N2JHkPw== X-Google-Smtp-Source: AGHT+IHhI/oWcOCX9Wc6DpXWgseFTTiUPcz+1Gfy68XyJu6GkiMip498340Hza5v4925+gs9EKQI X-Received: by 2002:a17:90a:fe93:b0:299:72d7:5b9a with SMTP id co19-20020a17090afe9300b0029972d75b9amr3377113pjb.24.1708368171910; Mon, 19 Feb 2024 10:42:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708368171; cv=pass; d=google.com; s=arc-20160816; b=Rlvahuh2r6M9/dZQnKGxw8vXc7OdqQgWBaNVel3EFdu/TtkDjKxbYfY4Qee4nzo8Rp jzCHVgwqoO6FXnO/2d/quNxBwndPuOTqvTp7KoJSZSP7ivcCy7y9IGMOSlbMRzRRb82V kEAcPYG18vOh9X4tUkA5jHa4qEuZhuEEddVeXgXms4YXXibo1SnDJj7Ln7fEyBVSpZb7 oDOUe7F6xxnMuDqlLms8WCOks6P7CHHVFOlb1yLM9BwjUry1STgCMcTgNv/Eg0xKvSia 6F/YsEuODztus6SIjM4xudoE9uZl6MMcd9lps/44cpqingqMW/beHPTMgyVUXjO6e0ZV GUKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=gylPkh/GXT4spEx7pBMUKcdiEuP1e+HFpCy9X4zge8o=; fh=eZrTyJ/HzkLTMaQFI3yBYByyw6CQlIShrIaTFtuWSa4=; b=ie5OrInxPWpV1JaRnANefQcJwnUyp0teO4SLlfLHaDYUSXqmsmh2+hbT3J6Skpv5Yq y9K5XE0h/uPC9nO13EheOqulr7NgWypo7xb6Jfrfo4Dzk+J8xUFa/XSsjSG3LkCr/i1B yv9Zj3JxTmMv6dOoklp9Tvg2MAQoaE9n9WS+59a6eUoWY1SK7NTOKLVBznkfsFjc9571 d/PAeQnaobUB8qXgVwAQk9vx/FZPTBlCFPhKb2AjwqEH9b7SblNwR94YUqVmxTZH2hdQ uSIiMw+i6KS5zu+Lnp1WdOYE8M7B5WipNat+zk8DbjbYL6ajsARgiqvQjcyBQHSRzi3D f7yA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rjcp4DqB; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71834-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71834-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id me4-20020a17090b17c400b00299d1854c85si437810pjb.41.2024.02.19.10.42.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:42:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71834-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rjcp4DqB; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71834-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71834-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 B7F4428294A for ; Mon, 19 Feb 2024 18:42:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DB8456B78; Mon, 19 Feb 2024 18:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rjcp4DqB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="v5LRbMJu" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 856C453E39; Mon, 19 Feb 2024 18:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367865; cv=none; b=QyJlK5nqtNcza0d7v1s/JVKm2wDyC5GIxWgO0Zm9UUQ4Aozch0AZNKKzZRMJbpilPWq1QGc7yOU0PWs8vrkHRnJsEDmtA3GG/R+Gqy4uZ9LN6LmHWo9jh4K8Hbo6itNJWCG3olaQOE6CAb74ngrK/brNgqthsc+BoXjZ6uo0pBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367865; c=relaxed/simple; bh=3N9P4a0i7dcdrj931WaklTIUwvtpjGdAE2hAVW5Azsc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ShBzgkoT0olXp61FqFsj7EEGmE9BfnzpvAzqMbPvBP/HKjc0MvFLIftZy7qc8CxGOm/6H5gY/U1NMzOzK88oo5yxRpsBpnmmvIJMM+GJ0aw7RBiRzbFxm1e34+K9IPzHJGcadpkuxhgY86PzMghrKxrPo3ZbIDlwPF3g33nWT3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rjcp4DqB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=v5LRbMJu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 19 Feb 2024 18:37:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708367861; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gylPkh/GXT4spEx7pBMUKcdiEuP1e+HFpCy9X4zge8o=; b=rjcp4DqBRvs/VJvmtuXOK4eG91zKp5MBRg85j6oGWAZleQYdwdwnrCclhHqq9KhIwHXg4e D7e7M+miC6yYK8SrMOTGb9MEZfyIpaLimgysq1Zo9Pqu2O1RmaGKmIws4Fr0GDR76JHaf0 T4RXycowZquDGQI4IdF7wFujhGsmREv10xl7wdp71qfFLfEjzYClfmqDxqq28zGqcS3Psu 9J+vZ93WBpkmT/RvtQfpDV2HKCLAr64F8Cl1AoHmeISdURSrrY8pbRg7sp2fH8i4lNTL9c c3ONQF0wFjTQMR2rM4a92XBMeRauJiQbhIDQl6n/HJq0/iSQ2VbzvX/LirWf5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708367861; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gylPkh/GXT4spEx7pBMUKcdiEuP1e+HFpCy9X4zge8o=; b=v5LRbMJugSUzgxy+xCkM9TTW1y9IKLBy0QGqm1PREAWM7g7MLeCkpxnoMicVdi8zruLw4A +z8LGzf79IP/J/Cg== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Free rmid_ptrs from resctrl_exit() Cc: James Morse , "Borislav Petkov (AMD)" , Babu Moger , Reinette Chatre , Carl Worth , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213184438.16675-3-james.morse@arm.com> References: <20240213184438.16675-3-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170836786051.398.1615891156083894968.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791353864058981908 X-GMAIL-MSGID: 1791353864058981908 The following commit has been merged into the x86/cache branch of tip: Commit-ID: 3f7b07380d58cfbb6a2d3aa672dcc76c0f4b0745 Gitweb: https://git.kernel.org/tip/3f7b07380d58cfbb6a2d3aa672dcc76c0f4b0745 Author: James Morse AuthorDate: Tue, 13 Feb 2024 18:44:16 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 Feb 2024 19:18:31 +01:00 x86/resctrl: Free rmid_ptrs from resctrl_exit() rmid_ptrs[] is allocated from dom_data_init() but never free()d. While the exit text ends up in the linker script's DISCARD section, the direction of travel is for resctrl to be/have loadable modules. Add resctrl_put_mon_l3_config() to cleanup any memory allocated by rdt_get_mon_l3_config(). There is no reason to backport this to a stable kernel. Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Babu Moger Reviewed-by: Reinette Chatre Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Link: https://lore.kernel.org/r/20240213184438.16675-3-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/resctrl/core.c | 6 ++++++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index aa9810a..9641c42 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -990,8 +990,14 @@ late_initcall(resctrl_late_init); static void __exit resctrl_exit(void) { + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + cpuhp_remove_state(rdt_online); + rdtgroup_exit(); + + if (r->mon_capable) + rdt_put_mon_l3_config(); } __exitcall(resctrl_exit); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 52e7e7d..61c7636 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -544,6 +544,7 @@ void closid_free(int closid); int alloc_rmid(void); void free_rmid(u32 rmid); int rdt_get_mon_l3_config(struct rdt_resource *r); +void __exit rdt_put_mon_l3_config(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 3a6c069..3a73db0 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -719,6 +719,16 @@ static int dom_data_init(struct rdt_resource *r) return 0; } +static void __exit dom_data_exit(void) +{ + mutex_lock(&rdtgroup_mutex); + + kfree(rmid_ptrs); + rmid_ptrs = NULL; + + mutex_unlock(&rdtgroup_mutex); +} + static struct mon_evt llc_occupancy_event = { .name = "llc_occupancy", .evtid = QOS_L3_OCCUP_EVENT_ID, @@ -814,6 +824,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) return 0; } +void __exit rdt_put_mon_l3_config(void) +{ + dom_data_exit(); +} + void __init intel_rdt_mbm_apply_quirk(void) { int cf_index;