From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@linux-foundation.org
Cc: Tejun Heo <tj@kernel.org>,
linux-am33-list@redhat.com, linux-kernel@vger.kernel.org,
Akira Takeuchi <takeuchi.akr@jp.panasonic.com>,
Mark Salter <msalter@redhat.com>
Subject: [PATCH] workqueue: Fix alignment calculation in alloc_cwqs()
Date: Mon, 25 Oct 2010 22:27:06 +0100 [thread overview]
Message-ID: <20101025212706.27798.23957.stgit@warthog.procyon.org.uk> (raw)
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
next reply other threads:[~2010-10-25 21:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-25 21:27 David Howells [this message]
2010-10-25 21:38 ` [Linux-am33-list] " David Howells
2010-10-25 21:43 ` Linus Torvalds
2010-10-25 21:46 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101025212706.27798.23957.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-am33-list@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=msalter@redhat.com \
--cc=takeuchi.akr@jp.panasonic.com \
--cc=tj@kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®