From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: Re: [PATCH net-next 1/7] net: dsa: hide dsa_uses_tagged_protocol code Date: Tue, 30 May 2017 18:12:49 +0200 Message-ID: <20170530161249.GK22758@lunn.ch> References: <20170530142131.23568-1-vivien.didelot@savoirfairelinux.com> <20170530142131.23568-2-vivien.didelot@savoirfairelinux.com> <20170530150144.GC22758@lunn.ch> <20170530.110923.2297838959849946238.davem@davemloft.net> <87wp8y2v9t.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Miller , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, f.fainelli@gmail.com To: Vivien Didelot Return-path: Content-Disposition: inline In-Reply-To: <87wp8y2v9t.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Tue, May 30, 2017 at 11:56:30AM -0400, Vivien Didelot wrote: > Hi Andrew, David, > > David Miller writes: > > >>> +bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) > >>> +{ > >>> + return !!dst->rcv; > >>> +} > >>> + > >> > >> You need to be careful here. This is in the hot path. Every frame > >> received uses this code. And think about a distro kernel, which might > >> have DSA enabled by default, yet is unlikely to have any switches. You > >> are adding a function call which can be called millions of times per > >> second.... > > > > Yeah, we really can't make this change. > > > > This isn't glibc where we're trying to hide the implementation of "FILE *" > > behind accessor functions that caller can't see. We inline things when > > performance dictates, and it does here. > > Thanks for the explanation, this wasn't obvious to me at all. So inline > is mandatory here. Would a dereference like "!!dst->tag_ops->rcv" have > an significant impact on performance? The additional dereference could cause a cache miss when accessing tag_ops, which is expensive. dst will be in cache, so dst->rcv should always be cheap. Andrew