All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Dmitry Torokhov <dtor@vmware.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux/m68k <linux-m68k@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>
Subject: Re: Early crash (was: Re: module: show version information for built-in modules in sysfs)
Date: Wed, 02 Feb 2011 23:52:04 +0100	[thread overview]
Message-ID: <m2ipx2dp7v.fsf@igel.home> (raw)
In-Reply-To: <20110202194227.GA13794@dtor-ws.eng.vmware.com> (Dmitry Torokhov's message of "Wed, 2 Feb 2011 11:42:27 -0800")

Dmitry Torokhov <dtor@vmware.com> writes:

> But why is it aligned on 2-byte boundary and why m64k is not happy with
> module_version_attribute but is happy with kernel_param which is also
> aligned similarly?

struct kernel_parm doesn't contain internal padding on 32 bit
architectures (it does on 64bit architectures though).

> If we unroll module_version_attribute it woud look like this:
>
> struct module_version_attribute {
>
> 	struct module_attribute {
>
> 		struct attribute {
> 			const char *name;
> 			mode_t mode;
> 		} attr;
> 		...
>
> 	} mattr;
>
> 	const char *module_name;
> 	const char *version;
> };
>
> So I would expect it be aligned on (char *) boundary which should be the
> same as (void *).

mode_t is a 16 bit type, thus any following member becomes aligned on an
odd 2 byte boundary.  On 32bit architectures with 4 byte alignment and
16 bit mode_t struct attribute contains 2 bytes of internal padding.
(64bit architectures typically have a 32bit mode_t, and there are 4
bytes of padding.)

> Will it help if we rearrange module_version_attribute definition to
> explicitly have first field being a pointer so it is more like
> kernel_param, like this:
>
> struct module_version_attribute {
> 	const char *module_name;
> 	const char *version;
> 	struct module_attribute mattr;
> };

That won't change the total size of the structure.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

WARNING: multiple messages have this Message-ID (diff)
From: Andreas Schwab <schwab@linux-m68k.org>
To: Dmitry Torokhov <dtor@vmware.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux/m68k <linux-m68k@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>
Subject: Re: Early crash (was: Re: module: show version information for built-in modules in sysfs)
Date: Wed, 02 Feb 2011 23:52:04 +0100	[thread overview]
Message-ID: <m2ipx2dp7v.fsf@igel.home> (raw)
In-Reply-To: <20110202194227.GA13794@dtor-ws.eng.vmware.com> (Dmitry Torokhov's message of "Wed, 2 Feb 2011 11:42:27 -0800")

Dmitry Torokhov <dtor@vmware.com> writes:

> But why is it aligned on 2-byte boundary and why m64k is not happy with
> module_version_attribute but is happy with kernel_param which is also
> aligned similarly?

struct kernel_parm doesn't contain internal padding on 32 bit
architectures (it does on 64bit architectures though).

> If we unroll module_version_attribute it woud look like this:
>
> struct module_version_attribute {
>
> 	struct module_attribute {
>
> 		struct attribute {
> 			const char *name;
> 			mode_t mode;
> 		} attr;
> 		...
>
> 	} mattr;
>
> 	const char *module_name;
> 	const char *version;
> };
>
> So I would expect it be aligned on (char *) boundary which should be the
> same as (void *).

mode_t is a 16 bit type, thus any following member becomes aligned on an
odd 2 byte boundary.  On 32bit architectures with 4 byte alignment and
16 bit mode_t struct attribute contains 2 bytes of internal padding.
(64bit architectures typically have a 32bit mode_t, and there are 4
bytes of padding.)

> Will it help if we rearrange module_version_attribute definition to
> explicitly have first field being a pointer so it is more like
> kernel_param, like this:
>
> struct module_version_attribute {
> 	const char *module_name;
> 	const char *version;
> 	struct module_attribute mattr;
> };

That won't change the total size of the structure.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2011-02-02 22:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 20:33 Early crash (was: Re: module: show version information for built-in modules in sysfs) Geert Uytterhoeven
2011-02-01 21:09 ` Dmitry Torokhov
2011-02-01 21:09   ` Dmitry Torokhov
2011-02-01 22:03   ` Geert Uytterhoeven
2011-02-01 22:26     ` Dmitry Torokhov
2011-02-02 14:48       ` Geert Uytterhoeven
2011-02-02 19:42         ` Dmitry Torokhov
2011-02-02 22:52           ` Andreas Schwab [this message]
2011-02-02 22:52             ` Andreas Schwab
2011-02-02 23:59             ` Dmitry Torokhov
2011-02-03  0:10               ` Andreas Schwab
2011-02-03  0:10                 ` Andreas Schwab
2011-02-03  0:24                 ` Dmitry Torokhov
2011-02-03 17:38                   ` Andreas Schwab
2011-02-03 17:38                     ` Andreas Schwab
2011-02-05 23:47                     ` Thorsten Glaser
2011-02-08 21:31                       ` Andreas Schwab
2011-02-08 22:46                         ` Thorsten Glaser
2011-02-07  8:19                   ` Dmitry Torokhov
2011-02-07  8:19                     ` Dmitry Torokhov
2011-02-07  8:50                     ` Early crash David Miller
2011-02-07 16:58                       ` Dmitry Torokhov
2011-02-07 19:27                         ` David Miller
2011-02-07 19:28                           ` Dmitry Torokhov
2011-02-08  3:12                           ` Rusty Russell
2011-02-08  3:31                             ` David Miller

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=m2ipx2dp7v.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=dtor@vmware.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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.