lib: Add a simple prime number generator

Prime numbers are interesting for testing components that use multiplies
and divides, such as testing DRM's struct drm_mm alignment computations.

v2: Move to lib/, add selftest
v3: Fix initial constants (exclude 0/1 from being primes)
v4: More RCU markup to keep 0day/sparse happy
v5: Fix RCU unwind on module exit, add to kselftests
v6: Tidy computation of bitmap size
v7: for_each_prime_number_from()
v8: Compose small-primes using BIT() for easier verification
v9: Move rcu dance entirely into callers.
v10: Improve quote for Betrand's Postulate (aka Chebyshev's theorem)

Signed-off-by: Chris Wilson <[email protected]>
Cc: Lukas Wunner <[email protected]>
Reviewed-by: Joonas Lahtinen <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
This commit is contained in:
Chris Wilson 2016-12-22 14:45:14 +00:00 • committed by Daniel Vetter
commit cf4a7207b1
5 changed files with 375 additions and 0 deletions

View file

@ -550,4 +550,11 @@ config STACKDEPOT
config SBITMAP
bool
config PRIME_NUMBERS
tristate "Prime number generator"
default n
help
Provides a helper module to generate prime numbers. Useful for writing
test code, especially when checking multiplication and divison.
endmenu