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 4E667C61D90 for ; Tue, 21 Nov 2023 16:18: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=E+kp22NDLgcCzJxrq9ertPDlVZO3FacgyaR8YYquqKo=; b=l2EYyABDorH+ts iRdvyqtsoBp1NjuTQj6O/6a+1WwZmbCk0VP/KNbqvExGaaSePGlgvbIYm8ytzuVzju+hgLZJg7DvQ wz3899Dy3QmNVcAbup9l2Q4b3NoBYnmuaVXeBxTGOR/1wlrCryZZaI1XrXYja+fgRMQobP9yNS2QN QAOvVh+VuHrk5+29IkqOB6vktAzc9P46iMxdoK45enEA8JlI7Ry/edBq/gljJnXLZuwKT81csXxPJ urB8H7zKpnmDvZ6k/CjNVQESRU5f1wA423Z15urOVHUMW7o23Rs++W5P/T5/b+ie+HA5GAhcuDG3x Wobldv+m/gV0DcdwifVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5TRh-00HG9j-1d; Tue, 21 Nov 2023 16:17:53 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5TRf-00HG8w-0v for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2023 16:17:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 0520CCE1C64; Tue, 21 Nov 2023 16:17:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 380C5C433C8; Tue, 21 Nov 2023 16:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700583468; bh=7cSOHL2IJoGFmC5GmmnLkiU+EjKX6ahpFKVxkXiUgDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eq0EG04J1DXAqs3vJIZolU3NEyJeIwWevtTYBz0vO9D8e+gpCDdFKNLg3ZQaXt1dr SUFtUIqUTHZZTvoNwnAQxhZ3OD154gKT5HOL2+WX+CY+0vS02Fax6pvI3xhTUBGLyH Vj7FQ0pLr4NFqUI3iEZANxlliV/pCkMEFWMTWB06xpl9LYw1pxN65HTpuaLtjcfT/g 6IN4DkHuduC10RllAeKNp6uOrKjgrITWq3hcDxVfMQkwU9oympZZtm1EclJMgk+fHB q2xUUmPD/FUH8eOOV3MZ7OioLmdFA7AoRg8HJDqeqDjLwagkiXPCOFeDgQFZ8G5wIS AVP9zbvflfT7w== Date: Tue, 21 Nov 2023 16:17:42 +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: <20231121161742.GA2151@willie-the-truck> References: <20231118155105.25678-1-yury.norov@gmail.com> <20231118155105.25678-8-yury.norov@gmail.com> <20231121155344.GB1938@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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_081751_779588_E088C2E9 X-CRM114-Status: GOOD ( 24.45 ) 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 Tue, Nov 21, 2023 at 08:16:13AM -0800, Yury Norov wrote: > On Tue, Nov 21, 2023 at 03:53:44PM +0000, Will Deacon wrote: > > 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? > > You're right. Will fix in v2 > > > [...] > > > > > 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. > > I personally agree, but we already have find_next_*_bit(addr, nbits, offset) > functions, and having atomic versions of the same with different order > of arguments will make it even more messy... Urgh, and there's loads of them too :( Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel