From patchwork Fri Jul 28 16:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 127786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp591089vqg; Fri, 28 Jul 2023 10:35:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOw8joXJDHoKcuoJfq3YrI6aRJusOAlxlIWwVDzcQ2H3zPHUSxOJk6akUtX13vS3nqBt8g X-Received: by 2002:a05:6808:1cd:b0:399:169:75d4 with SMTP id x13-20020a05680801cd00b00399016975d4mr3168036oic.36.1690565736742; Fri, 28 Jul 2023 10:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690565736; cv=none; d=google.com; s=arc-20160816; b=KGev7eWZwY9rsTEt+km6AXVTINMVBFYmEj6XzdK6KJxdz5yd3C1/pI10WAl0ETXES9 +MyqpKx76z1MgZgXO0daQPcZGx9rCtJSL6pNapv5gQRqin7/MGhISvDv+IswJwAvJk/Y 4/+adR1Xo5QqxjR+PAUs3tHScOtxYP/mZWU7WphEVWGRkjm72B4Ysauz0Ta7G/qzj8ps J0zheRzKMA1KPvbkgEr13cXTExNseN7NkU+kNL9M7ccfexjqcgM8ibz7uq6cZ/0mCV2Z brb3ZWFuuwBbfZ3h3hbQjoJOuvlB2d9kuN+qiwKMDpUqCmR4hlixxBV8odEygPKgtCwQ Q0Rw== 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=E4dL7xqpWX4Qe2R+ccPICLR2aZMLBjlNDb57DyAjaJc=; fh=n9L+e/Mo/wOalMjVbltm4zKnQoPh0Qbxoe+x3eznw8A=; b=nFj6EikadMfPNBJqw0ZD0bFUSvb73PckKCnxZ2Mz7sUvOuUkaKJXBAKVcUr2uABGoQ Rr72T6f6D1Fh5ye0wJycOVUrEcXfb+ubug0VbqJWEp3LHjAeW/Gkk8Rlb1AvpfzF58St 4G9sDpzqvkmfjQyIZ2dq8AejDxpps0z7o9c0BjZyoIN5zthiZW8qLhMkRQJUJ3QP1ZJ5 04NT4toBpaNh844ixXVsX5Y+y3Wd1MzudBdABIIeoVqkfvZaESVg+6CrRttQYUjPMWfD Huvf5rrXCkikNE0LZDuDDiSHDVr+K+cHYoLCDue8MBfvlRxHRZLZaxMu1naXkoDZhrba UVMA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi18-20020a17090b4b5200b0026838c1d91csi5077420pjb.38.2023.07.28.10.35.23; Fri, 28 Jul 2023 10:35:36 -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 S233771AbjG1Qot (ORCPT + 99 others); Fri, 28 Jul 2023 12:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234695AbjG1Qnu (ORCPT ); Fri, 28 Jul 2023 12:43:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88423448E for ; Fri, 28 Jul 2023 09:43: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 076B81570; Fri, 28 Jul 2023 09:44:22 -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 3E80E3F67D; Fri, 28 Jul 2023 09:43:36 -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 Subject: [PATCH v5 07/24] x86/resctrl: Use set_bit()/clear_bit() instead of open coding Date: Fri, 28 Jul 2023 16:42:37 +0000 Message-Id: <20230728164254.27562-8-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230728164254.27562-1-james.morse@arm.com> References: <20230728164254.27562-1-james.morse@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772686657801796020 X-GMAIL-MSGID: 1772686657801796020 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. 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 b97e119dbe46..4ab9bb018c17 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); } /**