Re: [PATCH] sysctl: vfs_cache_divisor

From: Kyle Moffett
Date: Fri Mar 23 2007 - 21:18:44 EST


On Mar 23, 2007, at 20:45:21, Kyle Moffett wrote:
On Mar 23, 2007, at 16:59:02, H. Peter Anvin wrote:
Randy Dunlap wrote:
That makes a lot of sense to me. It gives us finer-grained control without having to support fixed-point data. I've been working on the fixed-point data patch, but I'm going to give this method some time also, to see how it looks in code (instead of just thinking about it).

Well, to be specific, it actually is the same thing with different syntax (38.55 or 3855/100).

/* On input: reduce num/den but retain old values for display purposes */
gcd = euclid(&inputnum, &inputden);
num = inputnum/gcd;
den = inputden/gcd;

Whoops, if I divide inputnum and inputden by gcd I don't need to pass by reference.

The trivial implementation of euclid (modulo the bogus address-of operations above) is of course something like this:

unsigned long euclid(unsigned long a, unsigned long b)
{
unsigned long q, r;

if (!a || !b)
return 1;

do {
q = a / b;
r = a % b;
a = b;
b = r;
} while (r);

return a;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/