aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViro <viro@ZenIV.linux.org.uk>2014-03-17 16:01:27 -0400
committerTejun Heo <tj@kernel.org>2014-03-17 16:10:29 -0400
commit2f69fa829cb4ca062aaffee9ab9eb44484db75b1 (patch)
treea2bc2cf26e8e7907a3270aed8820c8f7c3085d74
parent3d331ad74fa33f0b14a46cf0de8358012d3c1500 (diff)
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 <viro@zeniv.linux.org.uk> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--mm/percpu.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mm/percpu.c b/mm/percpu.c
index c7206d06f8de..202e104df8a7 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)
713 713
714 /* 714 /*
715 * We want the lowest bit of offset available for in-use/free 715 * We want the lowest bit of offset available for in-use/free
716 * indicator. 716 * indicator, so force >= 16bit alignment and make size even.
717 */ 717 */
718 if (unlikely(align < 2)) 718 if (unlikely(align < 2))
719 align = 2; 719 align = 2;
720 720
721 if (unlikely(size & 1))
722 size++;
723
721 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) { 724 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) {
722 WARN(true, "illegal size (%zu) or align (%zu) for " 725 WARN(true, "illegal size (%zu) or align (%zu) for "
723 "percpu allocation\n", size, align); 726 "percpu allocation\n", size, align);