All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: David Miller <davem@davemloft.net>,
	sparclinux@vger.kernel.org, tj@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [BUG] percpu misaligned allocation
Date: Thu, 18 Mar 2010 16:56:16 +0000	[thread overview]
Message-ID: <20100318165613.GA5103@nowhere> (raw)
In-Reply-To: <4BA1CA91.2060004@cn.fujitsu.com>

On Thu, Mar 18, 2010 at 02:39:13PM +0800, Li Zefan wrote:
> David Miller wrote:
> > From: Frederic Weisbecker <fweisbec@gmail.com>
> > Date: Thu, 18 Mar 2010 05:49:33 +0100
> > 
> >> 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.
> > 
> > Thanks I'll take a look at this.
> > 
> > RAW locks (both rwlocks and spinlocks) on sparc64 are 4-bytes
> > in size, maybe some piece of code is assuming that locks
> > are cpu word sized.
> > 
> > Where is perf_trace_lock_acquire() I can't find it in Linus's
> > tree?  Does it get created by some crazy macro expansion?
> > 
> 
> Yes, it's expanded by some crazy macro in include/trace/ftrace.h..
> 
> In linus' tree, it's called ftrace_profile_lock_acquire(), and it's
> renamed to perf_trace_lock_acquire() in -tip tree by commit
> 97d5a22005f38057b4bc0d95f81cd26510268794.
> 
> #undef DECLARE_EVENT_CLASS
> #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)  \
> static notrace void                                                     \
> ftrace_profile_templ_##call(struct ftrace_event_call *event_call,       \
>                             proto)                                      \
> {                                                                       \
>         struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
>         struct ftrace_raw_##call *entry;                                \
>         u64 __addr = 0, __count = 1;                                    \
>         unsigned long irq_flags;                                        \
>         int __entry_size;                                               \
>         int __data_size;                                                \
>         int rctx;                                                       \
>                                                                         \
> ...
> }


Yeah indeed. The problem happens in Linus's tree and -tip tree as well,
it's just that I debugged it in -tip and there has been a naming change
inside, I forgot about that. So in mainline the problem happens in
ftrace_profile_templ_lock_acquire (macro generated above).

Thanks.


WARNING: multiple messages have this Message-ID (diff)
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: David Miller <davem@davemloft.net>,
	sparclinux@vger.kernel.org, tj@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [BUG] percpu misaligned allocation
Date: Thu, 18 Mar 2010 17:56:16 +0100	[thread overview]
Message-ID: <20100318165613.GA5103@nowhere> (raw)
In-Reply-To: <4BA1CA91.2060004@cn.fujitsu.com>

On Thu, Mar 18, 2010 at 02:39:13PM +0800, Li Zefan wrote:
> David Miller wrote:
> > From: Frederic Weisbecker <fweisbec@gmail.com>
> > Date: Thu, 18 Mar 2010 05:49:33 +0100
> > 
> >> 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.
> > 
> > Thanks I'll take a look at this.
> > 
> > RAW locks (both rwlocks and spinlocks) on sparc64 are 4-bytes
> > in size, maybe some piece of code is assuming that locks
> > are cpu word sized.
> > 
> > Where is perf_trace_lock_acquire() I can't find it in Linus's
> > tree?  Does it get created by some crazy macro expansion?
> > 
> 
> Yes, it's expanded by some crazy macro in include/trace/ftrace.h..
> 
> In linus' tree, it's called ftrace_profile_lock_acquire(), and it's
> renamed to perf_trace_lock_acquire() in -tip tree by commit
> 97d5a22005f38057b4bc0d95f81cd26510268794.
> 
> #undef DECLARE_EVENT_CLASS
> #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)  \
> static notrace void                                                     \
> ftrace_profile_templ_##call(struct ftrace_event_call *event_call,       \
>                             proto)                                      \
> {                                                                       \
>         struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
>         struct ftrace_raw_##call *entry;                                \
>         u64 __addr = 0, __count = 1;                                    \
>         unsigned long irq_flags;                                        \
>         int __entry_size;                                               \
>         int __data_size;                                                \
>         int rctx;                                                       \
>                                                                         \
> ...
> }


Yeah indeed. The problem happens in Linus's tree and -tip tree as well,
it's just that I debugged it in -tip and there has been a naming change
inside, I forgot about that. So in mainline the problem happens in
ftrace_profile_templ_lock_acquire (macro generated above).

Thanks.


  reply	other threads:[~2010-03-18 16:56 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 [this message]
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
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=20100318165613.GA5103@nowhere \
    --to=fweisbec@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --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.