[PATCH] MN10300: Fix the PERCPU() alignment to allow for workqueues

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Howells
Date: Monday, October 25, 2010 - 3:41 pm

In the MN10300 arch, we occasionally see an assertion being tripped in
alloc_cwqs() at the following line:

        /* just in case, make sure it's actually aligned */
  --->  BUG_ON(!IS_ALIGNED(wq->cpu_wq.v, align));
        return wq->cpu_wq.v ? 0 : -ENOMEM;

The values are:

        wa->cpu_wq.v => 0x902776e0
        align => 0x100

and align is calculated by the following:

        const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
                                   __alignof__(unsigned long long));

This is because the pointer in question (wq->cpu_wq.v) loses some of its lower
bits to control flags, and so the object it points to must be sufficiently
aligned to avoid the need to use those bits for pointing to things.

Currently, 4 control bits and 4 colour bits are used in normal circumstances,
plus a debugging bit if debugging is set.  This requires the
cpu_workqueue_struct struct to be at least 256 bytes aligned (or 512 bytes
aligned with debugging).

PERCPU() alignment on MN13000, however, is only 32 bytes as set in
vmlinux.lds.S.  So we set this to PAGE_SIZE (4096) to match most other arches
and stick a comment in alloc_cwqs() for anyone else who triggers the assertion.

Reported-by: Akira Takeuchi <takeuchi.akr@jp.panasonic.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mark Salter <msalter@redhat.com>
cc: Tejun Heo <tj@kernel.org>
---

 arch/mn10300/kernel/vmlinux.lds.S |    2 +-
 kernel/workqueue.c                |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 10549dc..febbeee 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -70,7 +70,7 @@ SECTIONS
 	.exit.text : { EXIT_TEXT; }
 	.exit.data : { EXIT_DATA; }
 
-  PERCPU(32)
+  PERCPU(PAGE_SIZE)
   . = ALIGN(PAGE_SIZE);
   __init_end = .;
   /* freed after init ends here */
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 30acdb7..e5ff2cb 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2791,7 +2791,9 @@ static int alloc_cwqs(struct workqueue_struct *wq)
 		}
 	}
 
-	/* just in case, make sure it's actually aligned */
+	/* just in case, make sure it's actually aligned
+	 * - this is affected by PERCPU() alignment in vmlinux.lds.S
+	 */
 	BUG_ON(!IS_ALIGNED(wq->cpu_wq.v, align));
 	return wq->cpu_wq.v ? 0 : -ENOMEM;
 }

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] MN10300: Fix the PERCPU() alignment to allow for w ..., David Howells, (Mon Oct 25, 3:41 pm)
[PATCH] x86, percpu: revert commit fe8e0c25, Tejun Heo, (Tue Oct 26, 5:45 am)
Re: [PATCH] x86, percpu: revert commit fe8e0c25, Ingo Molnar, (Tue Oct 26, 6:25 am)
Re: [PATCH] x86, percpu: revert commit fe8e0c25, Tejun Heo, (Tue Oct 26, 6:34 am)
Re: [PATCH] x86, percpu: revert commit fe8e0c25, Brian Gerst, (Tue Oct 26, 6:49 am)
Re: [PATCH] x86, percpu: revert commit fe8e0c25, Linus Torvalds, (Tue Oct 26, 8:08 am)
[tip:x86/urgent] x86-32: Allocate irq stacks seperate from ..., tip-bot for Brian Gerst, (Wed Oct 27, 9:03 am)
[tip:x86/urgent] percpu: Remove the multi-page alignment f ..., tip-bot for Ingo Molnar, (Wed Oct 27, 9:04 am)
[PATCH] numa: fix slab_node(MPOL_BIND), Eric Dumazet, (Wed Oct 27, 10:33 am)
[PATCH] x86-32: NUMA irq stacks allocations, Eric Dumazet, (Thu Oct 28, 7:40 am)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Linus Torvalds, (Thu Oct 28, 8:59 am)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Eric Dumazet, (Thu Oct 28, 9:27 am)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Mel Gorman, (Thu Oct 28, 9:45 am)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Christoph Lameter, (Thu Oct 28, 9:55 am)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Andrew Morton, (Thu Oct 28, 2:07 pm)
[tip:x86/urgent] x86-32: Restore irq stacks NUMA-aware all ..., tip-bot for Eric Dumazet, (Thu Oct 28, 11:43 pm)
Re: [PATCH] numa: fix slab_node(MPOL_BIND), Christoph Lameter, (Fri Oct 29, 7:55 am)