This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [rbraun at sceen dot net: [PATCH] Make __getclktck return 100 for the Hurd]
- From: Rich Felker <dalias at aerifal dot cx>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: Richard Braun <rbraun at sceen dot net>, bug-hurd at gnu dot org, libc-alpha at sourceware dot org
- Date: Tue, 11 Jun 2013 21:24:52 -0400
- Subject: Re: [rbraun at sceen dot net: [PATCH] Make __getclktck return 100 for the Hurd]
- References: <20130611222607 dot GA2793 at mail dot sceen dot net> <20130611224917 dot E93042C07D at topped-with-meat dot com> <20130611225504 dot GA8246 at mail dot sceen dot net> <20130611225546 dot B6CA52C09F at topped-with-meat dot com> <20130611230505 dot GA9058 at mail dot sceen dot net> <20130611231353 dot ED42E2C07D at topped-with-meat dot com>
On Tue, Jun 11, 2013 at 04:13:53PM -0700, Roland McGrath wrote:
> > Basically, top doesn't report correct CPU times. This is caused by
> > sysconf() returning 1000000 while values read from /proc are true tick
> > counts, hence 100 per second at most.
>
> In fact, that is not a "true tick count". Most modern Linux kernels have
> ticks at 1024Hz, for example. The ABI for certain /proc/PID/* files is
> that certain fields are in centiseconds. That has nothing (except for an
> historical relationship) to do with the actual frequency used in the kernel.
>
> This is a bug in procfs, regardless. If it's a good idea to change what
> libc uses, then we'll change. Any caller of times or clock (i.e. any
> interface using clock_t) has to use sysconf (_SC_CLK_TCK) to know the
> translation from "clock ticks" to units of real time.
sysconf(_SC_CLK_TCK) has to match the units returned by the times()
function. That's about the only place it's relevant. My understanding
is that the kernel's times() syscall and numbers reported in /proc are
using the same units, but if not, times() is the one that's required
to match.
Rich