From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 480AB16EBF0 for ; Mon, 1 Jul 2024 18:17:52 +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=1719857873; cv=none; b=Sgf02kU9PfwLqB+20kY8zRRFTxxltjLCjXcwyVrTSr/4TUuGuQZjKEhesdvn9mheirjuAnILht3xueoJbTZsWzEFxgQU8WXTwd5qyPzsbjuEWjFm8epqlK5YtTZFdO4K9tsZK6Ye+7pG/sFo5gjhz7GqRqKLD0HNKW7jdY7ATS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719857873; c=relaxed/simple; bh=S+4dTREH6lhcjn1Pb0b4UTnO12MqMYB1CC9R9lsZBbA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=W31BE04FHpz9B7MxnkwWlaBSRCsqKN4tANoOsz4R5GOh8IHXZ2xmfhNrNPLqiAichHf/mjYrcgh2X70UnHvdLiju3vJWMdNKsbC45yXz4YxxlPjN89q3MeIXMK9aWPYyK27XpfvQ8iYSiNoAN165MG868zJlfQ9zQgy2fVzo3z8= 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 D8A2D339; Mon, 1 Jul 2024 11:18:16 -0700 (PDT) Received: from [10.1.196.28] (eglon.cambridge.arm.com [10.1.196.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C2503F766; Mon, 1 Jul 2024 11:17:48 -0700 (PDT) Message-ID: <26844dc5-5fbb-40ea-842a-a467240c679d@arm.com> Date: Mon, 1 Jul 2024 19:17:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 15/38] x86/resctrl: Move monitor exit work to a restrl exit call 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, David Hildenbrand , Rex Nie , Dave Martin , Shaopeng Tan References: <20240614150033.10454-1-james.morse@arm.com> <20240614150033.10454-16-james.morse@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Reinette, On 28/06/2024 17:46, Reinette Chatre wrote: > On 6/14/24 8:00 AM, James Morse wrote: >> 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() > resctrl_mon_resource_init() does not exist at this point making > this motivation difficult to follow. Right - I re-ordered the patches to make the diffs simpler. I'll drop this paragraph. >> 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(). >> 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); > > I know there has been a bit of back&forth on whether the mutex is needed > here. With this change moving dom_data_exit() out from __exit I think > the locking should aim to be consistent with existing runtime > and thus the check of r->mon_capable should be with mutex held. Having > this little snippet outside mutex will just cause confusion. > Do you have motivation for needing this be done outside of mutex? Just to avoid sleeping - then returning having done nothing. > I think it > ended up this way with this patch aiming to keep existing flow exactly, > but that ended up as convenience in a flow where mutex was not really > needed at all. Sure - I don't think it matters either way. Its not a path where performance matters. The property is read-only from when resctrl_init() is called. I'll make it look like resctrl_offline_domain(). Thanks, James