From 90f7a60170326622e735b509cf99f14a529f570d Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 10 Sep 2016 20:34:02 +1000 Subject: [PATCH] mm-vmalloc-fix-align-value-calculation-error-fix s/get_order_long()/get_count_order_long()/ to match get_count_order() Cc: David Rientjes Cc: Johannes Weiner Cc: Minchan Kim Cc: Tejun Heo Cc: zijun_hu Signed-off-by: Andrew Morton --- include/linux/bitops.h | 34 +++++++++++++++++----------------- mm/vmalloc.c | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index c18448de2c57..711d12dcda2f 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -75,6 +75,23 @@ static inline int get_count_order(unsigned int count) return order; } +/** + * get_count_order_long - get order after rounding @l up to power of 2 + * @l: parameter + * + * The same as get_count_order() but accepts a long type parameter + * or 0 is returned if @l == 0UL + */ +static inline int get_count_order_long(unsigned long l) +{ + if (l == 0UL) + return 0; + else if (l & (l - 1UL)) + return fls_long(l); + else + return fls_long(l) - 1; +} + static __always_inline unsigned long hweight_long(unsigned long w) { return sizeof(w) == 4 ? hweight32(w) : hweight64(w); @@ -191,23 +208,6 @@ static inline unsigned fls_long(unsigned long l) return fls64(l); } -/** - * get_order_long - get order after rounding @l up to power of 2 - * @l: parameter - * - * it is same as get_count_order() but long type parameter - * or 0 is returned if @l == 0UL - */ -static inline int get_order_long(unsigned long l) -{ - if (l == 0UL) - return 0; - else if (l & (l - 1UL)) - return fls_long(l); - else - return fls_long(l) - 1; -} - /** * __ffs64 - find first set bit in a 64 bit word * @word: The 64 bit word diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 7d717f3eb288..08032de13ebe 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1360,7 +1360,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, BUG_ON(in_interrupt()); if (flags & VM_IOREMAP) - align = 1ul << clamp_t(int, get_order_long(size), + align = 1ul << clamp_t(int, get_count_order_long(size), PAGE_SHIFT, IOREMAP_MAX_ORDER); size = PAGE_ALIGN(size); -- 2.34.1