From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by dpdk.org (Postfix) with ESMTP id 5E2D2B6AB for ; Fri, 3 Jul 2015 21:58:36 +0200 (CEST) Received: by wicgi11 with SMTP id gi11so107691447wic.0 for ; Fri, 03 Jul 2015 12:58:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=e4TfH7kefnmbsk7ZuNeD9Jsek/LrWFXDZG9baZZSRQo=; b=Dm8SCxfo1ZGazs1susHgBXZAuSq/yYfUe/T7gu9zIsHvztNjP/LuRVi5n0sU3pfMu4 JAKuZu7YVS8wM8AyKBr/uy9GrWkXAMrBM5t+u0HT2dmtaMdMp3TQcTUkPmczGi3S+Jqj Au57/Mo4zI6iGBKCzvd7duDQwTb0Lxu9dlCZdmmGPmRD1+UZGJtZ+sIt1N3Za7JCe20R 6HMhsVSS/6M0Kc2F6gdcmV4Q9Xkyvajkc3AR2Ewd2jmCN3tMI93JJTyqG5JIH3xPRC9k 6lyr8A76S3VTuGh5rbSsEnXdZPuuP6Dy8ST+LXHwLozgNGh3scPbPsGz06r9ld+AobGd 8XvQ== X-Gm-Message-State: ALoCoQmtqWb7JobhLgfX0cYT6BHhejpDoz7sLbLNueV5xDx9y6ay0RVIWv/GAKqw+OW+3jj+PT5o X-Received: by 10.180.206.147 with SMTP id lo19mr28898391wic.79.1435953516270; Fri, 03 Jul 2015 12:58:36 -0700 (PDT) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id r6sm33965928wiy.13.2015.07.03.12.58.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2015 12:58:35 -0700 (PDT) From: Thomas Monjalon To: Bruce Richardson Date: Fri, 03 Jul 2015 21:57:26 +0200 Message-ID: <2644782.PAW8lcSTnr@xps13> Organization: 6WIND User-Agent: KMail/4.14.8 (Linux/4.0.4-2-ARCH; KDE/4.14.8; x86_64; ; ) In-Reply-To: <20150703155642.GB8096@bricha3-MOBL3> References: <1435938006-22254-1-git-send-email-bruce.richardson@intel.com> <2430733.IxTGXH4ElX@xps13> <20150703155642.GB8096@bricha3-MOBL3> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 19:58:36 -0000 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.