2006-03-30 07:22:43

by Denis Vlasenko

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Denis Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (2.06 kB)
netdevice.patch (4.39 kB)
Download all attachments

2006-03-30 07:26:30

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] deinline some larger functions from netdevice.h

From: Denis Vlasenko <[email protected]>
Date: Thu, 30 Mar 2006 10:21:48 +0300

> 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

2006-03-30 07:29:00

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] deinline some larger functions from netdevice.h

Denis Vlasenko <[email protected]> wrote:
>
> 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).