From: Frederic Weisbecker <fweisbec@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Sparc <sparclinux@vger.kernel.org>,
David Miller <davem@davemloft.net>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] percpu misaligned allocation
Date: Thu, 18 Mar 2010 19:50:26 +0000 [thread overview]
Message-ID: <20100318195023.GE5103@nowhere> (raw)
In-Reply-To: <4BA1F2BA.30604@kernel.org>
On Thu, Mar 18, 2010 at 06:30:34PM +0900, Tejun Heo wrote:
> Hello,
>
> On 03/18/2010 01:49 PM, Frederic Weisbecker wrote:
> > Hi,
> >
> > While using the lock events through perf in a sparc box, I can see
> > the following message repeated many times:
> >
> > Kernel unaligned access at TPC[49357c] perf_trace_lock_acquire+0xb4/0x180
> >
> > It actually hangs the box as the messages are sent to a serial console.
> >
> > When used with perf, the trace events use a per cpu buffer allocated
> > in kernel/trace/trace_event_perf.c, and the allocation appears to return
> > a misaligned percpu pointer. It is aligned to 4 while it seems it
> > requires to be aligned to 8.
>
> Does this fix the problem?
>
> diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c
> index c1cc3ab..d3f7d1b 100644
> --- a/kernel/trace/trace_event_profile.c
> +++ b/kernel/trace/trace_event_profile.c
> @@ -27,13 +27,15 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
> return 0;
>
> if (!total_profile_count) {
> - buf = (char *)alloc_percpu(perf_trace_t);
> + buf = (char *)__alloc_percpu(sizeof(perf_trace_t),
> + __alignof__(unsigned long));
> if (!buf)
> goto fail_buf;
>
> rcu_assign_pointer(perf_trace_buf, buf);
>
> - buf = (char *)alloc_percpu(perf_trace_t);
> + buf = (char *)__alloc_percpu(sizeof(perf_trace_t),
> + __alignof__(unsigned long));
> if (!buf)
> goto fail_buf_nmi;
Yep, it does the trick.
In case you test, I have two other misalignments, one is in
perf_trace_buf_prepare but it is my bad and it is nothing
related to percpu. I'm going to fix it.
Another is in the ring buffer and Steve has a pending fix.
Thanks.
WARNING: multiple messages have this Message-ID (diff)
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Sparc <sparclinux@vger.kernel.org>,
David Miller <davem@davemloft.net>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] percpu misaligned allocation
Date: Thu, 18 Mar 2010 20:50:26 +0100 [thread overview]
Message-ID: <20100318195023.GE5103@nowhere> (raw)
In-Reply-To: <4BA1F2BA.30604@kernel.org>
On Thu, Mar 18, 2010 at 06:30:34PM +0900, Tejun Heo wrote:
> Hello,
>
> On 03/18/2010 01:49 PM, Frederic Weisbecker wrote:
> > Hi,
> >
> > While using the lock events through perf in a sparc box, I can see
> > the following message repeated many times:
> >
> > Kernel unaligned access at TPC[49357c] perf_trace_lock_acquire+0xb4/0x180
> >
> > It actually hangs the box as the messages are sent to a serial console.
> >
> > When used with perf, the trace events use a per cpu buffer allocated
> > in kernel/trace/trace_event_perf.c, and the allocation appears to return
> > a misaligned percpu pointer. It is aligned to 4 while it seems it
> > requires to be aligned to 8.
>
> Does this fix the problem?
>
> diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c
> index c1cc3ab..d3f7d1b 100644
> --- a/kernel/trace/trace_event_profile.c
> +++ b/kernel/trace/trace_event_profile.c
> @@ -27,13 +27,15 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
> return 0;
>
> if (!total_profile_count) {
> - buf = (char *)alloc_percpu(perf_trace_t);
> + buf = (char *)__alloc_percpu(sizeof(perf_trace_t),
> + __alignof__(unsigned long));
> if (!buf)
> goto fail_buf;
>
> rcu_assign_pointer(perf_trace_buf, buf);
>
> - buf = (char *)alloc_percpu(perf_trace_t);
> + buf = (char *)__alloc_percpu(sizeof(perf_trace_t),
> + __alignof__(unsigned long));
> if (!buf)
> goto fail_buf_nmi;
Yep, it does the trick.
In case you test, I have two other misalignments, one is in
perf_trace_buf_prepare but it is my bad and it is nothing
related to percpu. I'm going to fix it.
Another is in the ring buffer and Steve has a pending fix.
Thanks.
next prev parent reply other threads:[~2010-03-18 19:50 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 4:49 [BUG] percpu misaligned allocation Frederic Weisbecker
2010-03-18 4:49 ` Frederic Weisbecker
2010-03-18 6:26 ` David Miller
2010-03-18 6:26 ` David Miller
2010-03-18 6:28 ` David Miller
2010-03-18 6:28 ` David Miller
2010-03-18 6:36 ` Li Zefan
2010-03-18 6:36 ` Li Zefan
2010-03-18 6:39 ` Li Zefan
2010-03-18 6:39 ` Li Zefan
2010-03-18 16:56 ` Frederic Weisbecker
2010-03-18 16:56 ` Frederic Weisbecker
2010-03-18 9:30 ` Tejun Heo
2010-03-18 9:30 ` Tejun Heo
2010-03-18 19:50 ` Frederic Weisbecker [this message]
2010-03-18 19:50 ` Frederic Weisbecker
2010-03-19 0:54 ` David Miller
2010-03-19 0:54 ` David Miller
2010-03-19 1:31 ` Frederic Weisbecker
2010-03-19 1:31 ` Frederic Weisbecker
2010-03-19 1:51 ` Tejun Heo
2010-03-19 1:51 ` Tejun Heo
2010-03-19 1:57 ` David Miller
2010-03-19 1:57 ` David Miller
2010-03-19 2:18 ` Tejun Heo
2010-03-19 2:18 ` Tejun Heo
2010-03-19 2:30 ` Frederic Weisbecker
2010-03-19 2:30 ` Frederic Weisbecker
2010-03-19 3:02 ` David Miller
2010-03-19 3:02 ` David Miller
2010-03-19 15:48 ` Richard Kennedy
2010-03-24 20:54 ` Maciej Rutecki
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=20100318195023.GE5103@nowhere \
--to=fweisbec@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=tj@kernel.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 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.