From: David Mosberger <davidm@napali.hpl.hp.com>
To: "David S. Miller" <davem@redhat.com>
Cc: davidm@hpl.hp.com, davidm@napali.hpl.hp.com, akpm@digeo.com,
ak@muc.de, arjanv@redhat.com, johnstul@us.ibm.com,
linux-kernel@vger.kernel.org
Subject: Re: time interpolation hooks
Date: Mon, 19 May 2003 16:03:44 -0700 [thread overview]
Message-ID: <16073.25296.659748.225474@napali.hpl.hp.com> (raw)
In-Reply-To: <20030519.153758.71094061.davem@redhat.com>
>>>>> On Mon, 19 May 2003 15:37:58 -0700 (PDT), "David S. Miller" <davem@redhat.com> said:
DaveM> That's not the issue, if I have only ONE way to do this on my
DaveM> platform, I can INLINE this thing and I DO NOT need function
DaveM> pointers.
With the present code, an architecture does not have to use any
indirect function calls if there is only one known interpolator
(presumably based on a CPU cycle counter). The only extra overhead is
the (inlined) read of variable time_interpolator and a check against
NULL. Is this acceptable?
For convenience, I attached the current proposal. In the SPARC case,
you'd simply never call register_time_interpolator() and use
arch-specific code to calculate (and update) last_nsec_offset. The
time_interpolator_update() and time_interpolator_reset() code then
take care of the rest.
--david
#ifdef CONFIG_TIME_INTERPOLATION
struct time_interpolator {
/* cache-hot stuff first: */
unsigned long (*get_offset) (void);
void (*update) (long);
void (*reset) (void);
/* cache-cold stuff follows here: */
struct time_interpolator *next;
unsigned long frequency; /* frequency in counts/second */
long drift; /* drift in parts-per-million (or -1) */
};
extern volatile unsigned long last_nsec_offset;
#ifndef __HAVE_ARCH_CMPXCHG
extern spin_lock_t last_nsec_offset_lock;
#endif
extern struct time_interpolator *time_interpolator;
extern void register_time_interpolator (struct time_interpolator *);
extern void unregister_time_interpolator (struct time_interpolator *);
/* Called with xtime read- OR write-lock acquired. */
static inline void
time_interpolator_update (long delta_nsec)
{
struct time_interpolator *ti = time_interpolator;
if (last_nsec_offset > 0) {
#ifdef __HAVE_ARCH_CMPXCHG
unsigned long new, old;
do {
old = last_nsec_offset;
if (old > delta_nsec)
new = old - delta_nsec;
else
new = 0;
} while (cmpxchg(&last_nsec_offset, old, new) != old);
#else
/*
* This really hurts, because it serializes gettimeofday(), but without an
* atomic single-word compare-and-exchange, there isn't all that much else
* we can do.
*/
spin_lock(&last_nsec_offset_lock);
{
last_nsec_offset -= min(last_nsec_offset, delta_nsec);
}
spin_unlock(&last_nsec_offset_lock);
#endif
}
if (ti)
(*ti->update)(delta_nsec);
}
/* Called with xtime read- or write-lock acquired. */
static inline void
time_interpolator_reset (void)
{
struct time_interpolator *ti = time_interpolator;
last_nsec_offset = 0;
if (ti)
(*ti->reset)();
}
static inline unsigned long
time_interpolator_get_offset (void)
{
struct time_interpolator *ti = time_interpolator;
if (ti)
return (*ti->get_offset)();
return last_nsec_offset;
}
#else /* !CONFIG_TIME_INTERPOLATION */
static inline void
time_interpolator_update (long delta_nsec)
{
}
static inline void
time_interpolator_reset (void)
{
}
static inline unsigned long
time_interpolator_get_offset (void)
{
return 0;
}
#endif /* !CONFIG_TIME_INTERPOLATION */
next prev parent reply other threads:[~2003-05-19 22:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-16 21:23 Andrew Morton
2003-05-16 22:00 ` David Mosberger
2003-05-17 2:38 ` David S. Miller
2003-05-19 17:34 ` David Mosberger
2003-05-19 17:42 ` Arjan van de Ven
2003-05-19 18:35 ` David Mosberger
2003-05-19 18:57 ` Andrew Morton
2003-05-20 7:26 ` David Mosberger
2003-05-19 22:37 ` David S. Miller
2003-05-19 23:03 ` David Mosberger [this message]
2003-05-19 23:08 ` David S. Miller
2003-05-17 9:09 ` Arjan van de Ven
2003-05-17 16:31 ` john stultz
2003-05-17 16:37 ` john stultz
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=16073.25296.659748.225474@napali.hpl.hp.com \
--to=davidm@napali.hpl.hp.com \
--cc=ak@muc.de \
--cc=akpm@digeo.com \
--cc=arjanv@redhat.com \
--cc=davem@redhat.com \
--cc=davidm@hpl.hp.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.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®