Hi -

> >>    global s, t%
> >>    probe kernel.trace("foobar_enter") {
> >>        t[tid()]=gettimeofday_us()
> >>    }
> >>    probe kernel.trace("foobar_exit") {
> >>        if (tid() in t) { s <<< gettimeofday_us() - t[tid()] }
> >>    }
> >>    probe timer.s(5),end {
> >>        printf("cumulative average us: %d\n", @avg(s))
> >>    }
> > [...]
> 
> Interesting solution. How does it scale with CPUs and tasks?

It's not a simple question, as there are several factors, but
generally fine.

systemtap compiles down to native code, so execution is very fast and
CPU consumption is not a problem (better than streaming to userspace &
processing there).

Depending on actual runtime behavior, there may be contention over the
t[] array that tracks start-time.  systemtap automagically safely
locks these for correctness.  If contention is high, trylock/timeouts
can fail and some probes will be missed.  Fail too many and the script
will self-terminate.  (See [man stap] for some of the related
configurables.)

There is no contention over the s scalar value tracks elapsed time,
since it is implicitly aggregated on a per-cpu basis.  That scales
without problem.

- FChE
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to