From: Steven Rostedt <rostedt@goodmis.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH RESEND] sched/core: Use try_cmpxchg in set_nr_{and_not,if}_polling
Date: Fri, 8 Jul 2022 18:39:06 -0400 [thread overview]
Message-ID: <20220708183906.345aae71@gandalf.local.home> (raw)
In-Reply-To: <20220629151552.6015-1-ubizjak@gmail.com>
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; \
> })
prev parent reply other threads:[~2022-07-08 22:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 15:15 Uros Bizjak
2022-07-06 11:37 ` [tip: sched/core] " tip-bot2 for Uros Bizjak
2022-07-08 22:39 ` Steven Rostedt [this message]
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=20220708183906.345aae71@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=brauner@kernel.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ubizjak@gmail.com \
--cc=vincent.guittot@linaro.org \
/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
all inboxes | Powered by JetHome®