From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC PATCH] Tracepoints: fix section alignment using pointer array
Date: Wed, 2 Feb 2011 13:29:45 -0500 [thread overview]
Message-ID: <20110202182945.GA27022@Krystal> (raw)
In-Reply-To: <201101311348.27501.rusty@rustcorp.com.au>
* Rusty Russell (rusty@rustcorp.com.au) wrote:
> On Thu, 27 Jan 2011 08:56:22 am Mathieu Desnoyers wrote:
> > Make the tracepoints more robust, making them solid enough to handle compiler
> > changes by not relying on anything based on compiler-specific behavior with
> > respect to structure alignment. Implement an approach proposed by David Miller:
> > use an array of const pointers to refer to the individual structures, and export
> > this pointer array through the linker script rather than the structures per se.
> > It will consume 32 extra bytes per tracepoint (24 for structure padding and 8
> > for the pointers), but are less likely to break due to compiler changes.
> >
> > History:
> >
> > commit 7e066fb870fcd1025ec3ba7bbde5d541094f4ce1 added the aligned(32) type and
> > variable attribute to the tracepoint structures to deal with gcc happily
> > aligning statically defined structures on 32-byte multiples.
> >
> > commit 15e3540ce2159705f18fad6147ffedf04445ad64 tried to use a 8-byte alignment
> > for tracepoint structures by applying both the variable and type attribute to
> > tracepoint structures definitions and declarations. It worked fine with gcc
> > 4.5.1, but broke with gcc 4.4.4 and 4.4.5.
> >
> > The reason is that the "aligned" attribute only specify the _minimum_ alignment
> > for a structure, leaving both the compiler and the linker free to align on
> > larger multiples. Because tracepoint.c expects the structures to be placed as an
> > array within each section, up-alignment cause NULL-pointer exceptions due to the
> > extra unexpected padding.
>
> Hmm, that assumption is used in module parameters too, so we already rely on
> the toolchain not to over-pad.
>
> Perhaps we should fix that too, or wait until it explodes?
Hrm, yeah, struct kernel_param seems to fit into the same category. I'd
recommend to fix it too. On 64-bit, this structure size is 28 bytes, but its
alignment is specified by:
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *))))
So AFAIU, if you declare __param sections in multiple different objects, that
you later link together to generate a module (or the kernel core), you might end
up with a whole caused by the realignment on 32-byte done by the linker.
In the past, tracepoints were 8-byte aligned, and I had to bump their structure
to a 32-byte alignment because of compiler behavior changes. I would personally
prefer not to wait for other things to break before introducing this fix for
struct kernel_param too.
Thanks,
Mathieu
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2011-02-02 18:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 22:26 [RFC PATCH] Tracepoints: fix section alignment using pointer array Mathieu Desnoyers
2011-01-31 3:18 ` Rusty Russell
2011-02-02 18:29 ` Mathieu Desnoyers [this message]
2011-02-04 22:01 ` [tip:perf/urgent] tracepoints: Fix " 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=20110202182945.GA27022@Krystal \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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