From patchwork Thu Feb 10 22:49:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99FB5C433EF for ; Fri, 11 Feb 2022 00:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YVibORtDeeKDb6lFEUDaZgTZvFFAUbTMO8xETucSpHE=; b=rkfBF34cwaIUGv 13AMfPa6kjYWWFwkmGwZltam4rHjycXcdEIdiGHk1lvbnMAOJ7kcYHrgw//jI4cZQq7deVIBZE8/y pcJCUBhq7qlbbcLhqBVSFo/zEvTrFXfWobrHy2jotzwXkF+SBSobQL1t7PofBYGcA+8brb4AvFyYZ ZC6FaXoURAoxNLW28AphtuRAnILrx0uWlw3JrBBl5Ytr0sEHha6X0UAMqbGcuLhN4K2M+3z0k8t6X PMstdNcu6kpk7yp4jAym+A+CHujWXdV3dMd7FE6fq65neCRuPhSlWzCW37r7dATQoGjqRFF4vNXNl YoyebwgR4lbZzE0gKRmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJQc-005GYo-F3; Fri, 11 Feb 2022 00:04:46 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJQY-005GYV-EO for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 00:04:43 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id a19so6844654qvm.4 for ; Thu, 10 Feb 2022 16:04:41 -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=4Pnr1geQeZZNYUvmzTdrAcaSDDBHcWYiYOpV2+IuXsY=; b=igNyfPN7wFlEB1yG0Q94kr/PxThWMFSj7uV6Xa4lsNO8Eodt/gd8/VSAkzJPPNNLqD qQwMyH8ytBWbsWit97TH9K8POhN09okti3ZyrqvzyHsbekkA+9K/sE9UpcWfflBJ6IX+ rhewR0hrCY8scmAiE3GTbwcTImsKu8PHITWAJ8KcJjCbRrQVFfaIPsg5CJBI+XMVT1T2 Mpfbx/rAP4rZXHBa7IM2cBBntYJ+Tq2sImYYlI9cqsl2/gWObSkvu8rlLJoLDx7IJcj1 jCx2oUFhq59q3xZWxiZBd6OlaPcAu9p4kvX0V3N74k5jHjhmq4ZfoiAb7ipvUDuOUeOL 9MJw== 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=4Pnr1geQeZZNYUvmzTdrAcaSDDBHcWYiYOpV2+IuXsY=; b=ORkN3aRHJfbvUhRFeNKwJ2xtNrpu1/r1Uz/AYCC59owPXwFoJDmu/9D9juR3QziHHW dZJ4ihDDRap4A+B2yTA/6tLfU3Ke8ws/8EqlMS4nkn2YIk9Dp/6KzLcu+NAxD1qM4AYe eksjz9JpFP/H5yCs7xAy3xEf69HCpZkwpUCq0IgMHyefAFSC2/Ly5Jg9aNfVA9PKIZ+n L0qJogK9cMb/MIFk12XvNAk7RHaoLTiyTZp3GFUtcS9ASAz24amkujKvXP9h40eFXxei DXzEZHDYjSRmvP0HDJqCof+CzMtg+Yhvf+IA1TpnE+9CZstzNvq+v3Rk+BMWLPpAaGP/ 1/ZQ== X-Gm-Message-State: AOAM531owHaP6xtYgCALs+WaDq+uJffv4/Ivnsz1yoXabvQxkHldelO/ zVevVFxKX8i1w+7FBEZ0yGE= X-Google-Smtp-Source: ABdhPJyfV3TF5HzHznBEsBWEauR+HTDxani3jRA7hek8YabMaXIpvx3P8mEI1Y1Wy7MVJOQjILfz9w== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr6804104qvb.45.1644537881043; Thu, 10 Feb 2022 16:04:41 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id 195sm10710640qkf.30.2022.02.10.16.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:04:40 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , 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, Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 33/49] perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2 Date: Thu, 10 Feb 2022 14:49:17 -0800 Message-Id: <20220210224933.379149-34-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_160442_521378_1A5DD5D3 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org tx2_uncore_event_start() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov Acked-by: Mark Rutland --- drivers/perf/thunderx2_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 1edb9c03704f..97d5b39778fa 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -623,8 +623,8 @@ static void tx2_uncore_event_start(struct perf_event *event, int flags) return; /* Start timer for first event */ - if (bitmap_weight(tx2_pmu->active_counters, - tx2_pmu->max_counters) == 1) { + if (bitmap_weight_eq(tx2_pmu->active_counters, + tx2_pmu->max_counters, 1)) { hrtimer_start(&tx2_pmu->hrtimer, ns_to_ktime(tx2_pmu->hrtimer_interval), HRTIMER_MODE_REL_PINNED);