It causes double align requirement for __get_vm_area_node() if parameter
size is power of 2 and VM_IOREMAP is set in parameter flags, for example
size=0x10000 -> fls_long(0x10000)=17 -> align=0x20000
get_count_order_long() is implemented and used instead of fls_long() for
fixing the bug, for example
size=0x10000 -> get_count_order_long(0x10000)=16 -> align=0x10000
Link: http://lkml.kernel.org/r/fc045ecf-20fa-0722-b3ac-9a6140488fad@zoho.com
Signed-off-by: zijun_hu <zijun_hu@htc.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
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
BUG_ON(in_interrupt());
if (flags & VM_IOREMAP)
- align = 1ul << clamp_t(int, fls_long(size),
+ align = 1ul << clamp_t(int, get_order_long(size),
PAGE_SHIFT, IOREMAP_MAX_ORDER);
size = PAGE_ALIGN(size);