[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140616163525.46933b64320e220a6d806bb4@linux-foundation.org>
Date: Mon, 16 Jun 2014 16:35:25 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: David Rientjes <rientjes@...gle.com>
Cc: Michal Nazarewicz <mina86@...a86.com>,
Steven Rostedt <rostedt@...dmis.org>,
Hagen Paul Pfeifer <hagen@...u.net>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using
min and max
On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes <rientjes@...gle.com> wrote:
> On Mon, 16 Jun 2014, Andrew Morton wrote:
>
> > > It appears that gcc is better at optimising a double call to min
> > > and max rather than open coded min3 and max3. This can be observed
> > > here:
> > >
> > > ...
> > >
> > > Furthermore, after ___make allmodconfig && make bzImage modules___ this is the
> > > comparison of image and modules sizes:
> > >
> > > # Without this patch applied
> > > $ ls -l arch/x86/boot/bzImage **/*.ko |awk '{size += $5} END {print size}'
> > > 350715800
> > >
> > > # With this patch applied
> > > $ ls -l arch/x86/boot/bzImage **/*.ko |awk '{size += $5} END {print size}'
> > > 349856528
> >
> > We saved nearly a megabyte by optimising min3(), max3() and clamp()?
> >
> > I'm counting a grand total of 182 callsites for those macros. So the
> > saving is 4700 bytes per invokation? I don't believe it...
> >
>
> I was checking just the instances of min3() in mm/ and gcc ends up
> inlining transfer_objects() in mm/slab.c as a result of this change and
> increases its text size:
>
> text data bss dec hex filename
> 28369 21559 4 49932 c30c slab.o.before
> 28399 21559 4 49962 c32a slab.o.after
Maybe that's a good thing in disguise: gcc said "hey this thing is now
small enough to inline it".
> It also seems to use one additional temp variable of type typeof(x) on the
> stack, so I do think the old version was superior.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists