[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0bfc5c56-467e-40ef-b0ee-0a15d7f64e33@intel.com>
Date: Mon, 20 Nov 2023 08:34:41 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Yury Norov <yury.norov@...il.com>, <linux-kernel@...r.kernel.org>,
Fenghua Yu <fenghua.yu@...el.com>,
Vinod Koul <vkoul@...nel.org>, <dmaengine@...r.kernel.org>
CC: Jan Kara <jack@...e.cz>,
Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
Matthew Wilcox <willy@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@...aro.org>,
Alexey Klimov <klimov.linux@...il.com>,
"Fenghua Yu" <fenghua.yu@...el.com>,
"tom.zanussi@...ux.intel.com" <tom.zanussi@...ux.intel.com>
Subject: Re: [PATCH 09/34] dmaengine: idxd: optimize perfmon_assign_event()
On 11/18/23 08:50, 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@...il.com>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>
> ---
> drivers/dma/idxd/perfmon.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/idxd/perfmon.c b/drivers/dma/idxd/perfmon.c
> index fdda6d604262..4dd9c0d979c3 100644
> --- a/drivers/dma/idxd/perfmon.c
> +++ b/drivers/dma/idxd/perfmon.c
> @@ -134,13 +134,9 @@ static void perfmon_assign_hw_event(struct idxd_pmu *idxd_pmu,
> static int perfmon_assign_event(struct idxd_pmu *idxd_pmu,
> struct perf_event *event)
> {
> - int i;
> -
> - for (i = 0; i < IDXD_PMU_EVENT_MAX; i++)
> - if (!test_and_set_bit(i, idxd_pmu->used_mask))
> - return i;
> + int i = find_and_set_bit(idxd_pmu->used_mask, IDXD_PMU_EVENT_MAX);
>
> - return -EINVAL;
> + return i < IDXD_PMU_EVENT_MAX ? i : -EINVAL;
> }
>
> /*
Powered by blists - more mailing lists