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] [day] [month] [year] [list]
Message-ID: <20220708183906.345aae71@gandalf.local.home>
Date:   Fri, 8 Jul 2022 18:39:06 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Uros Bizjak <ubizjak@...il.com>
Cc:     linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Christian Brauner <brauner@...nel.org>
Subject: Re: [PATCH RESEND] sched/core: Use try_cmpxchg in
 set_nr_{and_not,if}_polling

On Wed, 29 Jun 2022 17:15:52 +0200
Uros Bizjak <ubizjak@...il.com> wrote:

> +++ b/kernel/sched/core.c
> @@ -873,15 +873,11 @@ static inline void hrtick_rq_init(struct rq *rq)
>  	({								\
>  		typeof(ptr) _ptr = (ptr);				\
>  		typeof(mask) _mask = (mask);				\
> -		typeof(*_ptr) _old, _val = *_ptr;			\
> +		typeof(*_ptr) _val = *_ptr;				\
>  									\
> -		for (;;) {						\
> -			_old = cmpxchg(_ptr, _val, _val | _mask);	\
> -			if (_old == _val)				\
> -				break;					\
> -			_val = _old;					\
> -		}							\
> -	_old;								\
> +		do {							\
> +		} while (!try_cmpxchg(_ptr, &_val, _val | _mask));	\

I'm curious to why use a do { } while() and not just:

		while (!try_cmpxchg(_ptr, &_val, _val | _mask))
			;

I see that this is Peter's recommended way from commit a9ebf306f52c75
("locking/atomic: Introduce atomic_try_cmpxchg()")

Peter, why the do { } while() ?

Does it generate better asm than while () ; ?

-- Steve

> +	_val;								\
>  })

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ