Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp454417rdb; Thu, 5 Oct 2023 10:34:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhLFVTOC3VJPhFb55snI4BLpjibzRrR9MmMck6aLHiQZ+Tb6Nv9X6aFagREfe63L07uq54 X-Received: by 2002:a05:6808:14c3:b0:3a7:2621:2daf with SMTP id f3-20020a05680814c300b003a726212dafmr7394436oiw.42.1696527268952; Thu, 05 Oct 2023 10:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696527268; cv=none; d=google.com; s=arc-20160816; b=QylA6SorQrrMfi6yY+/ztpZQImqL6dfrx4yrVkcOdTOnm3uU90RrDkPaeVGK1yPgou twLCXbTeg0IuX9siwJmCFgiSCByyp4itGAg1Zb2buYyurS58gtJ4nwKrAK8RzRiCP964 huUiqOwe3WgNNLq2zbjlwIIf5GRJg2Mh6Da+jjBofHquQR3BykeSLhyjCvq37azEFejt EDfMUsq1fshUBr9/bSG54puXb99++BWCYSWUm2N6O2d5hEkNupb5gEKYgxZ7be6tA5OG v52XvjsujVCaMk4jtSYqnyUJL33OBFJsgPiTHjVM7tMofHxhknQM+Oj5otvErj9E9UiG FfIQ== 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=B3UvEER/l3eBZNWg4Ip8p0MVhJ4/aY4sBiAifXx+AMI=; fh=9O97hdzEezSdAQ/hEUF6K6/7TfN/3Uf0QBPpPtoaJ2Y=; b=Css7Fn20m3O/fQbwZTffhHGumbmZmSVPQGRQK9oomMtni8Wk/NRm/5kipT7C29Pv54 Nn1P5rGIMSCm4rN4tFFkcTl07Ie23YKscekAltUVAffVR1GNjdyLUVjj8/PcxEYJHv9W qByCUKAuy33jHwZK5A6OKHlXCOmN1hyjENNW3ROqEcxiQ6uez5VQKBA7qC8VdIULWFeS sDht+DjsIERdEnLXkFGKG8peiBBI9UJvZUs+Vr4a9zDUtuv02bwz9wXLdOMdYKwQayel 3z0aggaUzH/TwnOwYR/Sw930/rYhI+90vKBpoaYz/9PISE5lCAcafUrrwBe6/aTjFDwa 1thQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x185-20020a6386c2000000b00578bea3c10esi1795680pgd.756.2023.10.05.10.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 23850807C575; Thu, 5 Oct 2023 10:34:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjJERbH (ORCPT + 99 others); Thu, 5 Oct 2023 13:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjJERag (ORCPT ); Thu, 5 Oct 2023 13:30:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E2AA171A for ; Thu, 5 Oct 2023 10:07:36 -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 A8CD5C15; Thu, 5 Oct 2023 10:08:14 -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 09BD23F5A1; Thu, 5 Oct 2023 10:07:32 -0700 (PDT) Message-ID: Date: Thu, 5 Oct 2023 18:07:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v6 09/24] x86/resctrl: Use set_bit()/clear_bit() instead of open coding Content-Language: en-GB To: babu.moger@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , 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, amitsinght@marvell.com References: <20230914172138.11977-1-james.morse@arm.com> <20230914172138.11977-10-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=-2.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 05 Oct 2023 10:34:25 -0700 (PDT) Hi Babu, On 04/10/2023 21:38, Moger, Babu wrote: > On 9/14/23 12:21, 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. >> >> A subsequent patch adds resctrl_closid_is_free(), which adds more open >> coded bitmaps operations. These will eventually need changing to use >> the bitops helpers so that a CLOSID bitmap of the correct size can be >> allocated dynamically. >> >> Convert the existing open coded bit manipulations of closid_free_map >> to use set_bit() and friends. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index ac1a6437469f..fa449ee0d1a7 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -106,7 +106,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. >> */ >> -static int closid_free_map; >> +static unsigned long closid_free_map; >> static int closid_free_map_len; >> >> int closids_supported(void) >> @@ -126,7 +126,7 @@ static void closid_init(void) >> closid_free_map = BIT_MASK(rdt_min_closid) - 1; >> >> /* CLOSID 0 is always reserved for the default group */ >> - closid_free_map &= ~1; >> + clear_bit(0, &closid_free_map); > > How about using RESCTRL_RESERVED_CLOSID instead of 0 here? Great idea - even more readable. Thanks, James