Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5490696rdb; Wed, 13 Dec 2023 10:03:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA4PHqEu6psJPbaiNE81hUpSz18sIrRdW2lbhU00EG2ZFwg+txwguFUzuxIPdCR/k7fiP2 X-Received: by 2002:a05:6a20:5656:b0:18b:902f:892 with SMTP id is22-20020a056a20565600b0018b902f0892mr4148276pzc.40.1702490613780; Wed, 13 Dec 2023 10:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490613; cv=none; d=google.com; s=arc-20160816; b=yKm5q6H75IuXR0+mYwtk7k6WHLoT7MlYd06EvVDmOahackP+J1Jsoo3Rw/4JStFlTu 17E7aW8kWWuohsgDPaD4qbtTcu3HGA85VNTyB7sfCJ9tmquraDy+MqFzoyspA2HTuSIJ Y4QgGoF3eLjNm2VXVpNTJtujkJKSrFlqNaHNSS71FtMhA+CMacxzOL7MPJhmDUevK7i9 uKTiepPELlKY+IvE2hX91t6TlRFz9mv5ewA1EloQSlokukj7Cy3+omZ99XglGzox/1M3 NvJ/FG1L2DizHRRrHF3PQrEAbRZ0kmO+FtsgGxqEqwq9qvvIEY7EDEnIZsfBVdiqX+RV RASQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=VP2ztNGaNnskjbobPiYQx335M67usHUPhmO6YVHb0Fk=; fh=V3EXrfhtPXQ8VZs+995Yo8T+zOpBnshrD4ANVkhZrjM=; b=Zqlqo8fpQBZ7uS99eaASU6lxjiORWaGv1AEEPT5H2Nz99RBGGNqk9Cc2QPV8zmZTcZ F3EBWBA6fnzwDhZLvtBBB3UTe8w3KooU729jCQG1ymiWaQt7mjE+LHTiRiSXT+eFwj7E iMEnBlqYDUdZDAyoTJDS9ggN1ZUHATCb1K1YXcRvlMomAyHB9pdIaGShKxoH4xC5RLwx yo00zGhfqIpF5+70mC1D9JpuuzqVM/IcDwxbWwbFU6qWtH8xrkXoOh8s2JOEtnpznEes eOmHuOZfz5ex4u3krbzwclApOmZjzrGUswKHEt1+WqF3bYaaw4t2+FyXamhJx5u/Ywjp 0BYQ== 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:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id n14-20020a63f80e000000b005ca4098bf63si2470983pgh.645.2023.12.13.10.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 432EC81BB1A1; Wed, 13 Dec 2023 10:03:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233645AbjLMSDI (ORCPT + 99 others); Wed, 13 Dec 2023 13:03:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233600AbjLMSDH (ORCPT ); Wed, 13 Dec 2023 13:03:07 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AACF593 for ; Wed, 13 Dec 2023 10:03:13 -0800 (PST) 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 3174BC15; Wed, 13 Dec 2023 10:03:59 -0800 (PST) Received: from [10.1.197.60] (eglon.cambridge.arm.com [10.1.197.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 990913F762; Wed, 13 Dec 2023 10:03:10 -0800 (PST) Message-ID: Date: Wed, 13 Dec 2023 18:03:04 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v7 02/24] x86/resctrl: kfree() rmid_ptrs from rdtgroup_exit() Content-Language: en-GB To: Reinette Chatre , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , 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 References: <20231025180345.28061-1-james.morse@arm.com> <20231025180345.28061-3-james.morse@arm.com> <208c3ade-a8c3-41cc-b136-4ab9b7e938e5@intel.com> From: James Morse In-Reply-To: <208c3ade-a8c3-41cc-b136-4ab9b7e938e5@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:03:24 -0800 (PST) Hi Reinette On 09/11/2023 17:39, Reinette Chatre wrote: > Hi James, > > Subject refers to rdtgroup_exit() but the patch is actually changing > resctrl_exit(). I'll fix that, > On 10/25/2023 11:03 AM, James Morse wrote: >> 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(). > > To match what patch actually does it looks like this should rather be: > "Add resctrl_exit_mon_l3_config()" -> "Add resctrl_put_mon_l3_config()" > >> >> There is no reason to backport this to a stable kernel. [...] >> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c >> index 19e0681f0435..0056c9962a44 100644 >> --- a/arch/x86/kernel/cpu/resctrl/core.c >> +++ b/arch/x86/kernel/cpu/resctrl/core.c >> @@ -992,7 +992,13 @@ 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); >> + >> + if (r->mon_capable) >> + rdt_put_mon_l3_config(r); >> + >> rdtgroup_exit(); >> } > > I expect cleanup to do the inverse of init. I do not know what was the > motivation for the rdtgroup_exit() to follow cpuhp_remove_state() This will invoke the hotplug callbacks, making it look to resctrl like all CPUs are offline. This means it is then impossible for rdtgroup_exit() to race with the hotplug notifiers. (if you could run this code...) > but I > was expecting this new cleanup to be done after rdtgroup_exit() to be inverse > of init. This cleanup is inserted in middle of two existing cleanup - could > you please elaborate how this location was chosen? rdtgroup_exit() does nothing with the resctrl structures, it removes sysfs and debugfs entries, and unregisters the filesystem. Hypothetically, you can't observe any effect of the rmid_ptrs array being freed as all the CPUs are offline and the overflow/limbo threads should have been cancelled. Once cpuhp_remove_state() has been called, this really doesn't matter. Thanks, James