From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99223C6FA8F for ; Thu, 24 Aug 2023 16:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242729AbjHXQwG (ORCPT ); Thu, 24 Aug 2023 12:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242737AbjHXQvz (ORCPT ); Thu, 24 Aug 2023 12:51:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7097F1B9 for ; Thu, 24 Aug 2023 09:51:53 -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 6FA5E1007; Thu, 24 Aug 2023 09:52:33 -0700 (PDT) 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 75CD63F740; Thu, 24 Aug 2023 09:51:50 -0700 (PDT) Message-ID: Date: Thu, 24 Aug 2023 17:51:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v5 02/24] x86/resctrl: Access per-rmid structures by index 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, xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com References: <20230728164254.27562-1-james.morse@arm.com> <20230728164254.27562-3-james.morse@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Reinette, On 09/08/2023 23:32, Reinette Chatre wrote: > On 7/28/2023 9:42 AM, James Morse wrote: >> @@ -377,14 +399,17 @@ static void add_rmid_to_limbo(struct rmid_entry *entry) >> >> void free_rmid(u32 closid, u32 rmid) >> { >> + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); >> struct rmid_entry *entry; >> >> - if (!rmid) >> - return; >> - >> lockdep_assert_held(&rdtgroup_mutex); >> >> - entry = __rmid_entry(closid, rmid); >> + /* do not allow the default rmid to be free'd */ >> + if (idx == resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, >> + RESCTRL_RESERVED_RMID)) >> + return; >> + > Why is this encoding necessary? Can the provided function parameters > not be tested directly against RESCTRL_RESERVED_CLOSID and > RESCTRL_RESERVED_RMID ? Doing this by encoding means if the architecture code supplies an resctrl_arch_rmid_idx_encode() that ignores the closid, this reduces down to: | if (rmid == RESCTRL_RESERVED_RMID) which is what the code did before. I'll add a comment: | /* | * Do not allow RESCTRL_RESERVED_RMID to be free'd. Comparing by index | * allows architectures that ignore the closid parameter to avoid an | * unnecessary check. | */ Thanks, James