diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-24 16:01:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-24 16:01:29 -0500 |
commit | 0b5e2588d8238b03df66c4e74769fd03ad84f694 (patch) | |
tree | 7a7baf0d8309a3473bf265d1354bb756d65a4a02 /kernel | |
parent | 6067d7e4f05e5c08617cf95032867d892035e581 (diff) | |
parent | 443c6f145de813518c36ac6b6e4e08d9445337e7 (diff) |
Merge branch 'sysctl' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc-2.6
* 'sysctl' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc-2.6:
SYSCTL: Add a mutex to the page_alloc zone order sysctl
SYSCTL: Print binary sysctl warnings (nearly) only once
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sysctl_binary.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 112533d5fc0..8f5d16e0707 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) | |||
1417 | return; | 1417 | return; |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | #define WARN_ONCE_HASH_BITS 8 | ||
1421 | #define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS) | ||
1422 | |||
1423 | static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE); | ||
1424 | |||
1425 | #define FNV32_OFFSET 2166136261U | ||
1426 | #define FNV32_PRIME 0x01000193 | ||
1427 | |||
1428 | /* | ||
1429 | * Print each legacy sysctl (approximately) only once. | ||
1430 | * To avoid making the tables non-const use a external | ||
1431 | * hash-table instead. | ||
1432 | * Worst case hash collision: 6, but very rarely. | ||
1433 | * NOTE! We don't use the SMP-safe bit tests. We simply | ||
1434 | * don't care enough. | ||
1435 | */ | ||
1436 | static void warn_on_bintable(const int *name, int nlen) | ||
1437 | { | ||
1438 | int i; | ||
1439 | u32 hash = FNV32_OFFSET; | ||
1440 | |||
1441 | for (i = 0; i < nlen; i++) | ||
1442 | hash = (hash ^ name[i]) * FNV32_PRIME; | ||
1443 | hash %= WARN_ONCE_HASH_SIZE; | ||
1444 | if (__test_and_set_bit(hash, warn_once_bitmap)) | ||
1445 | return; | ||
1446 | deprecated_sysctl_warning(name, nlen); | ||
1447 | } | ||
1448 | |||
1420 | static ssize_t do_sysctl(int __user *args_name, int nlen, | 1449 | static ssize_t do_sysctl(int __user *args_name, int nlen, |
1421 | void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) | 1450 | void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) |
1422 | { | 1451 | { |
@@ -1431,7 +1460,7 @@ static ssize_t do_sysctl(int __user *args_name, int nlen, | |||
1431 | if (get_user(name[i], args_name + i)) | 1460 | if (get_user(name[i], args_name + i)) |
1432 | return -EFAULT; | 1461 | return -EFAULT; |
1433 | 1462 | ||
1434 | deprecated_sysctl_warning(name, nlen); | 1463 | warn_on_bintable(name, nlen); |
1435 | 1464 | ||
1436 | return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen); | 1465 | return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen); |
1437 | } | 1466 | } |