sard changes for 2.5.34
Quoted 1 line
+#define MSEC(x) ((x) * 1000 / HZ)
Perhaps it would be better to report the times in ticks using jiffies_to_clock_t(), and let the userland do further conversions? The macro above has an overflow problem, it creates a counter that wraps at 2^32 / HZ (instead of 2^32), and theoretically, the userland doesn't even know what the internal HZ is. The overflow can be avoided with something like
#define MSEC(x) (((x) / HZ) * 1000 + ((x) % HZ) * 1000 / HZ) but I think it would be cleaner just to change the units to ticks, especially if we're moving it to a different file and procps will need to be changed anyway.
On Sat, 14 Sep 2002, Lev Makhlis wrote:
| > +#define MSEC(x) ((x) * 1000 / HZ) | | Perhaps it would be better to report the times in ticks using | jiffies_to_clock_t(), and let the userland do further conversions? | The macro above has an overflow problem, it creates a counter | that wraps at 2^32 / HZ (instead of 2^32), and theoretically, the | userland doesn't even know what the internal HZ is. The overflow | can be avoided with something like | #define MSEC(x) (((x) / HZ) * 1000 + ((x) % HZ) * 1000 / HZ) | but I think it would be cleaner just to change the units to ticks, | especially if we're moving it to a different file and procps will | need to be changed anyway.
Thanks for pointing this out.
I'd rather not expose more ticks in /proc, so for now I'll ask Rick to use this #define for MSEC, which does indeed work nicely.
Signature · 3 lines
~Randy "Linux is not a research project. Never was, never will be." -- Linus, 2002-09-02
Quoted 14 lines · Randy.Dunlap
On Sat, 14 Sep 2002, Lev Makhlis wrote:
| > +#define MSEC(x) ((x) * 1000 / HZ) | | Perhaps it would be better to report the times in ticks using | jiffies_to_clock_t(), and let the userland do further conversions? | The macro above has an overflow problem, it creates a counter | that wraps at 2^32 / HZ (instead of 2^32), and theoretically, the | userland doesn't even know what the internal HZ is. The overflow | can be avoided with something like | #define MSEC(x) (((x) / HZ) * 1000 + ((x) % HZ) * 1000 / HZ) | but I think it would be cleaner just to change the units to ticks, | especially if we're moving it to a different file and procps will | need to be changed anyway.
Quoted 5 lines
Thanks for pointing this out.
I'd rather not expose more ticks in /proc, so for now I'll ask Rick to use this #define for MSEC, which does indeed work nicely.
In that case, I also suggest manual optimization for "convenient" values of HZ, because from what I've seen, GCC can't figure this out on its own:
#if 1000 % HZ == 0
#define MSEC(x) ((x) * (1000 / HZ))
#elif HZ % 1000 == 0
#define MSEC(x) ((x) / (HZ / 1000))
#else
#define MSEC(x) (((x) / HZ) * 1000 + ((x) % HZ) * 1000 / HZ) #endif