From: Will Deacon <will@kernel.org>
To: Yury Norov <yury.norov@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Shuai Xue <xueshuai@linux.alibaba.com>,
Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org, Jan Kara <jack@suse.cz>,
Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>,
Matthew Wilcox <willy@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Alexey Klimov <klimov.linux@gmail.com>
Subject: Re: [PATCH 08/34] drivers/perf: optimize ali_drw_get_counter_idx() by using find_bit()
Date: Tue, 21 Nov 2023 15:54:50 +0000 [thread overview]
Message-ID: <20231121155450.GC1938@willie-the-truck> (raw)
In-Reply-To: <20231118155105.25678-9-yury.norov@gmail.com>
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 <yury.norov@gmail.com>
> ---
> 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@kernel.org>
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-11-21 15:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231118155105.25678-1-yury.norov@gmail.com>
2023-11-18 15:50 ` [PATCH 07/34] perf/arm: optimize opencoded atomic find_bit() API Yury Norov
2023-11-21 15:53 ` Will Deacon
2023-11-21 16:16 ` Yury Norov
2023-11-21 16:17 ` Will Deacon
2023-11-18 15:50 ` [PATCH 08/34] drivers/perf: optimize ali_drw_get_counter_idx() by using find_bit() Yury Norov
2023-11-21 15:54 ` Will Deacon [this message]
2023-11-18 15:50 ` [PATCH 17/34] iommu: use atomic find_bit() API where appropriate Yury Norov
2023-11-18 15:51 ` [PATCH 31/34] drivers/perf: optimize m1_pmu_get_event_idx() by using find_bit() API Yury Norov
2023-11-18 18:40 ` Marc Zyngier
2023-11-18 18:45 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231121155450.GC1938@willie-the-truck \
--to=will@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jack@suse.cz \
--cc=klimov.linux@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mark.rutland@arm.com \
--cc=maxim.kuvyrkov@linaro.org \
--cc=mirsad.todorovac@alu.unizg.hr \
--cc=willy@infradead.org \
--cc=xueshuai@linux.alibaba.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox