dwarves.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: jamal <hadi-fAAogVwAN2Kw5LPnMra/2Q@public.gmane.org>
Cc: dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Changing the word-size was: Re: eat your own dog food?
Date: Sat, 12 Jan 2008 13:54:04 -0200	[thread overview]
Message-ID: <20080112155404.GB23567@ghostprotocols.net> (raw)
In-Reply-To: <20080112152109.GA23567-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>

Em Sat, Jan 12, 2008 at 01:21:09PM -0200, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Jan 10, 2008 at 04:41:16PM -0500, jamal escreveu:
> > On Thu, 2008-10-01 at 19:39 -0200, Arnaldo Carvalho de Melo wrote:
> > 
> > 
> > > Working now on unions, etc, have you had the chance of testing this
> > > patch?
> > 
> > I should be able to test it in a couple of hours. If you have the unions
> > change before then, send me a unified patch - else an incremental
> > version.
> 
> Remove the non-commited patches and do a git-pull, basic work is done,
> reusing code I had in ctracer to do some simple alignment fixups.
> 
> Please let me know about any bugs you may find.

There are still some problems:

[acme@doppio pahole]$ build/pahole -C e1000_opt_list \
/usr/lib/debug/lib/modules/2.6.21-65.el5rt/kernel/drivers/net/e1000/e1000.ko.debug

struct e1000_opt_list {
	int                        i;                    /*     0     4 */

	/* XXX 4 bytes hole, try to pack */

	char *                     str;                  /*     8     8 */

	/* size: 16, cachelines: 1 */
	/* sum members: 12, holes: 1, sum holes: 4 */
	/* last cacheline: 16 bytes */
};

So on 64 bits we have a hole because pointers are aligned at word-size
boundaries, changing it to 4 bytes:

[acme@doppio pahole]$ build/pahole -w 4 -C e1000_opt_list \
/usr/lib/debug/lib/modules/2.6.21-65.el5rt/kernel/drivers/net/e1000/e1000.ko.debug
struct e1000_opt_list {
	int                        i;                    /*     0     4 */

	/* XXX 4 bytes hole, try to pack */

	char *                     str;                  /*     8     4 */

	/* size: 12, cachelines: 1 */
	/* sum members: 8, holes: 1, sum holes: 4 */
	/* last cacheline: 12 bytes */
};

The pointer size was correctly changed to 4 and the size reduced to 12,
but we should have subtracted 4 bytes from 'str' offset and the hole
would disappear and the size becomes 8.

Working on it.

This new feature should be more exploited on an upcoming cool feature,
one where we'll be able to ask pahole if a struct has optimal layout in
a range of architectures.

That should be a piece of cake to implement as we'll just clone each
struct, change the word size of it and check if with the new word-size
there are holes where previously there wasn't.

With full fledged alignment rules in description files for each
architecture we will be able to check on all arches if a struct is The
Holy Grail :-)

Ah, and if we find out that on one arch it is unholy, i.e. has
non-optimal layout, we can ask pahole to reorganize it and check again.

Humm, the reorganize (that jamal calls 'optimize') machinery will have
to take into account the rules for all the architectures... That should
be fun! :-P

- Arnaldo
-
To unsubscribe from this list: send the line "unsubscribe dwarves" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2008-01-12 15:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-10 12:42 eat your own dog food? jamal
2008-01-10 13:39 ` Arnaldo Carvalho de Melo
     [not found]   ` <20080110133926.GF22437-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-10 13:55     ` jamal
2008-01-10 14:06       ` Arnaldo Carvalho de Melo
     [not found]         ` <20080110140635.GG22437-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-10 16:39           ` Arnaldo Carvalho de Melo
     [not found]             ` <20080110163959.GJ22437-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-10 21:37               ` jamal
2008-01-10 21:44                 ` Arnaldo Carvalho de Melo
     [not found]                   ` <20080110214438.GT22437-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-11  0:45                     ` jamal
2008-01-11  1:04                       ` jamal
2008-01-10 21:39               ` Arnaldo Carvalho de Melo
     [not found]                 ` <20080110213909.GS22437-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-10 21:41                   ` jamal
2008-01-12 15:21                     ` Arnaldo Carvalho de Melo
     [not found]                       ` <20080112152109.GA23567-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-12 15:54                         ` Arnaldo Carvalho de Melo [this message]
     [not found]                           ` <20080112155404.GB23567-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-12 16:28                             ` Changing the word-size was: " Arnaldo Carvalho de Melo
     [not found]                               ` <20080112162808.GC23567-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-12 17:28                                 ` Arnaldo Carvalho de Melo
     [not found]                                   ` <20080112172856.GD23567-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-12 18:08                                     ` jamal
2008-01-12 18:42                                       ` Arnaldo Carvalho de Melo
     [not found]                                         ` <20080112184211.GA17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-13  0:42                                           ` jamal
2008-01-13  1:15                                             ` jamal
     [not found]                                               ` <20080113163106.GE17675@ghostprotocols.net>
     [not found]                                                 ` <20080113163106.GE17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-13 18:07                                                   ` Arnaldo Carvalho de Melo
     [not found]                                                     ` <20080113180730.GG17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-13 18:19                                                       ` Arnaldo Carvalho de Melo
     [not found]                                                         ` <20080113181901.GH17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-13 18:26                                                           ` Arnaldo Carvalho de Melo
     [not found]                                                             ` <20080113182657.GI17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-13 19:13                                                               ` jamal
2008-01-12 21:36                                     ` Arnaldo Carvalho de Melo
     [not found]                                       ` <20080112213635.GC17675-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>
2008-01-12 22:08                                         ` Arnaldo Carvalho de Melo

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=20080112155404.GB23567@ghostprotocols.net \
    --to=acme-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hadi-fAAogVwAN2Kw5LPnMra/2Q@public.gmane.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 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).