public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	Alan.Brunelle@hp.com, Ingo Molnar <mingo@elte.hu>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] Fix blktrace unaligned memory access
Date: Fri, 10 Jul 2009 11:36:01 +0200	[thread overview]
Message-ID: <20090710093601.GF23611@kernel.dk> (raw)
In-Reply-To: <4A570A34.5090002@cn.fujitsu.com>

On Fri, Jul 10 2009, Li Zefan wrote:
> Jens Axboe wrote:
> > On Fri, Jul 10 2009, Li Zefan wrote:
> >> Jens Axboe wrote:
> >>> Hi,
> >>>
> >>> It seems that relay_reserve() (or the ring_buffer_event_data(), that one
> >>> still needs some love) can return unaligned memory, there's no way
> >>> around that when you have pdu lengths that aren't a nice size. This can
> >>> cause unaligned access warnings on platforms that care about alignment.
> >>>
> >> Seems relay_reserve() does nothing for alignment..On the other hand,
> >> ring_buffer_event_data() returns a ptr which is 32bit-aligned, but
> >> this still means it can cause unaligned accesses on 64bits arch, while
> >> I think it's fixable in ring buffer, it's certainly not an easy job.
> > 
> > Right, it's a bit nasty...
> > 
> 
> Lai Jiangshan noticed this issue long ago and had some ideas in mind
> how to fix ring buffer, but never try it out for it will probably be
> frustrating..
> 
> >>> This is an RFC, perhaps we can fix this in some other way. This one takes
> >>> the simple approach, use an on-stack copy and memcpy() that to the
> >>> destination.
> >>>
> >> or get_unaligned() ?
> > 
> > put_unaligned(), you mean? The big question is then which is faster, using
> > put_unaligned() or doing the memcpy() of the structure...
> > 
> 
> Ah, I meant put_unaligned().
> 
> I think the patch you posted can be a workaround at least for now, and
> can be improved by detecting HAVE_EFFICIENT_UNALIGNED_ACCESS

We either do one or the other, I don't want to clutter the code with
both methods implemented and some ifdef checking and deciding. I'll
check the unaligned put here on x86/ppc/sparc and then decide which one
is faster.

-- 
Jens Axboe


  reply	other threads:[~2009-07-10  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10  7:53 [PATCH] Fix blktrace unaligned memory access Jens Axboe
2009-07-10  9:07 ` Li Zefan
2009-07-10  9:13   ` Jens Axboe
2009-07-10  9:30     ` Li Zefan
2009-07-10  9:36       ` Jens Axboe [this message]
2009-07-14 17:35         ` Steven Rostedt

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=20090710093601.GF23611@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=Alan.Brunelle@hp.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.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