Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1841370rdb; Tue, 20 Feb 2024 08:29:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWHNCiGN7H1fSqyHsPw5sfsxCilZPA32mYeGcTpvt6bKqAxWAoqT2lJ9nCQbaUqiMpzJkSDWekjSgidto3EdWvtuPfYkh2r8u2bRGRIAw== X-Google-Smtp-Source: AGHT+IF7jm/AyJhZeT97zQoKGWFbY7I98Tf0l0yS0kSMW+H44NIYINbRTGU+h+NW4lW09zTJNuv5 X-Received: by 2002:a05:6402:1607:b0:564:54c6:6903 with SMTP id f7-20020a056402160700b0056454c66903mr5153147edv.7.1708446541049; Tue, 20 Feb 2024 08:29:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708446541; cv=pass; d=google.com; s=arc-20160816; b=F55sKUzRbU4m6c6PiPJdt3NAgUDmsfXJFiAeE3c9vBX+Nl9Ljr/TZodl6Ub8wmucuq +O9EY90TJJZ0quMNcX26moyQF4IMgKbxsQ8oUnIoUe4KLjPSGpN0ILOnzYvKAz14qMk/ E2ymwzqSyk158vfGRT2Y4MiV6pp2XW+Z8TOdhFo/pJFV3RGYZbeZhFuI5ENTeIxCIIfb 6yB/9OYPCN2jpn5MPdazrIUWqUY5axsd2HD9wkfrfm8LEWuZ08Vw4a4Byt+B5jdy1zjM 47UuntVSq+d1MQGj/OTnlqX5Jgb/fxgD6PQxgCP2xp0jejNgbwh+ht1+WYkVe8R1CPPv nEcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=A4A2x2GiWR7eUfmsGa8/K+tztkGlG50mspOZb/bkrYQ=; fh=tDt/AFmSR0RcDoz39xb2qVFNnP8yrC1cfZIQSe3P1f8=; b=Zaqe5Ujra7cDIYB3iDlX/TvoBt0/9WEy+PEqYYcfmgqLmuy7j15uXPdPBOpqxzUDVo 3IXil/tatQqLywtuGrT3k5T5KWav9FH7JnRoSVvXx8GVpqUE4yNbauuW6l7umc05nD8j oKbJg3Dg9BXTY4INuVdgjjDK+4Zo80z8QiVAEIZNdIgaWCOfAmshbh+r0w4QEI2wn52b QLe8IAbjYfOyM1oibFLUHwKbn54tnqdSrOWuoiHeiRX5mPW4TDmwTNgtIvHrdeHiSnNl /CKiCVtHlR4/24ahOPPIv+YlrYpagO9r0t8DOb9pMYOzugBzTGSAPkmHxPitDkEMnD3p kM9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-73355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t21-20020aa7d715000000b005640a717b42si3477126edq.170.2024.02.20.08.29.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 08:29:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-73355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CB09C1F238B8 for ; Tue, 20 Feb 2024 16:29:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9297877635; Tue, 20 Feb 2024 16:27:26 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CA9E763F3 for ; Tue, 20 Feb 2024 16:27:23 +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=1708446446; cv=none; b=ePcNiuTOLSugRf3lcmK1tuNY//hwnaOQp9nryblkC4n2c6eDJ56p7wVBM2UKY34FkuvNxjuQL6kzcnjya/gEeFbzmZcEqbfLpcQX6NWHjkTmeBcEmhjZtRBTJ9edZWGfEJHAhEkSGjrGsVIMPQTRmWvmzstxWsA4MRlF4BPmS0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708446446; c=relaxed/simple; bh=VDOX45f16PvLcH6zAT7dA/WXjYrMatUFzy/IpxKjtGE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=U3Y2llUxMlUYX0TxOzuC02N+Tzrzo3jnw1rvPw/aRY6BKn+MjYeY8O91Q8tJrsoh0Ip3N0mPUaFiYXec5mIsherKHM8pk5VmOT3R/cIhYfyn7DC0Oxf1+j5FnICz6RNZRnC8Myn6WOIKxs/DSc7SvuX1yuLfYbv5XAFSnzzukr4= 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 89E1AFEC; Tue, 20 Feb 2024 08:28:02 -0800 (PST) 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 16F2E3F762; Tue, 20 Feb 2024 08:27:20 -0800 (PST) Message-ID: <91b58253-f682-49f7-914d-8faf1ce181ef@arm.com> Date: Tue, 20 Feb 2024 16:27:19 +0000 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 v9 09/24] x86/resctrl: Use __set_bit()/__clear_bit() instead of open coding Content-Language: en-GB To: David Hildenbrand , 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, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com References: <20240213184438.16675-1-james.morse@arm.com> <20240213184438.16675-10-james.morse@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi David, On 20/02/2024 16:00, David Hildenbrand wrote: > On 13.02.24 19:44, James Morse wrote: >> The resctrl CLOSID allocator uses a single 32bit word to track which >> CLOSID are free. The setting and clearing of bits is open coded. >> >> Convert the existing open coded bit manipulations of closid_free_map >> to use __set_bit() and friends. These don't need to be atomic as this >> list is protected by the mutex. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index dcffd1c4a476..bc6e0f83c847 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -111,7 +111,7 @@ void rdt_staged_configs_clear(void) >>    * - Our choices on how to configure each resource become progressively more >>    *   limited as the number of resources grows. >>    */ > > That comment talks about "free CLOSIDs in a single integer". Once could think about > rephrasing that to "free CLOSIDs in a simple bitmap." > >> -static int closid_free_map; >> +static unsigned long closid_free_map; >>   static int closid_free_map_len; >>     int closids_supported(void) >> @@ -130,8 +130,8 @@ static void closid_init(void) >>         closid_free_map = BIT_MASK(rdt_min_closid) - 1; > > Now that we use "unsigned long", I was wondering for a second if we should use "proper" > bitmap functions here like > >     bitmap_fill(closid_free_map, rdt_min_closid); > > and converting the alloc path (replace ffs() in closid_alloc()): > >     closid = find_first_bit(closid_free_map, closid_free_map_len); >     if (closid == closid_free_map_len) >         return -ENOSPC; >     __clear_bit(closid, &closid_free_map); > > (would get rid of the closid-- in closid_alloc()) Yup. I have this as something to post after all the MPAM changes as it's not necessary to get MPAM going. The patch[0] uses the bitmap APIs you suggest to remove the fixed limit on the number of CLOSID/PARTID. MPAM systems are being built with more than 32, but will work without that patch. > Just a thought, so > > Reviewed-by: David Hildenbrand Thanks! James [0] https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/commit/?h=mpam/snapshot/v6.7-rc2&id=b530deed244d9b45f3bce3cccde91f6ed0ebf7ea