All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MN10300: Fix the PERCPU() alignment to allow for workqueues
@ 2010-10-25 22:41 David Howells
  2010-10-26  9:10 ` Tejun Heo
  2010-10-26 10:22 ` David Howells
  0 siblings, 2 replies; 63+ messages in thread
From: David Howells @ 2010-10-25 22:41 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: Tejun Heo, linux-am33-list, linux-kernel, Akira Takeuchi, Mark Salter

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;
 }


^ permalink raw reply related	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2011-03-24 18:00 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 22:41 [PATCH] MN10300: Fix the PERCPU() alignment to allow for workqueues David Howells
2010-10-26  9:10 ` Tejun Heo
2010-10-26 10:22 ` David Howells
2010-10-26 12:14   ` Tejun Heo
2010-10-26 12:27     ` Tejun Heo
2010-10-26 12:45       ` [PATCH] x86, percpu: revert commit fe8e0c25 Tejun Heo
2010-10-26 13:25         ` Ingo Molnar
2010-10-26 13:34           ` Tejun Heo
2010-10-26 13:49             ` Brian Gerst
2010-10-26 15:08               ` Linus Torvalds
2010-10-27  5:43                 ` [PATCH] x86-32: Allocate irq stacks seperate from percpu area Brian Gerst
2010-10-27  6:07                   ` Eric Dumazet
2010-10-27  9:57                     ` Peter Zijlstra
2010-10-27 13:33                       ` Eric Dumazet
2010-10-27 13:42                         ` Tejun Heo
2010-10-27 13:57                           ` Eric Dumazet
2010-10-27 14:00                             ` Tejun Heo
2010-10-27 14:24                               ` Eric Dumazet
2010-10-27 14:39                                 ` Tejun Heo
2010-10-27 14:39                                 ` Eric Dumazet
2010-10-27 14:43                                   ` Tejun Heo
2010-10-27 15:21                                     ` Eric Dumazet
2010-10-27 15:35                                       ` Tejun Heo
2010-10-27 16:07                                         ` Eric Dumazet
2010-10-27 17:33                                           ` [PATCH] numa: fix slab_node(MPOL_BIND) Eric Dumazet
2010-10-28 15:59                                             ` Linus Torvalds
2010-10-28 16:27                                               ` Eric Dumazet
2010-10-28 16:45                                               ` Mel Gorman
2010-10-28 16:55                                               ` Christoph Lameter
2010-10-28 21:07                                                 ` Andrew Morton
2010-10-29 14:55                                                   ` Christoph Lameter
2010-10-27 20:55                                         ` [PATCH] x86-32: Allocate irq stacks seperate from percpu area Eric Dumazet
2010-10-28 12:01                                           ` Tejun Heo
2010-10-28 12:30                                             ` Eric Dumazet
2010-10-28 14:40                       ` [PATCH] x86-32: NUMA irq stacks allocations Eric Dumazet
2010-10-29  6:43                         ` [tip:x86/urgent] x86-32: Restore irq stacks NUMA-aware allocations tip-bot for Eric Dumazet
2010-10-29 18:32                           ` Peter Zijlstra
2010-10-29 20:09                             ` Cyrill Gorcunov
2010-10-29 20:28                             ` Cyrill Gorcunov
2010-10-29 20:53                               ` Eric Dumazet
2010-10-29 20:59                                 ` Cyrill Gorcunov
2010-10-29 20:58                               ` Eric Dumazet
2010-10-29 21:21                                 ` Cyrill Gorcunov
2010-10-27 15:19                   ` [PATCH] x86-32: Allocate irq stacks seperate from percpu area Linus Torvalds
2010-10-27 15:30                     ` Ingo Molnar
2010-10-27 15:33                       ` Ingo Molnar
2010-10-27 15:40                         ` Tejun Heo
2010-10-27 15:43                           ` Ingo Molnar
2010-10-27 16:03                   ` [tip:x86/urgent] " tip-bot for Brian Gerst
2010-10-27 16:04                   ` [tip:x86/urgent] percpu: Remove the multi-page alignment facility tip-bot for Ingo Molnar
2010-10-26 14:06         ` [RFC PATCH] percpu: always align percpu output section to PAGE_SIZE Tejun Heo
2011-03-24  6:46           ` [Uclinux-dist-devel] " Mike Frysinger
2011-03-24  6:46             ` Mike Frysinger
2011-03-24  8:25             ` Tejun Heo
2011-03-24  8:25               ` Tejun Heo
2011-03-24  8:51               ` Tejun Heo
2011-03-24  8:51                 ` Tejun Heo
2011-03-24 13:46                 ` Mike Frysinger
2011-03-24 13:46                   ` Mike Frysinger
2011-03-24 17:51                   ` Tejun Heo
2011-03-24  8:54           ` [PATCH UPDATED] " Tejun Heo
2010-10-26 14:50   ` [PATCH] MN10300: Fix the PERCPU() alignment to allow for workqueues David Howells
2010-10-26 14:56     ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.