From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0162A5A8C for ; Fri, 3 Jul 2015 17:56:45 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 03 Jul 2015 08:56:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,400,1432623600"; d="scan'208";a="740130564" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.208.62]) by fmsmga001.fm.intel.com with SMTP; 03 Jul 2015 08:56:43 -0700 Received: by (sSMTP sendmail emulation); Fri, 03 Jul 2015 16:56:42 +0025 Date: Fri, 3 Jul 2015 16:56:42 +0100 From: Bruce Richardson To: Thomas Monjalon Message-ID: <20150703155642.GB8096@bricha3-MOBL3> References: <1435938006-22254-1-git-send-email-bruce.richardson@intel.com> <1435938006-22254-2-git-send-email-bruce.richardson@intel.com> <2430733.IxTGXH4ElX@xps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2430733.IxTGXH4ElX@xps13> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 1/2] ixgbe: add "cold" attribute to setup/teardown fns X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jul 2015 15:56:46 -0000 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." /Bruce