Add stable@vger.kernel.org annotations
[ext4-patch-queue.git] / simplify-definition-of-NR_BG_LOCKS
blobae732ed0ee825e190b0423a6aec2b23599914bab
1 blockgroup_lock.h: simplify definition of NR_BG_LOCKS
3 From: Eric Biggers <ebiggers@google.com>
5 We can use ilog2() to more easily produce the desired NR_BG_LOCKS.  This
6 works because ilog2() is evaluated at compile-time when its argument is
7 a compile-time constant.
9 I did not change the chosen NR_BG_LOCKS values.
11 Signed-off-by: Eric Biggers <ebiggers@google.com>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 Reviewed-by: Andreas Dilger <adilger@dilger.ca>
14 diff --git a/include/linux/blockgroup_lock.h b/include/linux/blockgroup_lock.h
15 index 61b583d..225bdb7 100644
16 --- a/include/linux/blockgroup_lock.h
17 +++ b/include/linux/blockgroup_lock.h
18 @@ -10,28 +10,10 @@
19  #include <linux/cache.h>
21  #ifdef CONFIG_SMP
23 -/*
24 - * We want a power-of-two.  Is there a better way than this?
25 - */
27 -#if NR_CPUS >= 32
28 -#define NR_BG_LOCKS    128
29 -#elif NR_CPUS >= 16
30 -#define NR_BG_LOCKS    64
31 -#elif NR_CPUS >= 8
32 -#define NR_BG_LOCKS    32
33 -#elif NR_CPUS >= 4
34 -#define NR_BG_LOCKS    16
35 -#elif NR_CPUS >= 2
36 -#define NR_BG_LOCKS    8
37 +#define NR_BG_LOCKS    (4 << ilog2(NR_CPUS < 32 ? NR_CPUS : 32))
38  #else
39 -#define NR_BG_LOCKS    4
40 -#endif
42 -#else  /* CONFIG_SMP */
43  #define NR_BG_LOCKS    1
44 -#endif /* CONFIG_SMP */
45 +#endif
47  struct bgl_lock {
48         spinlock_t lock;
49 -- 
50 2.8.0.rc3.226.g39d4020