From mboxrd@z Thu Jan 1 00:00:00 1970 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 789E9C61D90 for ; Tue, 21 Nov 2023 15:55:26 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6y6LKyXEUQq+PbOQbL5tngzW1UMxIqh5UkMOwGo5COE=; b=LC6fEaJ9pIQal6 MmSmDNUyDUMcrz515DHbZgE8Un3ABZey3I6lw62jT0rkWVTTNGqUTcA//cq3O38FtstSJgSEfIkoY Oq052CTq8ifVs3z31SA56AoaBD6ls4h0afYzDnATz6E2hYu65iUiopFEwzoa6/mhfmCttQpcOWn1n UBZtlNcXDlgLaEZ/fY4f7GJaOwK+62/Sa+No0+2Ewj4+KKBXK+/cJEGT4hGEgyUEp4dmAYidnx+zG jrU2hMfoPW02n8//aLSJPD+KSKU2+72pOq8exOHKwMmkoMp2a3U+fUYXaf1U9cAxjeIkJ6M4FwHRV 1h0skwSFfhq5MsHxoPYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5T5Y-00HDB1-0S; Tue, 21 Nov 2023 15:55:00 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5T5V-00HDAE-1m for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2023 15:54:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E6105618DE; Tue, 21 Nov 2023 15:54:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 602F7C433C8; Tue, 21 Nov 2023 15:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700582096; bh=nUNQwOHk4EELbIput1hMEvEcgZjaGuxBlZjCetzZAIY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FmG1JEOTrepgRO1Uwkv5Pi/eAe3djSEGUAhsS6kO3BfC5of3+YrT30v/wXDJDU1+z 5e7k9H1CC4PoUAx6DKYDACr7PKB+vPxX/RvBLeH0mrpY0zQaqdotr5R6oIqazwpvKG opTK/QY8os/L2fQXAXILGR82HUTxxHKRnm+vMskJ2wFmo7dBeWDE3JCVFviEjKIbVK YypKP2cszURHsv/cUz2of3HonbpVaYyxSZ0v8fmli48Z0rCTkUAANVuCOZ9Kmc0asX 3m24gMqKnoHHsco722BraL7TS5+Y5JHXaOTlx4a+wrhsIKlQ5ka7eWiFbkzsNWqTJG MNhH8x91xYVoQ== Date: Tue, 21 Nov 2023 15:54:50 +0000 From: Will Deacon To: Yury Norov Cc: linux-kernel@vger.kernel.org, Shuai Xue , Mark Rutland , linux-arm-kernel@lists.infradead.org, Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: Re: [PATCH 08/34] drivers/perf: optimize ali_drw_get_counter_idx() by using find_bit() Message-ID: <20231121155450.GC1938@willie-the-truck> References: <20231118155105.25678-1-yury.norov@gmail.com> <20231118155105.25678-9-yury.norov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231118155105.25678-9-yury.norov@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_075457_636161_B325A5F2 X-CRM114-Status: GOOD ( 17.73 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Nov 18, 2023 at 07:50:39AM -0800, Yury Norov wrote: > The function searches used_mask for a set bit in a for-loop bit by bit. > We can do it faster by using atomic find_and_set_bit(). > > Signed-off-by: Yury Norov > --- > drivers/perf/alibaba_uncore_drw_pmu.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c > index 19d459a36be5..2a3b7701d568 100644 > --- a/drivers/perf/alibaba_uncore_drw_pmu.c > +++ b/drivers/perf/alibaba_uncore_drw_pmu.c > @@ -274,15 +274,9 @@ static const struct attribute_group *ali_drw_pmu_attr_groups[] = { > static int ali_drw_get_counter_idx(struct perf_event *event) > { > struct ali_drw_pmu *drw_pmu = to_ali_drw_pmu(event->pmu); > - int idx; > + int idx = find_and_set_bit(drw_pmu->used_mask, ALI_DRW_PMU_COMMON_MAX_COUNTERS); > > - for (idx = 0; idx < ALI_DRW_PMU_COMMON_MAX_COUNTERS; ++idx) { > - if (!test_and_set_bit(idx, drw_pmu->used_mask)) > - return idx; > - } > - > - /* The counters are all in use. */ > - return -EBUSY; > + return idx < ALI_DRW_PMU_COMMON_MAX_COUNTERS ? idx : -EBUSY; > } > > static u64 ali_drw_pmu_read_counter(struct perf_event *event) > -- > 2.39.2 Acked-by: Will Deacon Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel