lkml.org 
[lkml]   [2010]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] workqueue: Fix alignment calculation in alloc_cwqs()
From
Date
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));

which is wrong. __alignof__() returns its value in bytes, but:

1 << WORK_STRUCT_FLAG_BITS

returns the value in bits. It needs dividing by the number of bits in a byte.

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

kernel/workqueue.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 30acdb7..e29ebd4 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2766,8 +2766,9 @@ static int alloc_cwqs(struct workqueue_struct *wq)
* unsigned long long.
*/
const size_t size = sizeof(struct cpu_workqueue_struct);
- const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
- __alignof__(unsigned long long));
+ const size_t align =
+ max_t(size_t, 1 << (WORK_STRUCT_FLAG_BITS - BITS_PER_BYTE),
+ __alignof__(unsigned long long));
#ifdef CONFIG_SMP
bool percpu = !(wq->flags & WQ_UNBOUND);
#else


\
 
 \ /
  Last update: 2010-10-25 23:29    [W:0.095 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site