lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e816aa75-4588-dae4-2d01-6f5ba9d4a4f3@intel.com>
Date:   Wed, 5 Jul 2023 07:53:07 -0700
From:   Dave Jiang <dave.jiang@...el.com>
To:     Uros Bizjak <ubizjak@...il.com>, <dmaengine@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Fenghua Yu <fenghua.yu@...el.com>, Vinod Koul <vkoul@...nel.org>,
        "Zanussi, Tom" <tom.zanussi@...el.com>
Subject: Re: [PATCH] dmaengine:idxd: Use local64_try_cmpxchg in
 perfmon_pmu_event_update



On 7/3/23 07:52, Uros Bizjak wrote:
> Use local64_try_cmpxchg instead of local64_cmpxchg (*ptr, old, new) == old
> in perfmon_pmu_event_update.  x86 CMPXCHG instruction returns success in
> ZF flag, so this change saves a compare after cmpxchg (and related move
> instruction in front of cmpxchg).
> 
> Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
> fails. There is no need to re-read the value in the loop.
> 
> No functional change intended.
> 
> Cc: Fenghua Yu <fenghua.yu@...el.com>
> Cc: Dave Jiang <dave.jiang@...el.com>
> Cc: Vinod Koul <vkoul@...nel.org>
> Signed-off-by: Uros Bizjak <ubizjak@...il.com>


Cc: Tom Zanussi

Tom do you mind review this patch? Thanks!

> ---
>   drivers/dma/idxd/perfmon.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/idxd/perfmon.c b/drivers/dma/idxd/perfmon.c
> index d73004f47cf4..fdda6d604262 100644
> --- a/drivers/dma/idxd/perfmon.c
> +++ b/drivers/dma/idxd/perfmon.c
> @@ -245,12 +245,11 @@ static void perfmon_pmu_event_update(struct perf_event *event)
>   	int shift = 64 - idxd->idxd_pmu->counter_width;
>   	struct hw_perf_event *hwc = &event->hw;
>   
> +	prev_raw_count = local64_read(&hwc->prev_count);
>   	do {
> -		prev_raw_count = local64_read(&hwc->prev_count);
>   		new_raw_count = perfmon_pmu_read_counter(event);
> -	} while (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
> -			new_raw_count) != prev_raw_count);
> -
> +	} while (!local64_try_cmpxchg(&hwc->prev_count,
> +				      &prev_raw_count, new_raw_count));
>   	n = (new_raw_count << shift);
>   	p = (prev_raw_count << shift);
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ