deinline some larger functions from netdevice.h
Subsystems (2)
PATCH 1/1 deinline some larger functions from netdevice.h
Hi Andrew,
Network folks did non comment on these two patches, let me try submitting them to you instead.
I hunted down some large inlines. This patch address those found in netdevice.h.
On a allyesconfig'ured kernel:
Size Uses Wasted Name and definition
===== ==== ====== ================================================ 95 162 12075 netif_wake_queue include/linux/netdevice.h 129 86 9265 dev_kfree_skb_any include/linux/netdevice.h 127 56 5885 netif_device_attach include/linux/netdevice.h 73 86 4505 dev_kfree_skb_irq include/linux/netdevice.h 46 60 1534 netif_device_detach include/linux/netdevice.h 119 16 1485 __netif_rx_schedule include/linux/netdevice.h 143 5 492 netif_rx_schedule include/linux/netdevice.h 81 7 366 netif_schedule include/linux/netdevice.h
netif_wake_queue is big because __netif_schedule is a big inline:
static inline void __netif_schedule(struct net_device *dev) {
if (!test_and_set_bit(__LINK_STATE_SCHED, &dev->state)) { unsigned long flags;
struct softnet_data *sd;
local_irq_save(flags);
sd = &__get_cpu_var(softnet_data); dev->next_sched = sd->output_queue; sd->output_queue = dev; raise_softirq_irqoff(NET_TX_SOFTIRQ); local_irq_restore(flags);
}
}
static inline void netif_wake_queue(struct net_device *dev) {
#ifdef CONFIG_NETPOLL_TRAP
if (netpoll_trap())
return;
#endif
if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state)) __netif_schedule(dev);
}
By de-inlining __netif_schedule we are saving a lot of text at each callsite of netif_wake_queue and netif_schedule. __netif_rx_schedule is also big, and it makes more sense to keep both of them out of line.
Patch also deinlines dev_kfree_skb_any. We can deinline dev_kfree_skb_irq instead... oh well.
netif_device_attach/detach are not hot paths, we can deinline them too.
--
vda
include/linux/netdevice.h +5 -50
@@ -594,20 +594,7 @@ DECLARE_PER_CPU(struct softnet_data,soft#define HAVE_NETIF_QUEUE -static inline void __netif_schedule (struct net_device *dev) -{ -if (!test_and_set_bit (__LINK_STATE_SCHED, &dev->state)) { -unsigned long flags; -struct softnet_data *sd; - -local_irq_save (flags); - sd = &__get_cpu_var (softnet_data); - dev->next_sched = sd->output_queue; - sd->output_queue = dev; -raise_softirq_irqoff (NET_TX_SOFTIRQ ); -local_irq_restore (flags); - } -} +extern void __netif_schedule (struct net_device *dev);static inline void netif_schedule (struct net_device *dev) {
@@ -671,13 +658,7 @@ static inline void dev_kfree_skb_irq(str/* Use this variant in places where it could be invoked * either from interrupt or non-interrupt context. */ -static inline void dev_kfree_skb_any (struct sk_buff *skb) -{ -if (in_irq () ||irqs_disabled ()) -dev_kfree_skb_irq (skb); -else -dev_kfree_skb (skb); -} +extern void dev_kfree_skb_any (struct sk_buff *skb);#define HAVE_NETIF_RX 1extern int netif_rx (struct sk_buff *skb);
@@ -735,22 +716,9 @@ static inline int netif_device_present(sreturn test_bit (__LINK_STATE_PRESENT, &dev->state); } -static inline void netif_device_detach (struct net_device *dev) -{ -if (test_and_clear_bit (__LINK_STATE_PRESENT, &dev->state) && -netif_running (dev)) { -netif_stop_queue (dev); - } -} +extern void netif_device_detach (struct net_device *dev); -static inline void netif_device_attach (struct net_device *dev) -{ -if (!test_and_set_bit (__LINK_STATE_PRESENT, &dev->state) && -netif_running (dev)) { -netif_wake_queue (dev); -__netdev_watchdog_up (dev); - } -} +extern void netif_device_attach (struct net_device *dev);/* * Network interface message level settings
@@ -818,20 +786,7 @@ static inline int netif_rx_schedule_prep* already been called and returned 1. */ -static inline void __netif_rx_schedule (struct net_device *dev) -{ -unsigned long flags; - -local_irq_save (flags); -dev_hold (dev); -list_add_tail (&dev->poll_list, &__get_cpu_var (softnet_data).poll_list); -if (dev->quota <0 ) - dev->quota += dev->weight; -else - dev->quota = dev->weight; -__raise_softirq_irqoff (NET_RX_SOFTIRQ ); -local_irq_restore (flags); -} +extern void __netif_rx_schedule (struct net_device *dev);/* Try to reschedule poll. Called by irq handler. */
net/core/dev.c +64 -0
70 lines not on this page · raw message
David S. Miller
maintainerFrom: Denis Vlasenko <[email protected]>
Date: Thu, 30 Mar 2006 10:21:48 +0300
Quoted 2 lines
Network folks did non comment on these two patches, let me try submitting them to you instead.
It's in my tree if you would bother checking:
kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6.git
Quoted 3 lines · Denis Vlasenko
Network folks did non comment on these two patches, let me try
submitting them to you instead.
They're both merged (one is in -linus, the other's in -davem).