public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Yury Norov <yury.norov@gmail.com>, <linux-kernel@vger.kernel.org>,
	Fenghua Yu <fenghua.yu@intel.com>, Vinod Koul <vkoul@kernel.org>,
	<dmaengine@vger.kernel.org>
Cc: 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>,
	"Fenghua Yu" <fenghua.yu@intel.com>,
	"tom.zanussi@linux.intel.com" <tom.zanussi@linux.intel.com>
Subject: Re: [PATCH 09/34] dmaengine: idxd: optimize perfmon_assign_event()
Date: Mon, 20 Nov 2023 08:34:41 -0700	[thread overview]
Message-ID: <0bfc5c56-467e-40ef-b0ee-0a15d7f64e33@intel.com> (raw)
In-Reply-To: <20231118155105.25678-10-yury.norov@gmail.com>



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@gmail.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.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;
>  }
>  
>  /*

  reply	other threads:[~2023-11-20 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-18 15:50 [PATCH 00/34] biops: add atomig find_bit() operations Yury Norov
2023-11-18 15:50 ` [PATCH 01/34] lib/find: add atomic find_bit() primitives Yury Norov
2023-11-18 16:23   ` Bart Van Assche
2023-11-18 15:50 ` [PATCH 09/34] dmaengine: idxd: optimize perfmon_assign_event() Yury Norov
2023-11-20 15:34   ` Dave Jiang [this message]
2023-11-24 12:15   ` Vinod Koul
2023-11-18 16:18 ` [PATCH 00/34] biops: add atomig find_bit() operations Bart Van Assche
2023-11-18 19:06   ` Sergey Shtylyov

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=0bfc5c56-467e-40ef-b0ee-0a15d7f64e33@intel.com \
    --to=dave.jiang@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=jack@suse.cz \
    --cc=klimov.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=maxim.kuvyrkov@linaro.org \
    --cc=mirsad.todorovac@alu.unizg.hr \
    --cc=tom.zanussi@linux.intel.com \
    --cc=vkoul@kernel.org \
    --cc=willy@infradead.org \
    --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