lkml.org 
[lkml]   [2008]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 1/3] Unified trace buffer
Steven Rostedt wrote:
> OK, let me rephrase my question.
>
> How and where do we record this? Do we keep this information in some
> global variable that we must compare to every time we add a new item in
> the trace?
>
> Do we have the buffer register a call back to record this information?
>

Something like (total pseudocode):

struct tsc_time_parameters {
int version; /* even - values OK; odd - values being updated */
u64 tsc;
u32 tsc_freq;
u64 gtod;
};
DEFINE_PERCPU(struct tsc_time_parameters, tsc_params);

/* To be called after a tsc frequency change, before any new
trace records are being emitted, in a context where we can call get_GTOD() */
void update_tsc_params(void)
{
struct tsc_time_parameters *p = __get_percpu_var(tsc_params);
p->version |= 1;
wmb();
p->tsc = get_tsc();
p->tsc_freq = get_tsc_freq();
p->gtod = get_GTOD();

wmb();
p->version++;
wmb();
}
DEFINE_PERCPU(unsigned, current_tsc_version);
DEFINE_PERCPU(u64, prev_tsc);

/* may be called in any context */
u64 get_trace_timestamp_delta(void)
{
const struct tsc_time_parameters *p = &__get_percpu_var(tsc_params);
unsigned *current_version = &__get_cpu_var(current_tsc_version);
u64 prev = __get_cpu_var(prev_tsc);
u64 now, ret;
/* check the current tsc_params version against the last one we emitted;
if the version is odd, then we interrupted the parameters as they were
being updated, so just emit a new delta with the old parameters */
if (unlikely(*current_version != p->version && !(p->version & 1))) {
/* XXX probably need a loop to deal with p->version changing under our feet */
emit_tsc_freq_record(p);
prev = p->tsc;
__get_cpu_var(current_tsc_version) = p->version;
}
now = read_tsc();
ret = now - prev;
__get_cpu_var(prev_tsc) = now;

return ret;
}

J


\
 
 \ /
  Last update: 2008-09-26 04:09    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site