All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: Linux Netdev List <netdev@vger.kernel.org>
Subject: [RFC][PATCH 0/3] Make loopback device weight twice as little.
Date: Fri, 04 Apr 2008 18:09:05 +0400	[thread overview]
Message-ID: <47F63681.1030603@openvz.org> (raw)

I noticed, that on a 32bit box with a non-debug config the 
sizeof(struct net_device) is slightly more than 1024. This 
means, that for example loopback device (with sizeof_priv == 0) 
is allocated from the size-2048 cache and thus we have ~1000
wasted bytes.

I know, that this is not that much, all the more so on most of
the setups the lo device is single :) but with the net-namespaced
kernel each namespace has its own loopback device, so this problem
becomes more relevant.

I also guess, that the net_device struct allows many ways to get
shrunk, but I noticed, that is has ~20 pointers on functions for
different purposes, like init, hard_start_xmit, neigh_setup, etc.

The proposal is to _move_ all these callbacks on a new structure
called net_device_ops and put a pointer on it on the net_device.
I've checked how much will the net_device weigh after this and
it turned out, that this difference (80 bytes) is enough to get
the 1024-sized net_device and thus a halved loopback.

To make this change smooth, I propose the following plan (however,
three patches I sent will demonstrate the idea better). 

* First - declare an empty nd_default_ops and make all new devices 
  point on this new ops temporarily. 
* Then replace each call to dev->xxx() with the dev->nd_ops->xxx() 
  one step by step. The ns_ops->xxx() will be the nd_default_ops->xxx
  then and they all will (temporarily) look like
	static void nd_default_xxx(struct net_device *dev, ...)
	{
		if (dev->xxx)
			dev->xxx(dev, ...)
	}
* After this patch switch all the drivers (lots of work :( but it can
  be done driver-by-driver, i.e. without HUGE patches) from on-device
  ops to nd_ops pointer.
* Finally - remove all the ops from the net_device and the default 
  stubs described above.

Does this idea worth being developed further?

Thanks,
Pavel

             reply	other threads:[~2008-04-04 13:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04 14:09 Pavel Emelyanov [this message]
2008-04-04 14:10 ` [RFC][PATCH 1/3] Introduce the net_device_ops structure Pavel Emelyanov
2008-04-04 15:14   ` Stephen Hemminger
2008-04-04 15:54     ` Patrick McHardy
2008-04-14  4:20       ` David Miller
2008-04-04 14:12 ` [RFC][PATCH 2/3] Move net_device->init callback on net_device_ops Pavel Emelyanov
2008-04-04 14:14 ` [RFC][PATCH 3/3] Move net_device->uninit " Pavel Emelyanov

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=47F63681.1030603@openvz.org \
    --to=xemul@openvz.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.