From: Daniel Walker <dwalker@mvista.com>
To: Jeff Muizelaar <jeff@infidigm.net>
Cc: "Frank Ch. Eigler" <fche@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: Using sched_clock for mmio-trace
Date: Fri, 16 Feb 2007 14:47:45 -0800 [thread overview]
Message-ID: <1171666065.3422.92.camel@imap.mvista.com> (raw)
In-Reply-To: <20070216221022.GA8721@infidigm.net>
On Fri, 2007-02-16 at 17:10 -0500, Jeff Muizelaar wrote:
>
> I still meant for _with_features to have same semantics so calling:
>
> clocksource_get_clock_with_features(CLOCKSOURCE_PM_UNAFFECTED|CLOCKSOURCE_STABLE
> |CLOCKSOURC_ATOMIC|CLOCKSOURCE_64BITS|CLOCKSOURCE_CONTINUOUS);
>
> would be equivalent to calling:
>
> clocksource_get_masked_clock(CLOCKSOURCE_PM_AFFECTED|CLOCKSOURCE_UNSTABLE
> |CLOCKSOURC_NOT_ATOMIC|CLOCKSOURCE_64BITS|CLOCKSOURCE_NOT_CONTINUOUS);
>
> The only difference is that the naming is reversed. i.e. it isn't a
> doulbe negative.
Yes, I assumed that ..
> perhaps a better name would clocksource_get_clock_must_have() or
> clocksource_get_clock_must_be()
>
> > Gets pretty ugly .. The clocksource interface already has a positive
> > rating to describe the "best" clocks in the system, which is used to
> > return the "best" clock .. Where the maintainers of the system give each
> > clock a rating. I would imagine most people would just get the so called
> > "best" clock which has the best rating..
> >
> > I'm starting to think this long flags stringing effect could happen with
> > negative flags also, but it's seems a lot less likely.
>
> The amount of flag stringing should be the same.
I don't think so .. The common case with negative flags is no flags,
then next would be CLOCKSOURCE_UNSTABLE. At most I would guess two
flags .. The other direction your likely to have people using all flags
most of the time. That's why I showed a function call with all the flags
listed.
To be clear the clocksources are already sorted with a rating (no flags
involved).
So for example, On i386 the clocks are sorts as follows,
tsc (300)
acpi_pm (200)
pit (110)
jiffies (1)
So the bulk of the positive information is already there for you. The
tsc clock is by far the best in the system if it's stable. If you ignore
the flags, then you will always be given the tsc .
> > > instead of
> > >
> > > clocksource_get_clock_masked(CLOCKSOURCE_UNSTABLE)
> > > clocksource_get_clock_masked(CLOCKSOURCE_PM_AFFECTED)
> > >
> > > Especially awkward is the CLOCKSOURCE_64BIT flag, as there isn't really
> > > anyway to specify that I want a 64bit timer, only a way to specify that
> > > I don't.
> >
> > I might add a way to get specific flags, but I still think the flags
> > should be mostly negative features.
>
> Yeah, the problem is that all of the features are negative except for
> CLOCKSOURCE_64BIT, so you can't mask for it.
It's meant as a negative feature. So you can mask it if you can't handle
the math .. The only 64bit clock I know off is the tsc, and it's got the
highest rating of all clocks.
> It might be good if something like these explanations could be added as
> comments beside the feature flags.
Ok .. On my TODO list ..
> So, if I was a systemtap style user of the clocksource api, I'd still have to
> do something like:
>
> init() {
> // assume this gives me the tsc
> clock = clocksource_get_masked_clock(CLOCKSOURCE_NOT_ATOMIC);
> register a cpu_freq notifier
> }
>
> trace() {
> trace.time =
> compute_cyc2_ns_by_hand_using_info_from_cpu_freq(clocksource_read(clock))
> }
>
> In this case it doesn't look like using the clocksource stuff helps this
> style of user much as all that is abstracted away is really the reading
> the tsc. On the other hand it sounds like if you want all this stuff
> taken care of for you, most people should be using do_gettimeofday()
> instead.
Instead of using an unstable clock and trying to compensate for it, the
solution is not to use unstable clocks. The clocksource stuff does help
with that.. You can either use the tsc until it becomes unstable, or use
the acpi_pm clock which never becomes unstable. Both are used in the
same way.
> init() {
// gives you the acpi_pm
clock = clocksource_get_masked_clock(CLOCKSOURCE_PM_AFFECTED|CLOCKSOURCE_NOT_ATOMIC);
> register a cpu_freq notifier
> }
>
> trace() {
> trace.time =
cyc2ns(clock, clocksource_read(clock))
> }
>
Daniel
next prev parent reply other threads:[~2007-02-16 22:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-16 1:30 Using sched_clock for mmio-trace Jeff Muizelaar
2007-02-16 16:30 ` Frank Ch. Eigler
2007-02-16 17:45 ` Daniel Walker
2007-02-16 18:10 ` Jeff Muizelaar
2007-02-16 18:28 ` Daniel Walker
2007-02-16 19:34 ` Jeff Muizelaar
2007-02-16 21:06 ` Daniel Walker
2007-02-16 22:10 ` Jeff Muizelaar
2007-02-16 22:47 ` Daniel Walker [this message]
2007-02-17 4:36 ` Jeff Muizelaar
2007-02-16 18:30 ` Jeff Muizelaar
2007-02-16 18:44 ` Randy Dunlap
2007-02-16 19:55 ` Jeff Muizelaar
2007-02-16 20:03 ` Andi Kleen
2007-02-16 21:26 ` Frank Ch. Eigler
2007-02-17 14:56 ` Andi Kleen
2007-02-17 15:19 ` Thomas Gleixner
2007-02-18 17:20 ` Andi Kleen
2007-02-16 20:02 ` Andi Kleen
2007-02-16 19:40 ` Jeff Muizelaar
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=1171666065.3422.92.camel@imap.mvista.com \
--to=dwalker@mvista.com \
--cc=fche@redhat.com \
--cc=jeff@infidigm.net \
--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