From: Andi Kleen Date: Wed, 23 Dec 2009 20:00:20 +0000 (+0100) Subject: SYSCTL: Print binary sysctl warnings (nearly) only once X-Git-Tag: v2.6.33-rc2~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4440095c8268c1a5e11577097d2be429cec036ca;p=platform%2Fkernel%2Flinux-3.10.git SYSCTL: Print binary sysctl warnings (nearly) only once When printing legacy sysctls print the warning message for each of them only once. This way there is a guarantee the syslog won't be flooded for any sane program. The original attempt at this made the tables non const and stored the flag inline. Linus suggested using a separate hash table for this, this is based on a code snippet from him. The hash implies this is not exact and can sometimes not print a new sysctl due to a hash collision, but in practice this should not be a problem I used a FNV32 hash over the binary string with a 32byte bitmap. This gives relatively little collisions when all the predefined binary sysctls are hashed: size 256 bucket length number 0: [25] 1: [67] 2: [88] 3: [47] 4: [22] 5: [6] 6: [1] The worst case is a single collision of 6 hash values. Signed-off-by: Andi Kleen --- diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 112533d..8f5d16e 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c @@ -1417,6 +1417,35 @@ static void deprecated_sysctl_warning(const int *name, int nlen) return; } +#define WARN_ONCE_HASH_BITS 8 +#define WARN_ONCE_HASH_SIZE (1<