Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3175666pxb; Mon, 24 Jan 2022 04:15:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF/TunqSdJRwdvjvnHcUzDuc2IaAuFxTMlho2WbHDMtj2EvBGpJMMlCMn9PSi8lKbU40Wo X-Received: by 2002:a65:460d:: with SMTP id v13mr11590028pgq.373.1643026508036; Mon, 24 Jan 2022 04:15:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026508; cv=none; d=google.com; s=arc-20160816; b=GpXNLF3ft2WqTLNrDQIOnfc6wsTk5jvU52J5U2tnlYltGvi1Qaf3hff1GFOvxyVhaN ROY0J2uE3fpscAgudfAXR3pT7UtzU9NvKAK+bVKOfFCEL1ybalg2+u35UYrhqLcCXalV z97gpEEkIX7sdS+jtUhsvLJIAwhcq943aMh8p8uK7+8LV85OwCmMeNLH3uPajCK2fpbG tLfkM98VSGwKiFzQktGTLdUqM5bVft5HJNNdodCV6K5N8Gx+I/PYNCDG9uSy6r/Iirnm nHo5cauqmqSpHVWeFftD5+kJPtQ58/rdPMNoGeu533il+pJCdzu+F4daUBT8xQqNFEav sp8w== 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:to:from :dkim-signature; bh=HHGGgmQVmFZBmg7DQxGJPvdjEjZRhNrQASscNGanVdc=; b=Iixkmtu/2tC+JpjrvfTXiJ0GzFbWLY2OGbzdGhW6dShmYBaVj8bdXl25DFVGvJ7ULi 7MBrjq73YL9dwpU9wpjQ/t6KLsc4iH37cXcg496i7SkqS1s7CL0SWsxyU8qtRDTYCzhV x7okiWSHUTVRzlIrTti4sSzvk4eBddrxqtSD1KjCbs+AfgnUwwDR3gGHHMsK8G3pcDkj Q6eIyIKh6OH1epkXorBHQothzZDlkXcqrziL+e8kEKBE9NoTy7mvbX7a9Uz/Qw4N4TCQ /xZg+gFKO0kyAFhHGXrXxcNVHWk38E4Pn4KHrYr5OM4PRw/qxgA9eMOxYpxnWj/nLfbj M4AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="EH/6cSa9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si12464947pls.622.2022.01.24.04.14.55; Mon, 24 Jan 2022 04:15:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="EH/6cSa9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240111AbiAWSmB (ORCPT + 99 others); Sun, 23 Jan 2022 13:42:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbiAWSlR (ORCPT ); Sun, 23 Jan 2022 13:41:17 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7966C061755 for ; Sun, 23 Jan 2022 10:41:16 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id i65so13769829pfc.9 for ; Sun, 23 Jan 2022 10:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HHGGgmQVmFZBmg7DQxGJPvdjEjZRhNrQASscNGanVdc=; b=EH/6cSa9YHoSM91y5ppgiQJWPTpXdG2h1ASsA1/BQXv7gF9h/mYO8png7AQzQ0PAHf j4VJRE+ZUXzbDygTfHwyInQ8nSymy4SRByDkAF5PbljjJssj/ISvNZYH57UV09qGoPuw LZVsthHIjt3JVJ4eYc5AcRvOlwzJgZ/JCdXft3FvsB0+UX3xKG761HQk0DVzrwArnBsZ CVChd9PanY0ZkBcfFw2y26HoT7nigXGb3ncN2czDrLbJOwgV/eFW7y26qkcOB48q3EWg IAPNxN9I+AUoD038aGCuWKHyG9dl08IJUEoVfXbWuGJ1h2E+cb5cs91xPZVVz2Qq4IBu /Dog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HHGGgmQVmFZBmg7DQxGJPvdjEjZRhNrQASscNGanVdc=; b=Hu42dJwLJu1nN/t/ZKZkXJYkqI8AvG6k0gwGO8G+kJ106z8eGyMN3q1PWsG9GozugT kLx/WhJ0PB76SQFV5mxCCMs6y9VNQFjwzjflxXRShc9r1lXJvDJ9dOA4J3JlgduKb0pw F+6OBEMbMyq6LwGmnPeTyQbBlfXMquIhvTSVCjxnftQkVpnDYcoMZ7gUdU1Yem+AagR7 U9qSXtsHN9zaqK2q+wuoZPxzaxoRf/rPqvEMCkzY7XTvrfXn3jllN5ni7/uxg6BFhB8s TIbWTTkxXuhcCifkpe86pSP3kx4wg6AtRaacSP+aBAc6fFd1Qsat4LO31GHDEmTSRo6w HcYg== X-Gm-Message-State: AOAM531SI4pjG0YtSadLNCMS25iihL+WWHTHFclVso22x8u9s/Ce/VAa 173so8/vBJtm05oy/hVRHxk= X-Received: by 2002:a63:a00a:: with SMTP id r10mr9334290pge.553.1642963276432; Sun, 23 Jan 2022 10:41:16 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id nv13sm4817821pjb.18.2022.01.23.10.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:16 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 28/54] arch/x86: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} where appropriate Date: Sun, 23 Jan 2022 10:38:59 -0800 Message-Id: <20220123183925.1052919-29-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __init_one_rdt_domain in rdtgroup.c code calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_lt because conditional bitmap_weight() may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index e23ff03290b8..9d42e592c1cf 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2752,7 +2752,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct resctrl_schema *s, * bitmap_weight() does not access out-of-bound memory. */ tmp_cbm = cfg->new_ctrl; - if (bitmap_weight(&tmp_cbm, r->cache.cbm_len) < r->cache.min_cbm_bits) { + if (bitmap_weight_lt(&tmp_cbm, r->cache.cbm_len, r->cache.min_cbm_bits)) { rdt_last_cmd_printf("No space on %s:%d\n", s->name, d->id); return -ENOSPC; } -- 2.30.2