From patchwork Thu Apr 20 20:27:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13219170 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 5C309C7618E for ; Thu, 20 Apr 2023 20:28:40 +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:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KqJj75aoxUfi7vZClsvoVB3UXMsBMZ687P5EQnJiDVQ=; b=4MhmZ7a4pr+tXi ffV849YIb4NZdLPIlIOiuIhOl9yruzl0GgM8RdD/hrUOQcz55STzv4sPJMfCvJiNVqlxZcWtQuwIJ AqdQPS4Qkz6RnaOHVuETbn/9jwL1ua4PkfF4I8H2/XFxfQL2xEACtP7pYwu7Rkn3X5fToMrwjuy+j TDVWvE68gca+p0eOPWSpknnVuc4RxG7kTLaSjrxkQqYxoyHCZ8PX/FAGZnhXVhDSi12qPpIbMG6r+ LhZuiGVtOOk4B3547v7cKuxEry+Wt6LZmCOqsxzjpNbknp/pmj5FY8GT7N4+y9Vc9GVSFkeyCU3ut 7D1Tn/ah+6Z+i+PF0J+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppasY-008wpl-04; Thu, 20 Apr 2023 20:27:42 +0000 Received: from smtp-14.smtpout.orange.fr ([80.12.242.14] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppasU-008woL-1C for linux-arm-kernel@lists.infradead.org; Thu, 20 Apr 2023 20:27:40 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id pasJp7IVs9ZjUpasKpiGJf; Thu, 20 Apr 2023 22:27:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682022449; bh=NZgNRLRGgwI0RD4dEiOi7Nq+A1YJQOKy4LiUQwQNZ04=; h=From:To:Cc:Subject:Date; b=phEO4bKNTjMTviP2M/Dnkp5BsIUVZJvI10h7l5Xo8d8S/ebsHDy8CbubLApUT6T7w cp9Gy02sbzQtWHubZULa55OqtJzASBN2tpiKE3tDrshyN4TyqteOy6NFhz9tcYinEh xFRFpm29/N2t/JWzILkoQhDpDgDK4e1K9jA7rPCnjdjvwwvetmfk3ttmOOqhOJ4kA4 oOf1ADkRQ50JCk0YHIiBa0nrGqkPjjihtiRYs2xxvvCMIfg3o8FkCJ1Z2TOtIJeVQW Z4AXGPeDlYdjwREaQNCOoQn4oF3eB7svDAZ70/6S1tlH5tBX0PsAnRotPsUBJ9EScS o1zf+nqiAKqOQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 20 Apr 2023 22:27:29 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Will Deacon , Mark Rutland Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org Subject: [PATCH] perf/arm-cci: Slightly optimize cci_pmu_sync_counters() Date: Thu, 20 Apr 2023 22:27:24 +0200 Message-Id: <88d4e20d595f771396e9d558c1587eb4494057db.1682022422.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230420_132738_849205_5A8261F0 X-CRM114-Status: GOOD ( 12.53 ) 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 When the 'mask' bitmap is cleared, it is better to use its full maximum size instead of only the needed size. This lets the compiler optimize it because the size is now known at compile time. HW_CNTRS_MAX is small (i.e. currently 9), so a call to memset() is saved. Also, as 'mask' is local to the function, the non-atomic __set_bit() can also safely be used here. Signed-off-by: Christophe JAILLET --- drivers/perf/arm-cci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 03b1309875ae..998259f1d973 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -645,7 +645,7 @@ static void cci_pmu_sync_counters(struct cci_pmu *cci_pmu) struct cci_pmu_hw_events *cci_hw = &cci_pmu->hw_events; DECLARE_BITMAP(mask, HW_CNTRS_MAX); - bitmap_zero(mask, cci_pmu->num_cntrs); + bitmap_zero(mask, HW_CNTRS_MAX); for_each_set_bit(i, cci_pmu->hw_events.used_mask, cci_pmu->num_cntrs) { struct perf_event *event = cci_hw->events[i]; @@ -656,7 +656,7 @@ static void cci_pmu_sync_counters(struct cci_pmu *cci_pmu) if (event->hw.state & PERF_HES_STOPPED) continue; if (event->hw.state & PERF_HES_ARCH) { - set_bit(i, mask); + __set_bit(i, mask); event->hw.state &= ~PERF_HES_ARCH; } }