Linux Container Development
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	containers@lists.osdl.org,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 2/5] ftrace: use code patching for ftrace graph tracer
Date: Wed, 26 Nov 2008 00:27:04 -0800	[thread overview]
Message-ID: <1227688024.5511.56.camel@brick> (raw)
In-Reply-To: <20081126000430.5c19e189.akpm@linux-foundation.org>

On Wed, 2008-11-26 at 00:04 -0800, Andrew Morton wrote:
> On Tue, 25 Nov 2008 22:52:29 -0800 Harvey Harrison <harvey.harrison@gmail.com> wrote:
> > > > +	if (code[0] != 0xe9 || old_offset != *(int *)(&code[1]))
> > > 
> > > erk.  I suspect that there's a nicer way of doing this amongst our
> > > forest of get_unaligned_foo() interfaces.  Harvey will know.
> > > 
> > 
> > if (code[0] != 0xe9 || old_offset != get_unaligned((int *)(&code[1])))
> 
> urgh, OK, that didn't really improve anything except to document
> something which was already rather obvious.
> 

Yeah, it really isn't that great.  It could be somewhat nicer if we had
the API for host-endian taking void and being explicit about the size:

if (code[0] != 0xe9 || old_offset != load32_noalign(&code[1]))

This is similar to the new API in -mm load_le32_noalign, but I
don't think it would be worth load_u32_noalign...load32 should
be enough.

> > > > +		return -EINVAL;
> > > > +
> > > > +	*(int *)(&code[1]) = new_offset;
> > > 
> > > Might be able to use put_unaligned_foo() here.
> > > 
> > 
> > 	put_unaligned(new_offset, (int *)(&code[1]));
> > 

In a similar vein to above, this becomes:

	store32_noalign(&code[1], new_offset);

I rather like this as it would allow most (if not all) of the figure
out what size based on pointer type versions to be chucked.

Turns out all the pieces are there in -mm that the patch is pretty
trivial (not for application, just a heads-up):

 include/asm-generic/unaligned.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
index d2f3998..5a055f7 100644
--- a/include/asm-generic/unaligned.h
+++ b/include/asm-generic/unaligned.h
@@ -343,9 +343,23 @@ extern void __bad_unaligned_access_size(void);
 #ifdef __LITTLE_ENDIAN
 # define get_unaligned __get_unaligned_le
 # define put_unaligned __put_unaligned_le
+
+# define load16_noalign(p) load_le16_noalign((void *)(p))
+# define load32_noalign(p) load_le32_noalign((void *)(p))
+# define load64_noalign(p) load_le64_noalign((void *)(p))
+# define store16_noalign(p, val) store_le16_noalign((void *)(p), (val))
+# define store32_noalign(p, val) store_le32_noalign((void *)(p), (val))
+# define store64_noalign(p, val) store_le64_noalign((void *)(p), (val))
 #else
 # define get_unaligned __get_unaligned_be
 # define put_unaligned __put_unaligned_be
+
+# define load16_noalign(p) load_be16_noalign((void *)(p))
+# define load32_noalign(p) load_be32_noalign((void *)(p))
+# define load64_noalign(p) load_be64_noalign((void *)(p))
+# define store16_noalign(p, val) store_be16_noalign((void *)(p), (val))
+# define store32_noalign(p, val) store_be32_noalign((void *)(p), (val))
+# define store64_noalign(p, val) store_be64_noalign((void *)(p), (val))
 #endif
 
 #endif /* _ASM_GENERIC_UNALIGNED_H */
-- 
1.6.0.4.1044.g77718

  reply	other threads:[~2008-11-26  8:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-26  5:16 [PATCH 0/5] ftrace: rebase patches on top of tip/master + some extras Steven Rostedt
2008-11-26  5:16 ` [PATCH 1/5] ftrace: add function tracing to single thread Steven Rostedt
2008-11-26  5:29   ` Andrew Morton
2008-11-26 16:43     ` Steven Rostedt
2008-11-26  6:42   ` Eric W. Biederman
2008-11-26  6:54     ` Ingo Molnar
2008-11-26 16:55       ` Steven Rostedt
2008-11-26 16:54     ` Steven Rostedt
2008-11-26  5:16 ` [PATCH 2/5] ftrace: use code patching for ftrace graph tracer Steven Rostedt
     [not found]   ` <20081126051709.774546196-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>
2008-11-26  5:35     ` Andrew Morton
2008-11-26  6:52       ` Harvey Harrison
2008-11-26  8:04         ` Andrew Morton
2008-11-26  8:27           ` Harvey Harrison [this message]
2008-11-26  8:35             ` Andrew Morton
     [not found]               ` <20081126003553.12d38150.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2008-11-26  8:44                 ` Harvey Harrison
2008-11-26  9:05                   ` Andrew Morton
2008-11-26  9:22                     ` Harvey Harrison
2008-11-26 16:46       ` Steven Rostedt
2008-11-26 18:02         ` Andrew Morton
2008-11-26 18:06           ` Harvey Harrison
2008-11-26  5:16 ` [PATCH 3/5] ftrace: let function tracing and function return run together Steven Rostedt
2008-11-26  5:16 ` [PATCH 4/5] ftrace: add thread comm to function graph tracer Steven Rostedt
2008-11-26  5:37   ` Andrew Morton
2008-11-26 16:48     ` Steven Rostedt
2008-11-26 18:04       ` Andrew Morton
2008-11-26  5:16 ` [PATCH 5/5] ftrace: add cpu annotation for " Steven Rostedt
2008-11-26  5:39   ` Andrew Morton
2008-11-26  5:47     ` Ingo Molnar
2008-11-26  5:55       ` Andrew Morton
2008-11-26 16:49     ` 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=1227688024.5511.56.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=serue@us.ibm.com \
    --cc=srostedt@redhat.com \
    --cc=sukadev@linux.vnet.ibm.com \
    /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