LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: David Miller <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org,
	fweisbec@gmail.com, mingo@elte.hu, richm@oldelvet.org.uk,
	ben@decadent.org.uk, sparclinux@vger.kernel.org,
	stable <stable@kernel.org>
Subject: Re: [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3)
Date: Sat, 22 Jan 2011 12:11:34 -0500	[thread overview]
Message-ID: <20110122171134.GA31308@Krystal> (raw)
In-Reply-To: <20110121.160503.233879710.davem@davemloft.net>

* David Miller (davem@davemloft.net) wrote:
> From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Date: Fri, 21 Jan 2011 15:36:31 -0500
> 
> > Problem description:
> > 
> > gcc happily align on 32-byte structures defined statically. Ftrace trace events
> > and Tracepoints both statically define structures into custom sections (using
> > the "section" attribute), to then assign these to symbols with the linker
> > scripts to iterate the these sections as an array.
> > 
> > However, gcc uses different alignments for these structures when they are
> > defined statically than when they are globally visible and/or in an array.
> > Therefore iteration on these arrays sees "holes" of padding. gcc is within its
> > rights to increase the alignment of the statically defined structures because,
> > normally, there should be no other accesses to them than in the local object. We
> > are actually iterating on the generated structures as if they were an array
> > without letting gcc knowing anything about it.
> > 
> > This patch introduces __u64_aligned to force gcc to use the u64 type and
> > variable alignment, up-aligning or down-aligning the target type if necessary.
> > The memory accesses to the target structure are efficient (does not require
> > bytewise memory accesses) and the atomic pointer update guarantees required by
> > RCU are kept. u64 is considered as the largest type that can generate a trap for
> > unaligned accesses (u64 on sparc32 needs to be aligned on 64-bit).
> > 
> > This alignment should be used for both structure definitions and declarations
> > (as *both* the type and variable attribute) when using the "section"
> > attribute to generate arrays of structures. Given that gcc only uses the type
> > attribute "aligned" as a lower-bound for alignment, the structures should not
> > contain types which require alignment larger than that of u64. The "aligned"
> > variable attribute, on the other hand, forces gcc to use exactly the specified
> > alignment.
> > 
> > Also introduce the linker script U64_ALIGN() macro for specification of custom
> > section alignment that matches that of __u64_aligned.
> > 
> > Changelog since v2:
> > - Drop the "packed" type attribute, because it causes gcc to drop the padding
> >   between consecutive "int" and "pointer"/"long" fields, which leads to
> >   unaligned accesses on sparc64.
> > 
> > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> 
> Acked-by: David S. Miller <davem@davemloft.net>

Thanks David,

After these patches get merged -- I would recommend going through the tracing
tree -- they'll have to go to -stable too. I'm therefore forwarding this to
stable@kernel.org (the same should be done for the two other patches in this
series).

Mathieu


-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2011-01-22 17:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21 20:36 [patch 0/3] Fix alignment of custom sections made from structures (v3) Mathieu Desnoyers
2011-01-21 20:36 ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3) Mathieu Desnoyers
2011-01-22  0:05   ` David Miller
2011-01-22 17:11     ` Mathieu Desnoyers [this message]
2011-01-22 17:43       ` Steven Rostedt
2011-01-25 23:34         ` Mathieu Desnoyers
2011-01-26  0:25           ` Steven Rostedt
2011-01-26  7:12   ` [tip:perf/core] Introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections tip-bot for Mathieu Desnoyers
2011-01-21 20:36 ` [patch 2/3] tracing: fix sparc64 alignment crash with __u64_aligned/U64_ALIGN() Mathieu Desnoyers
2011-01-22  0:05   ` David Miller
2011-01-22 17:15     ` Mathieu Desnoyers
2011-01-26  7:13   ` [tip:perf/core] tracing: Fix " tip-bot for Mathieu Desnoyers
2011-01-21 20:36 ` [patch 3/3] tracepoints: use __u64_aligned/U64_ALIGN() Mathieu Desnoyers
2011-01-22  0:05   ` David Miller
2011-01-26  7:13   ` [tip:perf/core] tracepoints: Use __u64_aligned/U64_ALIGN() tip-bot for Mathieu Desnoyers

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=20110122171134.GA31308@Krystal \
    --to=mathieu.desnoyers@efficios.com \
    --cc=ben@decadent.org.uk \
    --cc=davem@davemloft.net \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=richm@oldelvet.org.uk \
    --cc=rostedt@goodmis.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=stable@kernel.org \
    --subject='Re: [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3)' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).