Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4063293rdb; Thu, 14 Sep 2023 10:34:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH97TdmJmUsThPc31kUkh7CWMIqzKnaiR/PgsltHfV0shRFPjWBbxpLrTgxxpTjPn58ddWI X-Received: by 2002:a05:6a20:9388:b0:155:6e4f:8c1a with SMTP id x8-20020a056a20938800b001556e4f8c1amr6953291pzh.25.1694712871038; Thu, 14 Sep 2023 10:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694712871; cv=none; d=google.com; s=arc-20160816; b=NX4cjJpWQlvHk5RpSu+6gQwAalAJ59xFOvNqNLLuQC8PM0GNplV5s4HVGAG0nV6h+h 3Pnqd1ripqwSoEG7zq4FYm/Nr604bhdyPtuo+vLPenT4fQMuoSGNWC3onJGZNAa709AM qGjOvIiVqfTkQbo25+yJq8LBxpd0/1D1klZYpBFRWWQDSNpFjHf0SUGdkljo6ElaAI/b GTyBETOmxcianCPwh6ebJ48V/Wn/pkSP71G+HsHAP877BUVYMvEZl1QTAGooof0c+vlh ATNeo29Oeh4FRpvtSG1rPehpxkm0dqyQFXr3+gLloxuCClDTCyXgUXe9QaCu7yuPnUm+ WsXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GmBu9z4ZK/2idhlp9g1TEFd5uJd5zE2XSvRAxzlkdXU=; fh=6Nl2MjDBXofbhMXyzAhf7L7loTtEBflFxRNey74qSFc=; b=lEv+OdfciEomDsd6foOglaEoS7XjWRpD6CeFrvm3vFJ4WK5WYQgvDo2fDj2KrRN4Al dMnvoY5lYEug2n08q+ELmtMWvl8sdtGr5nefnkwCBZMg52qX0aCJBrf3kG7UgeXO5/PP X739nWG++D7G1K52sk0x44dg+EinIHnNcqdnNZz6zbISx+RNUs/d6cWxsxI8tiIvuDk/ KVcYd+v6sj4S+VbzgxxLAGvbkgknhF5isGrUQEx6hyTdzZXMvjv2So5dZh/WwW1wLdo+ CAWf8EbWeOlf8gpKwoQBiQ/fncnzGyYZr+aB+JowDTLoQnsFHeBAkRGvVypkQratgWmm cFOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id w20-20020a63fb54000000b005774cf04028si1803089pgj.764.2023.09.14.10.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EA31A82114AC; Thu, 14 Sep 2023 10:22:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238940AbjINRWK (ORCPT + 99 others); Thu, 14 Sep 2023 13:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238865AbjINRWG (ORCPT ); Thu, 14 Sep 2023 13:22:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 48FA31BFE for ; Thu, 14 Sep 2023 10:22:02 -0700 (PDT) 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 3BFD312FC; Thu, 14 Sep 2023 10:22: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 36FDD3F5A1; Thu, 14 Sep 2023 10:21:59 -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, xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com Subject: [PATCH v6 02/24] x86/resctrl: kfree() rmid_ptrs from rdtgroup_exit() Date: Thu, 14 Sep 2023 17:21:16 +0000 Message-Id: <20230914172138.11977-3-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230914172138.11977-1-james.morse@arm.com> References: <20230914172138.11977-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:22:21 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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_exit_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 --- Changes since v5: * This patch is new --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 85ceaf9a31ac..57cf1e6a57bd 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -537,6 +537,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 resctrl_exit_mon_l3_config(struct rdt_resource *r); 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 ded1fc7cb7cb..cfb3f632a4b2 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -741,6 +741,16 @@ static int dom_data_init(struct rdt_resource *r) return 0; } +void resctrl_exit_mon_l3_config(struct rdt_resource *r) +{ + 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, diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 725344048f85..a2158c266e41 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3867,6 +3867,11 @@ int __init rdtgroup_init(void) void __exit rdtgroup_exit(void) { + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (r->mon_capable) + resctrl_exit_mon_l3_config(r); + debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl"); -- 2.39.2