2008-08-06 20:48:37

by Piotr Jaroszyński

[permalink] [raw]
Subject: HZ from userspace

Hello,
I want to be able to convert starttime from /proc/#/stat to absolutetime and it seems that I need HZ to do that as it is measured injiffies. How can I get HZ? I have seen some discussion about this buthaven't found a definite answer. procps is using some hacks do it andI would prefer to avoid them.I only need a solution for modern kernels, say 2.6.20+ if that matters.
-- Best Regards,Piotr Jaroszyński????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?


2008-08-06 21:50:01

by Ray Lee

[permalink] [raw]
Subject: Re: HZ from userspace

On Wed, Aug 6, 2008 at 1:48 PM, Piotr Jaroszyński<[email protected]> wrote:> Hello,>> I want to be able to convert starttime from /proc/#/stat to absolute> time and it seems that I need HZ to do that as it is measured in> jiffies. How can I get HZ? I have seen some discussion about this but> haven't found a definite answer. procps is using some hacks do it and> I would prefer to avoid them.> I only need a solution for modern kernels, say 2.6.20+ if that matters.
`man sysconf`, in particular you want sysconf(_SC_CLK_TCK).????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2008-08-06 22:07:56

by Piotr Jaroszyński

[permalink] [raw]
Subject: Re: HZ from userspace

>> I want to be able to convert starttime from /proc/#/stat to absolute>> time and it seems that I need HZ to do that as it is measured in>> jiffies. How can I get HZ? I have seen some discussion about this but>> haven't found a definite answer. procps is using some hacks do it and>> I would prefer to avoid them.>> I only need a solution for modern kernels, say 2.6.20+ if that matters.>> `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).
manpage says it's obsolete and i read in some discussion that it onlyreturns the default and not the real HZ used.
-- Best Regards,Piotr Jaroszyński????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2008-08-06 22:17:04

by Ray Lee

[permalink] [raw]
Subject: Re: HZ from userspace

On Wed, Aug 6, 2008 at 3:07 PM, Piotr Jaroszyński<[email protected]> wrote:>>> I want to be able to convert starttime from /proc/#/stat to absolute>>> time and it seems that I need HZ to do that as it is measured in>>> jiffies. How can I get HZ? I have seen some discussion about this but>>> haven't found a definite answer. procps is using some hacks do it and>>> I would prefer to avoid them.>>> I only need a solution for modern kernels, say 2.6.20+ if that matters.>>>> `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).>> manpage says it's obsolete and i read in some discussion that it only> returns the default and not the real HZ used.
I believe the claim that it's out of date is out of date. manpages3.0.1 has an update to this, according to a message I saw on this lista month or so ago.
Regardless, the fields you're reading should all be showing USER_HZwhich is fixed at 100 per second regardless of the underlying kernelHZ parameter.
Try it.????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2008-08-06 22:20:09

by Sven Wegener

[permalink] [raw]
Subject: Re: HZ from userspace

On Wed, 6 Aug 2008, Piotr Jaroszy?ski wrote:

> >> I want to be able to convert starttime from /proc/#/stat to absolute
> >> time and it seems that I need HZ to do that as it is measured in
> >> jiffies. How can I get HZ? I have seen some discussion about this but
> >> haven't found a definite answer. procps is using some hacks do it and
> >> I would prefer to avoid them.
> >> I only need a solution for modern kernels, say 2.6.20+ if that matters.
> >
> > `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).
>
> manpage says it's obsolete and i read in some discussion that it only
> returns the default and not the real HZ used.

You can get the information via two ways. At compile time, that is the
variable CLK_TCK and this way has been obsoleted. The other way is at
runtime via sysconf(_SC_CLK_TCK) and that is still valid. You don't need
the real HZ, because the kernel converts it to USER_HZ, which is currently
100 on x86 for historic reasons.

Sven

2008-08-06 22:20:49

by Ray Lee

[permalink] [raw]
Subject: Re: HZ from userspace

On Wed, Aug 6, 2008 at 3:16 PM, Ray Lee <[email protected]> wrote:> On Wed, Aug 6, 2008 at 3:07 PM, Piotr Jaroszyński> <[email protected]> wrote:>>>> I want to be able to convert starttime from /proc/#/stat to absolute>>>> time and it seems that I need HZ to do that as it is measured in>>>> jiffies. How can I get HZ? I have seen some discussion about this but>>>> haven't found a definite answer. procps is using some hacks do it and>>>> I would prefer to avoid them.>>>> I only need a solution for modern kernels, say 2.6.20+ if that matters.>>>>>> `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).>>>> manpage says it's obsolete and i read in some discussion that it only>> returns the default and not the real HZ used.>> I believe the claim that it's out of date is out of date. manpages> 3.0.1 has an update to this, according to a message I saw on this list> a month or so ago.>> Regardless, the fields you're reading should all be showing USER_HZ> which is fixed at 100 per second regardless of the underlying kernel> HZ parameter.>> Try it.>
Here's the latest proc(5) man page from June 25, 2008. Look for_SC_CLK_TCK about a third of the way down.
http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2008-08-06 22:21:08

by Piotr Jaroszyński

[permalink] [raw]
Subject: Re: HZ from userspace

>>>> I want to be able to convert starttime from /proc/#/stat to absolute>>>> time and it seems that I need HZ to do that as it is measured in>>>> jiffies. How can I get HZ? I have seen some discussion about this but>>>> haven't found a definite answer. procps is using some hacks do it and>>>> I would prefer to avoid them.>>>> I only need a solution for modern kernels, say 2.6.20+ if that matters.>>>>>> `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).>>>> manpage says it's obsolete and i read in some discussion that it only>> returns the default and not the real HZ used.>> I believe the claim that it's out of date is out of date. manpages> 3.0.1 has an update to this, according to a message I saw on this list> a month or so ago.>> Regardless, the fields you're reading should all be showing USER_HZ> which is fixed at 100 per second regardless of the underlying kernel> HZ parameter.>> Try it.
Ah ok, thanks a lot for info, will do.

-- Best regards,Piotr Jaroszyński????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?