Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4058002rdb; Thu, 14 Sep 2023 10:24:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsmo97ksyPLqNiFSUVujxU+Vw07opReff7HOG1/E05wuUcmTtSeTbeUHgVfVTEt/Jphilo X-Received: by 2002:a05:6a20:8e05:b0:159:f39a:54e1 with SMTP id y5-20020a056a208e0500b00159f39a54e1mr1868035pzj.51.1694712277268; Thu, 14 Sep 2023 10:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694712277; cv=none; d=google.com; s=arc-20160816; b=ZSYGXdgp4wAfAPo+vqktZT7f5vwe3ojZCE5b7d3YeKVc1wYJH/OrRWeDRNIPHcr6Bi Gry2MojoSFPmrhcGeAta8UPG8aP5xxOEQhqNz2/8xnvk2KC1ea3r4xGmsV74XEYenUYk ufOS/NPhqDUp5Ac23201TZIxk/Y9PtyXipmwVEOcX+QIaMkklIKVeZZfBO1xLk7he490 pY1DRA1vFFP1UWIXfSgW6G4RQTPwi78GpRHM5olvZVSEBRvngdPFv+YPIYx1LtQFlN5Z UpENo+BAr0dDzNN86bGOdN/wAStnfOdYjen6rfVI/K7OxYbUwjNQWb2fOW9vn0AMHlUB lBJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CgLmuXbH4fAxp4dR2P5wSPi/Zvsmz5htU4bQYrUnrDY=; fh=6Nl2MjDBXofbhMXyzAhf7L7loTtEBflFxRNey74qSFc=; b=I72ep5StQeAuxH88JS2/oGPY/JFZxc/G1E38g0I20UAvD85HLRsb90Lk5B9wcfgwmj P1coPzuIQX2fofMwcvPyBwuowfxJZi6nQCGjzokvnNPTC8WFF/vSyo9cqC5s8N/638C+ tsRbFtoroaLy3xlCSLA+5mjDJqmJZ944h4bUQsqoYc+8L8QfsoRVTUFgkut2hzgZ1VFS XyVIZZ309eslb0jd3s1m/1JtCyM2akK9+MDZWonBHX4cPLroOXbFhqkODqTcghhcWvkN SY5atQyyPGGgsyirnQB45RoZ9svkvuVb6cFOqfMAtdsnMMtakYj8EnfO8FluH/U5Xe6X qqUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b0056aca1f1d5csi1804615pgd.777.2023.09.14.10.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:24:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id DFD2D836E1A5; Thu, 14 Sep 2023 10:24:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239212AbjINRWv (ORCPT + 99 others); Thu, 14 Sep 2023 13:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240106AbjINRWd (ORCPT ); Thu, 14 Sep 2023 13:22:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 253B826BD for ; Thu, 14 Sep 2023 10:22:23 -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 D313511FB; Thu, 14 Sep 2023 10:23:00 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C91773F5A1; Thu, 14 Sep 2023 10:22:20 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , 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 Subject: [PATCH v6 09/24] x86/resctrl: Use set_bit()/clear_bit() instead of open coding Date: Thu, 14 Sep 2023 17:21:23 +0000 Message-Id: <20230914172138.11977-10-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230914172138.11977-1-james.morse@arm.com> References: <20230914172138.11977-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:24:17 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 groat.vger.email 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. Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Tested-By: Peter Newman Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); closid_free_map_len = rdt_min_closid; } @@ -137,14 +137,14 @@ static int closid_alloc(void) if (closid == 0) return -ENOSPC; closid--; - closid_free_map &= ~(1 << closid); + clear_bit(closid, &closid_free_map); return closid; } void closid_free(int closid) { - closid_free_map |= 1 << closid; + set_bit(closid, &closid_free_map); } /** @@ -156,7 +156,7 @@ void closid_free(int closid) */ static bool closid_allocated(unsigned int closid) { - return (closid_free_map & (1 << closid)) == 0; + return !test_bit(closid, &closid_free_map); } /** -- 2.39.2