Messages in this thread | | | Date | Fri, 8 Jul 2022 18:39:06 -0400 | From | Steven Rostedt <> | 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@gmail.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; \ > })
| |