From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Nicolas Pitre <nico@cam.org>
Cc: David Howells <dhowells@redhat.com>,
torvalds@osdl.org, akpm@linux-foundation.org,
linux-am33-list@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] MN10300: Move asm-arm/cnt32_to_63.h to include/linux/
Date: Fri, 26 Sep 2008 14:20:35 +0200 [thread overview]
Message-ID: <1222431635.16700.278.camel@lappy.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.LFD.2.00.0809260802310.3635@xanadu.home>
On Fri, 2008-09-26 at 08:03 -0400, Nicolas Pitre wrote:
> On Fri, 26 Sep 2008, Peter Zijlstra wrote:
>
> > On Wed, 2008-09-24 at 17:48 +0100, David Howells wrote:
> > > Move asm-arm/cnt32_to_63.h to include/linux/ so that MN10300 can make use of it
> > > too.
> > >
> > > Signed-off-by: David Howells <dhowells@redhat.com>
> > > ---
> > >
> > > arch/arm/mach-pxa/time.c | 2 +
> > > arch/arm/mach-sa1100/generic.c | 2 +
> > > arch/arm/mach-versatile/core.c | 2 +
> > > include/linux/cnt32_to_63.h | 80 ++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 83 insertions(+), 3 deletions(-)
> > > create mode 100644 include/linux/cnt32_to_63.h
> >
> > Didn't you forget to remove the old one?
> >
> >
> > > +#define cnt32_to_63(cnt_lo) \
> > > +({ \
> > > + static volatile u32 __m_cnt_hi; \
> > > + union cnt32_to_63 __x; \
> > > + __x.hi = __m_cnt_hi; \
> > > + __x.lo = (cnt_lo); \
> > > + if (unlikely((s32)(__x.hi ^ __x.lo) < 0)) \
> > > + __m_cnt_hi = __x.hi = (__x.hi ^ 0x80000000) + (__x.hi >> 31); \
> > > + __x.val; \
> > > +})
> > > +
> > > +#endif
> >
> > That code is way to smart :-)
> >
> > Better make sure that non of its users are SMP capable though.
>
> Why would that matter?
#define cnt32_to_63(cnt_lo)
({
static DEFINE_PER_CPU(u32, __m_cnt_hi);
union cnt32_to_63 __x;
u32 *__m_cnt_hi_ptr = &get_cpu_var(__m_cnt_hi);
__x.hi = *__m_cnt_hi_ptr;
__x.lo = (cnt_lo);
if (unlikely((s32)(__x.hi ^ __x.lo) < 0))
*__m_cnt_hi_ptr = __x.hi = (__x.hi ^ 0x80000000) + (__x.hi >> 31);
put_cpu_var(__m_cnt_hi);
__x.val;
})
And I'm not quite sure why you had volatile in there.. but that should
be replaced by a barrier().
Also, we could probably use __get_cpu_var() and put BUG_ON(!in_atomic())
in there since if this stuff is per cpu, it'd better be atomic anyway -
you don't want to read a different cpu's counter than the one you're
using to upgrade.
next prev parent reply other threads:[~2008-09-26 12:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 16:48 David Howells
2008-09-24 16:48 ` [PATCH 2/2] MN10300: Make sched_clock() report time since boot David Howells
2008-09-26 10:58 ` Peter Zijlstra
2008-09-26 10:56 ` [PATCH 1/2] MN10300: Move asm-arm/cnt32_to_63.h to include/linux/ Peter Zijlstra
2008-09-26 12:03 ` Nicolas Pitre
2008-09-26 12:08 ` Peter Zijlstra
2008-09-29 1:21 ` Nicolas Pitre
2008-09-26 12:20 ` Peter Zijlstra [this message]
2008-09-29 1:42 ` Nicolas Pitre
2008-10-01 14:34 ` David Howells
2008-10-01 15:36 ` Nicolas Pitre
2008-10-02 22:23 ` David Howells
2008-10-03 19:15 ` Nicolas Pitre
2008-10-06 10:44 ` David Howells
2008-10-06 15:06 ` Nicolas Pitre
2008-09-26 13:27 ` David Howells
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=1222431635.16700.278.camel@lappy.programming.kicks-ass.net \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=linux-am33-list@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nico@cam.org \
--cc=torvalds@osdl.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