mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Rientjes <rientjes@google.com>
Cc: Michal Nazarewicz <mina86@mina86.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Hagen Paul Pfeifer <hagen@jauu.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max
Date: Mon, 16 Jun 2014 16:35:25 -0700	[thread overview]
Message-ID: <20140616163525.46933b64320e220a6d806bb4@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.02.1406161621530.21018@chino.kir.corp.google.com>

On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes <rientjes@google.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.

  reply	other threads:[~2014-06-16 23:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 21:07 Michal Nazarewicz
2014-06-16 23:18 ` Andrew Morton
2014-06-16 23:25   ` David Rientjes
2014-06-16 23:35     ` Andrew Morton [this message]
2014-06-16 23:54       ` David Rientjes
2014-06-17  0:21         ` Steven Rostedt
2014-06-17  4:01           ` Steven Rostedt
2014-06-17 13:49   ` Michal Nazarewicz
2014-06-17 11:37 ` Hagen Paul Pfeifer

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=20140616163525.46933b64320e220a6d806bb4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hagen@jauu.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=rientjes@google.com \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®