DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/2] ixgbe: add "cold" attribute to setup/teardown fns
Date: Fri, 03 Jul 2015 21:57:26 +0200	[thread overview]
Message-ID: <2644782.PAW8lcSTnr@xps13> (raw)
In-Reply-To: <20150703155642.GB8096@bricha3-MOBL3>

2015-07-03 16:56, Bruce Richardson:
> On Fri, Jul 03, 2015 at 05:45:34PM +0200, Thomas Monjalon wrote:
> > Hi Bruce,
> > 
> > 2015-07-03 16:40, Bruce Richardson:
> > > As well as the fast-path functions in the rxtx code, there are also
> > > functions which set up and tear down the descriptor rings. Since these
> > > are not performance critical functions, there is no need to have them
> > > extensively optimized, so we add __attribute__((cold)) to their
> > > definitions. This has the side-effect of making debugging them easier as
> > > the compiler does not optimize them as heavily, so more variables are
> > > accessible by default in gdb.
> > 
> > What is the benefit, compared to -O0?
> 
> First off, it's per function, rather than having to use -O0 globally. Secondly,
> it doesn't disable optimization, it just tells the compiler that the code is
> not on the hotpath - whether or not the compiler optimizes it is up to the 
> compiler itself. From GCC documentation: 
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
> 
> "The cold attribute on functions is used to inform the compiler that the 
> function is unlikely to be executed. The function is optimized for size rather 
> than speed and on many targets it is placed into a special subsection of the 
> text section so all cold functions appear close together, improving code 
> locality of non-cold parts of program. The paths leading to calls of cold
> functions within code are marked as unlikely by the branch prediction mechanism.
> It is thus useful to mark functions used to handle unlikely conditions, such as
> perror, as cold to improve optimization of hot functions that do call marked
> functions in rare occasions."

I know it may provide some optimization of the hot path.
I was asking compared to -O0 because you were justifying this change for debug.
In other words, for debugging, -O0 is probably better. So the reason of this
change should be the optimization. And it would be interesting to know if you
have seen some performance improvement.

  reply	other threads:[~2015-07-03 19:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03 15:40 [dpdk-dev] [PATCH 0/2] Fix crash with vpmd and mbuf debug Bruce Richardson
2015-07-03 15:40 ` [dpdk-dev] [PATCH 1/2] ixgbe: add "cold" attribute to setup/teardown fns Bruce Richardson
2015-07-03 15:45   ` Thomas Monjalon
2015-07-03 15:56     ` Bruce Richardson
2015-07-03 19:57       ` Thomas Monjalon [this message]
2015-07-06  9:20         ` Bruce Richardson
2015-07-06  9:26           ` Thomas Monjalon
2015-07-03 23:03   ` Stephen Hemminger
2015-07-03 15:40 ` [dpdk-dev] [PATCH 2/2] ixgbe: check mbuf refcnt when clearing RX/TX ring Bruce Richardson
2015-07-03 15:46   ` Thomas Monjalon
2015-07-03 16:04     ` Bruce Richardson
2015-07-03 19:52       ` Thomas Monjalon
2015-07-20  9:36   ` Ananyev, Konstantin
2015-07-20  9:47     ` Richardson, Bruce
2015-07-06 15:08 ` [dpdk-dev] [PATCH 0/2] Fix crash with vpmd and mbuf debug Thomas Monjalon

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=2644782.PAW8lcSTnr@xps13 \
    --to=thomas.monjalon@6wind.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.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).