diff options
| author | James Morris <jmorris@namei.org> | 2011-01-09 17:46:24 -0500 |
|---|---|---|
| committer | James Morris <jmorris@namei.org> | 2011-01-09 17:46:24 -0500 |
| commit | d2e7ad19229f982fc1eb731827d82ceac90abfb3 (patch) | |
| tree | 98a3741b4d4b27a48b3c7ea9babe331e539416a8 /lib | |
| parent | d03a5d888fb688c832d470b749acc5ed38e0bc1d (diff) | |
| parent | 0c21e3aaf6ae85bee804a325aa29c325209180fd (diff) | |
Merge branch 'master' into next
Conflicts:
security/smack/smack_lsm.c
Verified and added fix by Stephen Rothwell <sfr@canb.auug.org.au>
Ok'd by Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig | 3 | ||||
| -rw-r--r-- | lib/Kconfig.debug | 3 | ||||
| -rw-r--r-- | lib/Makefile | 4 | ||||
| -rw-r--r-- | lib/average.c | 61 | ||||
| -rw-r--r-- | lib/debug_locks.c | 2 | ||||
| -rw-r--r-- | lib/nlattr.c | 22 | ||||
| -rw-r--r-- | lib/percpu_counter.c | 8 | ||||
| -rw-r--r-- | lib/timerqueue.c | 107 |
8 files changed, 190 insertions, 20 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index fa9bf2c06199..3116aa631af6 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -210,4 +210,7 @@ config GENERIC_ATOMIC64 | |||
| 210 | config LRU_CACHE | 210 | config LRU_CACHE |
| 211 | tristate | 211 | tristate |
| 212 | 212 | ||
| 213 | config AVERAGE | ||
| 214 | bool | ||
| 215 | |||
| 213 | endmenu | 216 | endmenu |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 28b42b9274d0..2d05adb98401 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -173,7 +173,8 @@ config LOCKUP_DETECTOR | |||
| 173 | An NMI is generated every 60 seconds or so to check for hardlockups. | 173 | An NMI is generated every 60 seconds or so to check for hardlockups. |
| 174 | 174 | ||
| 175 | config HARDLOCKUP_DETECTOR | 175 | config HARDLOCKUP_DETECTOR |
| 176 | def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI | 176 | def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \ |
| 177 | !ARCH_HAS_NMI_WATCHDOG | ||
| 177 | 178 | ||
| 178 | config BOOTPARAM_SOFTLOCKUP_PANIC | 179 | config BOOTPARAM_SOFTLOCKUP_PANIC |
| 179 | bool "Panic (Reboot) On Soft Lockups" | 180 | bool "Panic (Reboot) On Soft Lockups" |
diff --git a/lib/Makefile b/lib/Makefile index e6a3763b8212..d7b6e30a3a1e 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -8,7 +8,7 @@ KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS)) | |||
| 8 | endif | 8 | endif |
| 9 | 9 | ||
| 10 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ | 10 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ |
| 11 | rbtree.o radix-tree.o dump_stack.o \ | 11 | rbtree.o radix-tree.o dump_stack.o timerqueue.o\ |
| 12 | idr.o int_sqrt.o extable.o prio_tree.o \ | 12 | idr.o int_sqrt.o extable.o prio_tree.o \ |
| 13 | sha1.o irq_regs.o reciprocal_div.o argv_split.o \ | 13 | sha1.o irq_regs.o reciprocal_div.o argv_split.o \ |
| 14 | proportions.o prio_heap.o ratelimit.o show_mem.o \ | 14 | proportions.o prio_heap.o ratelimit.o show_mem.o \ |
| @@ -106,6 +106,8 @@ obj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o | |||
| 106 | 106 | ||
| 107 | obj-$(CONFIG_ATOMIC64_SELFTEST) += atomic64_test.o | 107 | obj-$(CONFIG_ATOMIC64_SELFTEST) += atomic64_test.o |
| 108 | 108 | ||
| 109 | obj-$(CONFIG_AVERAGE) += average.o | ||
| 110 | |||
| 109 | hostprogs-y := gen_crc32table | 111 | hostprogs-y := gen_crc32table |
| 110 | clean-files := crc32table.h | 112 | clean-files := crc32table.h |
| 111 | 113 | ||
diff --git a/lib/average.c b/lib/average.c new file mode 100644 index 000000000000..5576c2841496 --- /dev/null +++ b/lib/average.c | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * lib/average.c | ||
| 3 | * | ||
| 4 | * This source code is licensed under the GNU General Public License, | ||
| 5 | * Version 2. See the file COPYING for more details. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <linux/module.h> | ||
| 9 | #include <linux/average.h> | ||
| 10 | #include <linux/bug.h> | ||
| 11 | #include <linux/log2.h> | ||
| 12 | |||
| 13 | /** | ||
| 14 | * DOC: Exponentially Weighted Moving Average (EWMA) | ||
| 15 | * | ||
| 16 | * These are generic functions for calculating Exponentially Weighted Moving | ||
| 17 | * Averages (EWMA). We keep a structure with the EWMA parameters and a scaled | ||
| 18 | * up internal representation of the average value to prevent rounding errors. | ||
| 19 | * The factor for scaling up and the exponential weight (or decay rate) have to | ||
| 20 | * be specified thru the init fuction. The structure should not be accessed | ||
| 21 | * directly but only thru the helper functions. | ||
| 22 | */ | ||
| 23 | |||
| 24 | /** | ||
| 25 | * ewma_init() - Initialize EWMA parameters | ||
| 26 | * @avg: Average structure | ||
| 27 | * @factor: Factor to use for the scaled up internal value. The maximum value | ||
| 28 | * of averages can be ULONG_MAX/(factor*weight). For performance reasons | ||
| 29 | * factor has to be a power of 2. | ||
| 30 | * @weight: Exponential weight, or decay rate. This defines how fast the | ||
| 31 | * influence of older values decreases. For performance reasons weight has | ||
| 32 | * to be a power of 2. | ||
| 33 | * | ||
| 34 | * Initialize the EWMA parameters for a given struct ewma @avg. | ||
| 35 | */ | ||
| 36 | void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight) | ||
| 37 | { | ||
| 38 | WARN_ON(!is_power_of_2(weight) || !is_power_of_2(factor)); | ||
| 39 | |||
| 40 | avg->weight = ilog2(weight); | ||
| 41 | avg->factor = ilog2(factor); | ||
| 42 | avg->internal = 0; | ||
| 43 | } | ||
| 44 | EXPORT_SYMBOL(ewma_init); | ||
| 45 | |||
| 46 | /** | ||
| 47 | * ewma_add() - Exponentially weighted moving average (EWMA) | ||
| 48 | * @avg: Average structure | ||
| 49 | * @val: Current value | ||
| 50 | * | ||
| 51 | * Add a sample to the average. | ||
| 52 | */ | ||
| 53 | struct ewma *ewma_add(struct ewma *avg, unsigned long val) | ||
| 54 | { | ||
| 55 | avg->internal = avg->internal ? | ||
| 56 | (((avg->internal << avg->weight) - avg->internal) + | ||
| 57 | (val << avg->factor)) >> avg->weight : | ||
| 58 | (val << avg->factor); | ||
| 59 | return avg; | ||
| 60 | } | ||
| 61 | EXPORT_SYMBOL(ewma_add); | ||
diff --git a/lib/debug_locks.c b/lib/debug_locks.c index 5bf0020b9248..b1c177307677 100644 --- a/lib/debug_locks.c +++ b/lib/debug_locks.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> | 9 | * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> |
| 10 | */ | 10 | */ |
| 11 | #include <linux/kernel.h> | ||
| 12 | #include <linux/rwsem.h> | 11 | #include <linux/rwsem.h> |
| 13 | #include <linux/mutex.h> | 12 | #include <linux/mutex.h> |
| 14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| @@ -39,7 +38,6 @@ int debug_locks_off(void) | |||
| 39 | { | 38 | { |
| 40 | if (__debug_locks_off()) { | 39 | if (__debug_locks_off()) { |
| 41 | if (!debug_locks_silent) { | 40 | if (!debug_locks_silent) { |
| 42 | oops_in_progress = 1; | ||
| 43 | console_verbose(); | 41 | console_verbose(); |
| 44 | return 1; | 42 | return 1; |
| 45 | } | 43 | } |
diff --git a/lib/nlattr.c b/lib/nlattr.c index c4706eb98d3d..00e8a02681a6 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | #include <net/netlink.h> | 16 | #include <net/netlink.h> |
| 17 | 17 | ||
| 18 | static u16 nla_attr_minlen[NLA_TYPE_MAX+1] __read_mostly = { | 18 | static const u16 nla_attr_minlen[NLA_TYPE_MAX+1] = { |
| 19 | [NLA_U8] = sizeof(u8), | 19 | [NLA_U8] = sizeof(u8), |
| 20 | [NLA_U16] = sizeof(u16), | 20 | [NLA_U16] = sizeof(u16), |
| 21 | [NLA_U32] = sizeof(u32), | 21 | [NLA_U32] = sizeof(u32), |
| @@ -23,7 +23,7 @@ static u16 nla_attr_minlen[NLA_TYPE_MAX+1] __read_mostly = { | |||
| 23 | [NLA_NESTED] = NLA_HDRLEN, | 23 | [NLA_NESTED] = NLA_HDRLEN, |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | static int validate_nla(struct nlattr *nla, int maxtype, | 26 | static int validate_nla(const struct nlattr *nla, int maxtype, |
| 27 | const struct nla_policy *policy) | 27 | const struct nla_policy *policy) |
| 28 | { | 28 | { |
| 29 | const struct nla_policy *pt; | 29 | const struct nla_policy *pt; |
| @@ -115,10 +115,10 @@ static int validate_nla(struct nlattr *nla, int maxtype, | |||
| 115 | * | 115 | * |
| 116 | * Returns 0 on success or a negative error code. | 116 | * Returns 0 on success or a negative error code. |
| 117 | */ | 117 | */ |
| 118 | int nla_validate(struct nlattr *head, int len, int maxtype, | 118 | int nla_validate(const struct nlattr *head, int len, int maxtype, |
| 119 | const struct nla_policy *policy) | 119 | const struct nla_policy *policy) |
| 120 | { | 120 | { |
| 121 | struct nlattr *nla; | 121 | const struct nlattr *nla; |
| 122 | int rem, err; | 122 | int rem, err; |
| 123 | 123 | ||
| 124 | nla_for_each_attr(nla, head, len, rem) { | 124 | nla_for_each_attr(nla, head, len, rem) { |
| @@ -173,10 +173,10 @@ nla_policy_len(const struct nla_policy *p, int n) | |||
| 173 | * | 173 | * |
| 174 | * Returns 0 on success or a negative error code. | 174 | * Returns 0 on success or a negative error code. |
| 175 | */ | 175 | */ |
| 176 | int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, | 176 | int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head, |
| 177 | const struct nla_policy *policy) | 177 | int len, const struct nla_policy *policy) |
| 178 | { | 178 | { |
| 179 | struct nlattr *nla; | 179 | const struct nlattr *nla; |
| 180 | int rem, err; | 180 | int rem, err; |
| 181 | 181 | ||
| 182 | memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); | 182 | memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); |
| @@ -191,7 +191,7 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, | |||
| 191 | goto errout; | 191 | goto errout; |
| 192 | } | ||
