Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1562283iof; Tue, 7 Jun 2022 07:49:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9haeqUbm8dTObQwBMmQ5sGM4BE1Ut70yT5DLTgkYHeZfAJQVxz2QqHV5qXQKw39o7W8Ph X-Received: by 2002:a05:6402:c1:b0:42a:b8a5:8d5e with SMTP id i1-20020a05640200c100b0042ab8a58d5emr34118304edu.266.1654613385538; Tue, 07 Jun 2022 07:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654613385; cv=none; d=google.com; s=arc-20160816; b=xamU/hjz2rl4bVLfknUzfmE7Aipd5STE82Cg18NQv9QOaeddkzMljrc6prLKjkDREJ jEYa3ksxAXbk6vY55D7wLUG49awOOs2r4rllM9LIfrTFchDSxvrqshmlvyYKt722/DZL JRO0ZBTGKgcsbHZuqu/qbjs+xdPSQRY7Z80/MDp0MHxvJU2sRxFG3c0g4KbgVd+K/Z82 ew/BSpSgY9kelYXXBNnEMhR/C7HuDLoDkNNZC6/vVr+i2/Nq/bmGQjVEbWwQv7fP5Wlk NnUjT4P7Dtd7x0u3vyAMxgcuZ+goyDBSOXhveGMJJjW2uCjQ126zgs3a3UPfFMqm8JW/ 3TTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=AFTFS7SI+fAw3x++VKynxeUURoigvEgSSvKEKIPLUJw=; b=hGKobrYC2lmPaf4nON5tA+46nNkv7A16O+L9XrDTD2YKRiotRtGBEYaht8FVkWhCpG xmEqjXhbEU8kCQQr8kr2WoRa+u5ITNxc5N7Vh9ERPJqdTGAGOU1BklVV1+1OC6bchbIO U7tkr3QqcI/0ytyokvMf+5vVySTGnllrcK7t+ravCrIWNXKlIpLo/84RGTnIfQn9p1kL Vt62O2cJlb4pG/48jSpGBAsu3qAgJ4LmkZPusdtCmJ/vrqVSGHrutdvFnMfQEqQkGB8P u92xAhdixRqKkv365ihBSs+vFVzdvxx3k2xrZQgil6mixy8HLo8V1DmsgdRtLl+tgO0g s0zg== 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 dr11-20020a170907720b00b006e6f361280fsi10680139ejc.724.2022.06.07.07.49.18; Tue, 07 Jun 2022 07:49:45 -0700 (PDT) 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 S243444AbiFGMH5 (ORCPT + 99 others); Tue, 7 Jun 2022 08:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243421AbiFGMHj (ORCPT ); Tue, 7 Jun 2022 08:07:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1CFE037A31 for ; Tue, 7 Jun 2022 05:07:39 -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 D054B143D; Tue, 7 Jun 2022 05:07:38 -0700 (PDT) Received: from [10.1.196.218] (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6AD773F85F; Tue, 7 Jun 2022 05:07:34 -0700 (PDT) Subject: Re: [PATCH v4 07/21] x86/resctrl: Create mba_sc configuration in the rdt_domain 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 , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Cristian Marussi , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com References: <20220412124419.30689-1-james.morse@arm.com> <20220412124419.30689-8-james.morse@arm.com> <7f1c23cd-486d-9bbd-2bcc-c2db0fa1e5c2@intel.com> From: James Morse Message-ID: Date: Tue, 7 Jun 2022 13:07:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <7f1c23cd-486d-9bbd-2bcc-c2db0fa1e5c2@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hi Reinette, On 17/05/2022 17:18, Reinette Chatre wrote: > On 4/12/2022 5:44 AM, James Morse wrote: >> @@ -3263,6 +3295,7 @@ void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d) >> cancel_delayed_work(&d->cqm_limbo); >> } >> >> + mba_sc_domain_destroy(r, d); >> domain_destroy_mon_state(d); >> } > > It is not clear to me how rdt_domain->mbps_val will be released via the above call. > > After patch 3/21 and the hunk below resctrl_online_domain() would look like: [..] > If I understand the above correctly, if MBM is enabled then all domains > of resource RDT_RESOURCE_MBA will have rdt_domain->mbps_val allocated via > resctrl_online_domain(). > > RDT_RESOURCE_MBA is not mon_capable, Bother - this is part of the mistake I made with v3. (in MPAM, all resources can be alloc_capable or mon_capable - this trips me up every time) > so at the time its domains go > offline, the freeing of rdt_domain->mbps_val will be skipped because > after patch 5/21 resctrl_offline_domain() would look like below so > I do not see how the hunk added above will ever end up cleaning up > allocated memory: Yup, I missed this when fixing the mistake you pointed out in v3. I've changes this to have: | if (supports_mba_mbps() && r->rid == RDT_RESOURCE_MBA) | mba_sc_domain_destroy(r, d); in resctrl_offline_domain(). >> @@ -3302,12 +3335,20 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) >> >> lockdep_assert_held(&rdtgroup_mutex); >> >> + if (is_mbm_enabled() && r->rid == RDT_RESOURCE_MBA) { > > This introduces only half of the checks that are later replaced in > patch 10 "x86/resctrl: Abstract and use supports_mba_mbps()". Could the > full check be used here for that patch to be cleaner or perhaps patch 10 > could be moved to be before this patch? Great idea. >> + err = mba_sc_domain_allocate(r, d); >> + if (err) >> + return err; >> + } >> + >> if (!r->mon_capable) >> return 0; >> >> err = domain_setup_mon_state(r, d); >> - if (err) >> + if (err) { >> + mba_sc_domain_destroy(r, d); >> return err; >> + } > > Cleaning up after the error is reasonable but this allocation would only > ever happen if the resource is RDT_RESOURCE_MBA and it is not mon_capable. > Something would thus have gone really wrong if this cleanup is necessary. > Considering that only mon_capable resources are initialized at this point, > why not just exit right after calling mba_sc_domain_allocate()? I'm a little uncomfortable adding more places that hardcode "this resources is never mon_capable", its something that has to be bodged around by MPAM where any resource can have monitors. But sure, this just needs looking at in more detail in the future. Thanks, James