From: Chris Metcalf <cmetcalf@ezchip.com>
To: Frederic Weisbecker <fweisbec@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Luiz Capitulino <lcapitulino@redhat.com>,
Christoph Lameter <cl@linux.com>, Ingo Molnar <mingo@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH 1/7] atomic: Export fetch_or()
Date: Tue, 24 Nov 2015 10:58:00 -0500 [thread overview]
Message-ID: <56548908.50509@ezchip.com> (raw)
In-Reply-To: <1447424529-13671-2-git-send-email-fweisbec@gmail.com>
On 11/13/2015 09:22 AM, Frederic Weisbecker wrote:
> Export fetch_or() that's implemented and used internally by the
> scheduler. We are going to use it for NO_HZ so make it generally
> available.
>
> Cc: Christoph Lameter<cl@linux.com>
> Cc: Chris Metcalf<cmetcalf@ezchip.com>
> Cc: Ingo Molnar<mingo@kernel.org>
> Cc: Luiz Capitulino<lcapitulino@redhat.com>
> Cc: Peter Zijlstra<peterz@infradead.org>
> Cc: Rik van Riel<riel@redhat.com>
> Cc: Thomas Gleixner<tglx@linutronix.de>
> Cc: Viresh Kumar<viresh.kumar@linaro.org>
> Signed-off-by: Frederic Weisbecker<fweisbec@gmail.com>
> ---
> include/linux/atomic.h | 18 ++++++++++++++++++
> kernel/sched/core.c | 14 --------------
> 2 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/atomic.h b/include/linux/atomic.h
> index 00a5763..c3b99f8 100644
> --- a/include/linux/atomic.h
> +++ b/include/linux/atomic.h
> @@ -451,6 +451,24 @@ static inline int atomic_dec_if_positive(atomic_t *v)
> }
> #endif
>
> +/**
> + * fetch_or - perform *ptr |= mask and return old value of *ptr
> + * @ptr: pointer to value
> + * @mask: mask to OR on the value
> + *
> + * cmpxchg based fetch_or, macro so it works for different integer types
> + */
> +#define fetch_or(ptr, mask) \
> +({ typeof(*(ptr)) __old, __val = *(ptr); \
> + for (;;) { \
> + __old = cmpxchg((ptr), __val, __val | (mask)); \
> + if (__old == __val) \
> + break; \
> + __val = __old; \
> + } \
> + __old; \
> +})
> +
> #include <asm-generic/atomic-long.h>
> #ifdef CONFIG_GENERIC_ATOMIC64
> #include <asm-generic/atomic64.h>
I think this should be guarded by an "#ifndef" like other things in
this file, so architectures can provide their own implementations,
or can use the C11 atomic_fetch_or() for newer compilers.
Also, I wonder about the nomenclature here: other than cmpxchg
and xchg, all the atomic ops are named "atomic_xxx". For something
that returns the old value, I'd expect it to be atomic_or_return()
and be otherwise like the existing atomic_or() routine, and thus you'd
specify "atomic_t tick_dependency".
Avoiding all of these issues is probably why fetch_or() is not exported :-)
I made some similar comments last time around:
https://lkml.kernel.org/r/55B2794A.8040707@ezchip.com
--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com
next prev parent reply other threads:[~2015-11-24 15:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 14:22 [PATCH 0/7] nohz: Tick dependency mask v3 Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 1/7] atomic: Export fetch_or() Frederic Weisbecker
2015-11-24 15:58 ` Chris Metcalf [this message]
2015-11-24 21:19 ` Frederic Weisbecker
2015-11-24 21:48 ` Chris Metcalf
2015-11-30 17:36 ` Frederic Weisbecker
2015-11-30 18:17 ` Chris Metcalf
2015-11-25 9:13 ` Peter Zijlstra
2015-11-13 14:22 ` [PATCH 2/7] nohz: New tick dependency mask Frederic Weisbecker
2015-11-24 16:19 ` Chris Metcalf
2015-11-25 11:32 ` Frederic Weisbecker
2015-12-01 20:41 ` Peter Zijlstra
2015-12-01 22:20 ` Frederic Weisbecker
2015-12-02 10:56 ` Peter Zijlstra
2015-12-02 14:08 ` Frederic Weisbecker
2015-12-02 15:09 ` Peter Zijlstra
2015-12-08 15:57 ` Frederic Weisbecker
2015-12-02 12:45 ` Peter Zijlstra
2015-12-02 14:10 ` Frederic Weisbecker
2015-12-02 12:48 ` Peter Zijlstra
2015-12-02 14:11 ` Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model Frederic Weisbecker
2015-11-24 16:19 ` Chris Metcalf
2015-11-25 12:34 ` Frederic Weisbecker
2015-12-02 16:17 ` Peter Zijlstra
2015-12-02 17:03 ` Frederic Weisbecker
2015-12-02 17:15 ` Peter Zijlstra
2015-11-13 14:22 ` [PATCH 4/7] sched: Account rr and fifo tasks separately Frederic Weisbecker
2015-12-02 12:53 ` Peter Zijlstra
2015-12-02 14:16 ` Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 5/7] sched: Migrate sched to use new tick dependency mask model Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 6/7] posix-cpu-timers: Migrate " Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 7/7] sched-clock: " Frederic Weisbecker
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=56548908.50509@ezchip.com \
--to=cmetcalf@ezchip.com \
--cc=cl@linux.com \
--cc=fweisbec@gmail.com \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=viresh.kumar@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
Powered by JetHome