From: Ingo Oeser <netdev@axxeo.de>
To: Denis Vlasenko <vda@ilport.com.ua>
Cc: Dave Dillow <dave@thedillows.org>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org, jgarzik@pobox.com,
ioe-lkml@rameria.de
Subject: Re: [PATCH] deinline a few large functions in vlan code v2
Date: Tue, 11 Apr 2006 15:17:36 +0200 [thread overview]
Message-ID: <200604111517.37215.netdev@axxeo.de> (raw)
In-Reply-To: <200604111502.52302.vda@ilport.com.ua>
Hi Denis,
Denis Vlasenko wrote:
> On Tuesday 11 April 2006 12:49, Ingo Oeser wrote:
> > #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> > static inline has_vlan_group(...) {
> > /* get VLAN group */
> > }
> > #else
> > static inline has_vlan_group(...) {return 0;}
> > #endif
> >
> > With this and similiar changes in the drivers,
> > your patch might be less intrusive and thus more acceptable to maintainers.
> >
> > Just let the compiler remove the extra code with constant folding and dead
> > code elemination. The result will be even cleaner code, I think.
> >
> > What do you think?
I thought more of introducing functions, which just fold away
all the "if ()" blocks in normal code paths,
which you wrapped into "#if" here.
I don't think people have problems, if you #ifdef out complete functions,
linear setup code or structure members. People seem to have more problems
with #ifdef in control flow code, because there the condition is nothing else but
a compile time constant (the CONFIG_FOO value) which should be expressed as such.
Instead of
#ifdef CONFIG_FOO
if (condition) {
}
#endif
just do
#ifdef CONFIG_FOO
#define foo 1
#else
#define foo 0
#endif
if (foo && condition) {
}
Just do nothing or return a compile time constant in those inlines.
>
> Addresses of these functions are stored into netdevice members:
>
> @@ -2549,8 +2559,10 @@ typhoon_init_one(struct pci_dev *pdev, c
> dev->watchdog_timeo = TX_TIMEOUT;
> dev->get_stats = typhoon_get_stats;
> dev->set_mac_address = typhoon_set_mac_address;
> +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> dev->vlan_rx_register = typhoon_vlan_rx_register;
> dev->vlan_rx_kill_vid = typhoon_vlan_rx_kill_vid;
> +#endif
>
> Even empty inline would not be "optimized out to nothing" here.
No problem, just optimize out the assignment itself:
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static inline void typhoon_setup_vlan_hooks(struct netdev *dev) {
dev->vlan_rx_register = typhoon_vlan_rx_register;
dev->vlan_rx_kill_vid = typhoon_vlan_rx_kill_vid;
}
#else
static inline void typhoon_setup_vlan_hooks(struct netdev *dev) { (void)dev; }
#endif
The whole linux/if_vlan.h stuff misses this style of code.
There is simply no fallback code for CONFIG_VLAN_8021Q not being defined.
Regards
Ingo Oeser
next prev parent reply other threads:[~2006-04-11 13:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200604071628.30486.vda@ilport.com.ua>
[not found] ` <200604101716.58463.vda@ilport.com.ua>
[not found] ` <1144682807.12177.22.camel@dillow.idleaire.com>
2006-04-11 7:28 ` [PATCH] deinline a few large functions in vlan code v2 Denis Vlasenko
2006-04-11 8:02 ` David S. Miller
2006-04-11 9:49 ` Ingo Oeser
[not found] ` <200604111502.52302.vda@ilport.com.ua>
2006-04-11 13:17 ` Ingo Oeser [this message]
2006-04-12 19:32 ` [RFD][PATCH] typhoon and core sample for folding away VLAN stuff (was: Re: [PATCH] deinline a few large functions in vlan code v2) Ingo Oeser
2006-04-12 20:10 ` [RFD][PATCH] typhoon and core sample for folding away VLAN stuff Ben Greear
2006-04-12 20:23 ` Stephen Hemminger
2006-04-12 20:51 ` David S. Miller
2006-04-13 1:24 ` Dave Dillow
2006-04-13 8:38 ` Denis Vlasenko
2006-04-13 15:00 ` Dave Dillow
2006-04-11 13:59 ` [PATCH] deinline a few large functions in vlan code v2 Dave Dillow
2006-04-12 8:55 ` Denis Vlasenko
2006-04-12 17:18 ` Dave Dillow
2006-04-13 6:04 ` Denis Vlasenko
2006-04-13 14:59 ` Dave Dillow
2006-04-13 11:32 ` Ingo Oeser
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=200604111517.37215.netdev@axxeo.de \
--to=netdev@axxeo.de \
--cc=dave@thedillows.org \
--cc=davem@davemloft.net \
--cc=ioe-lkml@rameria.de \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vda@ilport.com.ua \
/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).