Re: [PATCH 2/5] ftrace: use code patching for ftrace graph tracer

From: Harvey Harrison
Date: Wed Nov 26 2008 - 13:06:19 EST


On Wed, 2008-11-26 at 10:02 -0800, Andrew Morton wrote:
> > >
> > > > + return -EINVAL;
> > > > +
> > > > + *(int *)(&code[1]) = new_offset;
> > >
> > > Might be able to use put_unaligned_foo() here.
> > >
> > > The problem is that these functions use sizeof(*ptr) to work out what
> > > to do, so a cast is still needed. A get_unaligned32(ptr) would be
> > > nice. One which takes a void* and assumes CPU ordering.
> >
> > Is there a correctness concern here? This is arch specific code, so I'm
> > not worried about other archs.
>
> No, the code is OK as-is.
>
> It's just that "read a word from an [maybe-]unaligned address" is such
> a common operation that there should be a nice clean simple function to
> do it, rather than doing open-coded (and different) weird C tricks at each
> and\ every site.
>

Also it is arch-specific, so if you know unaligned access is OK, just doing the
cast+deref is OK.

Harvey

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/