From: Viro Date: Mon, 17 Mar 2014 20:01:27 +0000 (-0400) Subject: percpu: allocation size should be even X-Git-Tag: v4.14-rc1~7835^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f69fa829cb4ca062aaffee9ab9eb44484db75b1;p=platform%2Fkernel%2Flinux-rpi.git percpu: allocation size should be even 723ad1d90b56 ("percpu: store offsets instead of lengths in ->map[]") updated percpu area allocator to use the lowest bit, instead of sign, to signify whether the area is occupied and forced min align to 2; unfortunately, it forgot to force the allocation size to be even causing malfunctions for the very rare odd-sized allocations. Always force the allocations to be even sized. tj: Wrote patch description. Original-patch-by: Al Viro Signed-off-by: Tejun Heo --- diff --git a/mm/percpu.c b/mm/percpu.c index c7206d0..202e104 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -713,11 +713,14 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved) /* * We want the lowest bit of offset available for in-use/free - * indicator. + * indicator, so force >= 16bit alignment and make size even. */ if (unlikely(align < 2)) align = 2; + if (unlikely(size & 1)) + size++; + if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) { WARN(true, "illegal size (%zu) or align (%zu) for " "percpu allocation\n", size, align);