All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: mathieu.desnoyers@efficios.com
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
Subject: Re: [patch 2/3] tracing: fix sparc64 alignment crash with __u64_aligned/U64_ALIGN()
Date: Fri, 21 Jan 2011 16:05:09 -0800 (PST)	[thread overview]
Message-ID: <20110121.160509.146106348.davem@davemloft.net> (raw)
In-Reply-To: <20110121203642.884088920@efficios.com>

From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Fri, 21 Jan 2011 15:36:32 -0500

> Problem description:
> 
> gcc happily align structures defined statically on 32-byte. Ftrace trace events
> and Tracepoints both statically define structures into 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 and when they are globally visible and/or in an array.
> Therefore iteration on these arrays sees "holes" of padding.
> 
> Use the __u64_aligned for type declarations and variable definitions to ensure
> that gcc:
> 
> a) iterates on the correctly aligned type. (type attribute)
> b) generates the definitions within the sections with the appropriate alignment.
>    (variable attribute)
> 
> The Ftrace code introduced the "aligned(4)" variable attribute in commit
> 1473e4417c79f12d91ef91a469699bfa911f510f to try to work around this problem that
> showed up on x86_64, but it causes unaligned accesses on sparc64, and is
> generally a bad idea on 64-bit if RCU pointers are contained within the
> structure. Moreover, it did not use the same attribute as type attribute, which
> could cause the iteration on the extern array structure not to match the
> variable definitions for some structure sizes.
> 
> We should also ensure proper alignment of each Ftrace section in
> include/asm-generic/vmlinux.lds.h.
> 
> Moving all STRUCT_ALIGN() for FTRACE_EVENTS() and TRACE_SYSCALLS() into the
> definitions, so the alignment is only done if these infrastructures are
> configured in. Use U64_ALIGN instead of STRUCT_ALIGN.
> 
> Also align TRACE_PRINTKS on U64_ALIGN to make sure the beginning of the section
> is aligned on pointer size.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Acked-by: David S. Miller <davem@davemloft.net>

WARNING: multiple messages have this Message-ID (diff)
From: David Miller <davem@davemloft.net>
To: mathieu.desnoyers@efficios.com
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
Subject: Re: [patch 2/3] tracing: fix sparc64 alignment crash with
Date: Sat, 22 Jan 2011 00:05:09 +0000	[thread overview]
Message-ID: <20110121.160509.146106348.davem@davemloft.net> (raw)
In-Reply-To: <20110121203642.884088920@efficios.com>

From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Fri, 21 Jan 2011 15:36:32 -0500

> Problem description:
> 
> gcc happily align structures defined statically on 32-byte. Ftrace trace events
> and Tracepoints both statically define structures into 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 and when they are globally visible and/or in an array.
> Therefore iteration on these arrays sees "holes" of padding.
> 
> Use the __u64_aligned for type declarations and variable definitions to ensure
> that gcc:
> 
> a) iterates on the correctly aligned type. (type attribute)
> b) generates the definitions within the sections with the appropriate alignment.
>    (variable attribute)
> 
> The Ftrace code introduced the "aligned(4)" variable attribute in commit
> 1473e4417c79f12d91ef91a469699bfa911f510f to try to work around this problem that
> showed up on x86_64, but it causes unaligned accesses on sparc64, and is
> generally a bad idea on 64-bit if RCU pointers are contained within the
> structure. Moreover, it did not use the same attribute as type attribute, which
> could cause the iteration on the extern array structure not to match the
> variable definitions for some structure sizes.
> 
> We should also ensure proper alignment of each Ftrace section in
> include/asm-generic/vmlinux.lds.h.
> 
> Moving all STRUCT_ALIGN() for FTRACE_EVENTS() and TRACE_SYSCALLS() into the
> definitions, so the alignment is only done if these infrastructures are
> configured in. Use U64_ALIGN instead of STRUCT_ALIGN.
> 
> Also align TRACE_PRINTKS on U64_ALIGN to make sure the beginning of the section
> is aligned on pointer size.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Acked-by: David S. Miller <davem@davemloft.net>

  reply	other threads:[~2011-01-22  0:04 UTC|newest]

Thread overview: 28+ 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 ` 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-21 20:36   ` Mathieu Desnoyers
2011-01-22  0:05   ` David Miller
2011-01-22  0:05     ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for David Miller
2011-01-22 17:11     ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3) Mathieu Desnoyers
2011-01-22 17:11       ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for Mathieu Desnoyers
2011-01-22 17:43       ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3) Steven Rostedt
2011-01-22 17:43         ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for Steven Rostedt
2011-01-25 23:34         ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3) Mathieu Desnoyers
2011-01-25 23:34           ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for Mathieu Desnoyers
2011-01-26  0:25           ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for structure alignment in custom sections (v3) Steven Rostedt
2011-01-26  0:25             ` [patch 1/3] introduce __u64_aligned and U64_ALIGN() for 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-21 20:36   ` Mathieu Desnoyers
2011-01-22  0:05   ` David Miller [this message]
2011-01-22  0:05     ` [patch 2/3] tracing: fix sparc64 alignment crash with David Miller
2011-01-22 17:15     ` [patch 2/3] tracing: fix sparc64 alignment crash with __u64_aligned/U64_ALIGN() Mathieu Desnoyers
2011-01-22 17:15       ` [patch 2/3] tracing: fix sparc64 alignment crash with Mathieu Desnoyers
2011-01-26  7:13   ` [tip:perf/core] tracing: Fix sparc64 alignment crash with __u64_aligned/U64_ALIGN() tip-bot for Mathieu Desnoyers
2011-01-21 20:36 ` [patch 3/3] tracepoints: use __u64_aligned/U64_ALIGN() Mathieu Desnoyers
2011-01-21 20:36   ` Mathieu Desnoyers
2011-01-22  0:05   ` David Miller
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
2011-01-26  4:04 [PATCH 0/3] [GIT PULL][v2.6.38] tracing: fix unaligned event arrays Steven Rostedt
2011-01-26  4:05 ` [PATCH 2/3] tracing: Fix sparc64 alignment crash with __u64_aligned/U64_ALIGN() 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=20110121.160509.146106348.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ben@decadent.org.uk \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@elte.hu \
    --cc=richm@oldelvet.org.uk \
    --cc=rostedt@goodmis.org \
    --cc=sparclinux@vger.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.