Re: Linux 2.1 kernel patch --- update /dev/random driver.

Theodore Y. Ts'o (tytso@mit.edu)
Mon, 25 May 1998 21:07:38 -0400


Date: Mon, 25 May 1998 11:49:23 +0200
From: Alexander Kjeldaas <astor@guardian.no>

Isn't this the same as the ffs() function?

This seems to be needed several places in the kernel and there is
native support for this operation on many architectures. Someone has
already provided a patch to implement ffs in bitops.h but it hasn't
been included yet. Maybe it's a good idea to do so now?

What's currently implemented is much like ffs, except it only works up
to 12 bits, since that's all we need. It may come as a surprise to some
that it's faster to open-code it in C than to use the x86 bit scan
instruction.

If you want to implement ffs in bitops.h, make sure you do benchmarks to
make sure that it really is faster to use the native architecture
support than it is to use some clever algorithm, as we do in the
/dev/random driver. In the case of /dev/random, the code goes one step
further and takes advantage of the fact that we know something about the
characteristics of the input arguments to speed things up even more.

- Ted

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu