Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8973645rwb; Thu, 24 Nov 2022 06:34:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5LBkNWey95lPpjLSyPacFR5ncA6bKKZYTANQb39TEnVbm4w3audlFhYc7ebe0MfDxNvJYq X-Received: by 2002:a17:906:e87:b0:78d:b88f:1548 with SMTP id p7-20020a1709060e8700b0078db88f1548mr28756847ejf.221.1669300498492; Thu, 24 Nov 2022 06:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669300498; cv=none; d=google.com; s=arc-20160816; b=f6nQ6N6gvh1gMZA6Vj8wvJ3D1zt9BrTRTpRUQ5DtYrN97ITuiEXVIUkDnTiLSgDunR r8naiMvEz3mIwrIIfGYi1mjvI/0r8Uon1B/4BWJrCukSwuRERRgnZkNoFVB44IEgPLVM FI/U4DE5ofdabheGN5tjtadblk6IZnMllS9pQF4jYEE9xJrYbv3SxHOAotyx0XX5riRf FSwdFKZy69bOxVQP1HM6zHzRQS8y5uM5k9e/J1NhDn+QoawY+TlOjFkXqFzQf+ghUCY9 tdixi2yvwBKxfSgtsktiJ8CJdbn4paX3gBLaMdRfDUsWgtoLsKE1rWg+5q9kKj4keRyK T05w== 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=U1wRRepe+tjH8R3O5k91R4MUeJzVbXPn8Y6bK9n5mgw=; b=OFNZTzWnPjvbLptUmzx+s1gSKXkib2ygsR4LxUFn0TnWtrBOr+6CAQM/nmD1lSAOgh diIIRHly5IyTlBzjPvbCMekznugszsFSLV38zZ69z7/DHWVhmdUrxoBXfFZPtn+IfgfE V3w/qvBELUH3nfIj+DoQ4AUEHjT3kGZQ9ivTDkWOAwZ14TBEub9slGzsUrEjO2BbbHMU JubrTOCRoFllJ2a3MisSKForyTTpDQAL+idS3pnVGLr82taj/0gfuStdRGIQ85p4s08z zNN4IIuc+eJUuHQ7zSqQ4WzGE8vCJHtxBztWobVpnFWkL54YfSFEazJshabiricxpVfo wISw== 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 m9-20020a056402430900b0046a9b3521fasi764469edc.134.2022.11.24.06.34.37; Thu, 24 Nov 2022 06:34:58 -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 S229639AbiKXOWA (ORCPT + 86 others); Thu, 24 Nov 2022 09:22:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiKXOV5 (ORCPT ); Thu, 24 Nov 2022 09:21:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F264D238 for ; Thu, 24 Nov 2022 06:21:55 -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 35F9E106F; Thu, 24 Nov 2022 06:22:02 -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 3CFAF3F73B; Thu, 24 Nov 2022 06:21:53 -0800 (PST) Message-ID: Date: Thu, 24 Nov 2022 14:21:52 +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 06/18] x86/resctrl: Allow the allocator to check if a CLOSID can allocate clean RMID 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-7-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: > Hi James > >> MPAM's PMG bits extend its PARTID space, meaning the same PMG value can >> be used for different control groups. >> >> This means once a CLOSID is allocated, all its monitoring ids may still be dirty, >> and held in limbo. >> >> Add a helper to allow the CLOSID allocator to check if a CLOSID has dirty RMID >> values. This behaviour is enabled by a kconfig option selected by the >> architecture, which avoids a pointless search for x86. >> >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c >> b/arch/x86/kernel/cpu/resctrl/monitor.c >> index 59da256a77fe..99854ef4dee4 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -320,6 +320,37 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 >> +bool resctrl_closid_is_dirty(u32 closid) { >> + struct rmid_entry *entry; >> + int i; >> + >> + lockdep_assert_held(&rdtgroup_mutex); >> + >> + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) >> + return false; >> a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index ac88610a6946..59f33adcf6f8 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -119,14 +119,18 @@ static void closid_init(void) >> >> static int closid_alloc(void) >> { >> - u32 closid = ffs(closid_free_map); >> + u32 closid; >> >> - if (closid == 0) >> - return -ENOSPC; >> - closid--; >> - closid_free_map &= ~(1 << closid); >> + for_each_set_bit(closid, &closid_free_map, closid_free_map_len) { >> + if >> (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID) && >> + resctrl_closid_is_dirty(closid)) > IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID) is redundant here, > since it is also at the beginning of function resctrl_closid_is_dirty(closid). This is true. I included it because resctrl_closid_is_dirty() is in a different compilation unit, so the compiler can't know it does nothing if that config option isn't enabled. This avoided a pointless call to a function that does nothing. But you're right it would be more readable without it, and creating a control group is hardly a performance critical path. I'll remove it. Thanks, James