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 5C52FC61D85 for ; Tue, 21 Nov 2023 15:54:20 +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=4s3U/Sp3FMjacFR7Ub6RtUlJ6/NjgQ9hvKZGoTaV0zY=; b=ZKD0Twm8IZnmZ9 kFKxZ6H85ONSojgcGG8IU0lH5KrRHnC/3iHtGS7ggAVp13+SBNuAPuTopcY+7cVeqgHizQLYfX3Fr qeQlLkK3o00Z+av0ZBhfKzTjivUsVvUdNMNW0d3NmBITt5MnzIEkbmaAmy+xRY/okNltKnPX/ycat kypMwlCAgK3KJxsYMyYHAoljJ7lAzX93raB0QHwjX2mO0/me3GO9DW28k65eU+w2M/+XEdnQGTSj2 bTNQX9SHZ47vyUgKTjFHqBWu/8GihzRQJdHdVwcvbkGWqHwxSiBOf6eFXG/DLYQrHqeOqOyKiHJ7o g3ygLMZh+6HEp1haUwzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5T4U-00HCxx-2y; Tue, 21 Nov 2023 15:53:54 +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 1r5T4R-00HCxI-2d for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2023 15:53:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B217C617EC; Tue, 21 Nov 2023 15:53:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 527F8C433C7; Tue, 21 Nov 2023 15:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700582030; bh=SoS9Ag1+RqC2NSBHSqQi1wvuc0Z8QYMVBqZbJL+ARpo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A4xoftpBz4krbCJ+RVWs2QWqiTqBBrpytVL5qOIIlmgZhqbid6GcrhnDd/MFhk7qO NFQMMBXQrCAW3TegL2vXnU60F8qnK05nICHTWatU4oKdUSLalu0puc6pR6WonuWIpx pIqztTOPO3k+MpE358j9gn5vYTsrLwf6Cr4x1GD4G5loQDlzDo2fg8vL1PRE+HegRK 5+fJvFoaOt6DOh0YjpVBNFbhlfv7mL4Cu+r+NeoyOyRFpWDd4HtL7quXDvJnRjdWlV lWWgxdfgUMptOVtJP30JjtiguMxflbDtsxcHXnlOqpyMHiD0B2AOQ+6zh8tWazMmii sCNG4BC4n0yJQ== Date: Tue, 21 Nov 2023 15:53:44 +0000 From: Will Deacon To: Yury Norov Cc: linux-kernel@vger.kernel.org, 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 07/34] perf/arm: optimize opencoded atomic find_bit() API Message-ID: <20231121155344.GB1938@willie-the-truck> References: <20231118155105.25678-1-yury.norov@gmail.com> <20231118155105.25678-8-yury.norov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231118155105.25678-8-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_075351_902298_41B5C52C X-CRM114-Status: GOOD ( 17.79 ) 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:38AM -0800, Yury Norov wrote: > Switch subsystem to use atomic find_bit() or atomic iterators as > appropriate. > > Signed-off-by: Yury Norov > --- > drivers/perf/arm-cci.c | 23 +++++------------------ > drivers/perf/arm-ccn.c | 10 ++-------- > drivers/perf/arm_dmc620_pmu.c | 9 ++------- > drivers/perf/arm_pmuv3.c | 8 ++------ > 4 files changed, 11 insertions(+), 39 deletions(-) > > diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c > index 61de861eaf91..70fbf9d09d37 100644 > --- a/drivers/perf/arm-cci.c > +++ b/drivers/perf/arm-cci.c > @@ -320,12 +320,8 @@ static int cci400_get_event_idx(struct cci_pmu *cci_pmu, > return CCI400_PMU_CYCLE_CNTR_IDX; > } > > - for (idx = CCI400_PMU_CNTR0_IDX; idx <= CCI_PMU_CNTR_LAST(cci_pmu); ++idx) > - if (!test_and_set_bit(idx, hw->used_mask)) > - return idx; > - > - /* No counters available */ > - return -EAGAIN; > + idx = find_and_set_bit(hw->used_mask, CCI_PMU_CNTR_LAST(cci_pmu) + 1); CCI400_PMU_CNTR0_IDX is defined as 1, so isn't this wrong? [...] > diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c > index 30cea6859574..e41c84dabc3e 100644 > --- a/drivers/perf/arm_dmc620_pmu.c > +++ b/drivers/perf/arm_dmc620_pmu.c > @@ -303,13 +303,8 @@ static int dmc620_get_event_idx(struct perf_event *event) > end_idx = DMC620_PMU_MAX_COUNTERS; > } > > - for (idx = start_idx; idx < end_idx; ++idx) { > - if (!test_and_set_bit(idx, dmc620_pmu->used_mask)) > - return idx; > - } > - > - /* The counters are all in use. */ > - return -EAGAIN; > + idx = find_and_set_next_bit(dmc620_pmu->used_mask, end_idx, start_idx); It might just be me, but I'd find this a tonne easier to read if you swapped the last two arguments around so that the offset came before the limit in the new function. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel