Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8970965rwb; Thu, 24 Nov 2022 06:33:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5a6wEgA1krO3156JsJqEPyqkAWNYFbs74YozB9hSRg6J4AJEI7+/Uowfji8A+Fhvqsgx6i X-Received: by 2002:a63:1b60:0:b0:46f:b2a5:2e2d with SMTP id b32-20020a631b60000000b0046fb2a52e2dmr15004031pgm.400.1669300392898; Thu, 24 Nov 2022 06:33:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669300392; cv=none; d=google.com; s=arc-20160816; b=eWntraqBHH+9IuoaGZUZzjWvxsljFSPe2gDHPmEOHAfsOY5e3MonuOGKQeOPMa4Obw rE/F6FaSV7jrYTxR7OBvPJwg8eD3TrjwdFn2ruaQQYLrlgXI6NMaJaR6K+SkLcfP1sf0 bmouw5QhzHD8jsdTOxmmktMXn6Wn0RrO2+/Zu9kq/F7gPkjEWzfRXkA4dBqMFj1RIH8c vCObntjxonS/Nn9hYSbxzfjT/PnI9RAV2D+HggQu7Bv29ByiyEfiv0nOLIBfmcrWVxi3 3Q3KNXW6PsAtkzY7YvEV1Zi6Iy2aGqXEVz2xDL6f+B35t0flAgMtfeKywMTuPFli373C RGLw== 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=qQwOy2vp0tURZKPXC+r0cBTRAmPux5QeCHm6noYTckY=; b=tu90ZUv18QThLa/OL8YJl43iQgxr0PPUih4DKx1t7wMoyye4C8eYhap/1V9zDXP/Fu ZZQr0FgcD0OzLIuU6brvYtO4w56cySAQUpdiWYS9b5M2jOlYg/C4Sdncl2heXHMGGFw1 i9Cg6bqmJk45/AVkqscAQYtLvLiUOxUE9k/QFR9j/S1bVF24BEbBPaU1BGMsnR3LKCTY 2C02tIqZf2ochE7T+fF0TvIFpsyudU4x+RI5aMEARMSwVWnuutn/E93aGSAkhjllpsAx Wb5pJSbUhexbT4s1HrBjOlltHif0YW1h7dNwlNAMuN1LF3jwL3JshrodhMoEoLBTzebS dDcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a634501000000b00476c5012596si24928pga.72.2022.11.24.06.33.01; Thu, 24 Nov 2022 06:33:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiKXOV7 (ORCPT + 86 others); Thu, 24 Nov 2022 09:21:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiKXOVu (ORCPT ); Thu, 24 Nov 2022 09:21:50 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2885126C2 for ; Thu, 24 Nov 2022 06:21:49 -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 6962423A; Thu, 24 Nov 2022 06:21:55 -0800 (PST) Received: from [10.1.197.38] (eglon.cambridge.arm.com [10.1.197.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EFD9B3F73B; Thu, 24 Nov 2022 06:21:45 -0800 (PST) Message-ID: Date: Thu, 24 Nov 2022 14:21:40 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH 04/18] x86/resctrl: Move rmid allocation out of mkdir_rdt_prepare() Content-Language: en-GB To: "Shaopeng Tan (Fujitsu)" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" Cc: Fenghua Yu , Reinette Chatre , 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" , Jamie Iles , Xin Hao , "xingxin.hx@openanolis.org" , "baolin.wang@linux.alibaba.com" , "peternewman@google.com" References: <20221021131204.5581-1-james.morse@arm.com> <20221021131204.5581-5-james.morse@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 10/11/2022 10:50, Shaopeng Tan (Fujitsu) wrote: >> RMID are allocated for each monitor or control group directory, because each of >> these needs its own RMID. For control groups, >> rdtgroup_mkdir_ctrl_mon() later goes on to allocate the CLOSID. >> >> MPAM's equivalent of RMID are not an independent number, so can't be >> allocated until the closid is known. An RMID allocation for one CLOSID may fail, >> whereas another may succeed depending on how many monitor groups a >> control group has. >> >> The RMID allocation needs to move to be after the CLOSID has been allocated. >> >> Move the RMID allocation out of mkdir_rdt_prepare() to occur in its caller, after >> the mkdir_rdt_prepare() call. This allows the RMID allocator to know the >> CLOSID. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index 841294ad6263..c67083a8a5f5 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -3003,12 +3004,19 @@ static int rdtgroup_mkdir_mon(struct kernfs_node >> *parent_kn, >> prgrp = rdtgrp->mon.parent; >> rdtgrp->closid = prgrp->closid; >> >> + ret = mkdir_rdt_prepare_rmid_alloc(rdtgrp); >> + if (ret) { >> + mkdir_rdt_prepare_clean(rdtgrp); >> + goto out_unlock; >> + } >> + >> /* >> * Add the rdtgrp to the list of rdtgrps the parent >> * ctrl_mon group has to track. >> */ >> list_add_tail(&rdtgrp->mon.crdtgrp_list, &prgrp->mon.crdtgrp_list); >> >> +out_unlock: >> rdtgroup_kn_unlock(parent_kn); > Is there any case that a lock is not unlocked here? If you've found an example - please share! The unlock is necessary because mkdir_rdt_prepare() calls rdtgroup_kn_lock_live(), but expects its caller to do the unlock. This patch allows the rmid allocation to fail separately to mkdir_rdt_prepare(), so rdtgroup_mkdir_mon() needs to ensure the unlock() happens when it returns an error, this work was previously done by 'out_unlock' in mkdir_rdt_prepare(). I hope this helps, Thanks, James