From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Greg Rose <gregory.v.rose@intel.com>,
netdev@vger.kernel.org, bhutchings@solarflare.com,
davem@davemloft.net
Subject: Re: [RFC V2 PATCH] rtnetlink: Add method to calculate dump info data size
Date: Tue, 10 May 2011 05:45:27 +0200 [thread overview]
Message-ID: <1304999127.3050.40.camel@edumazet-laptop> (raw)
In-Reply-To: <20110509201705.409f6d39@nehalam>
Le lundi 09 mai 2011 à 20:17 -0700, Stephen Hemminger a écrit :
> On Tue, 10 May 2011 04:43:33 +0200
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> > Le lundi 09 mai 2011 à 15:26 -0700, Greg Rose a écrit :
> > > The message size allocated for rtnl info dumps was limited to a single
> > > page. This is not enough for additional interface info available with
> > > devices that support SR-IOV. Calculate the amount of data required so
> > > the dump can allocate enough data to satisfy the request.
> > >
> > > V2 of this patch adds a new argument to the rtnl_register service that
> > > allows for a new method to calculate the amount of data required to
> > > complete the info dump request. So far the method is only implemented
> > > for the RTM_GETLINK slot.
> > >
> > > Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
> >
> > >
> > > +static u16 rtnl_calcit(struct sk_buff *skb)
> > > +{
> > > + struct net *net = sock_net(skb->sk);
> > > + int h;
> > > + int idx = 0, s_idx;
> > > + struct net_device *dev;
> > > + struct hlist_head *head;
> > > + struct hlist_node *node;
> > > + u16 alloc_size = 0;
> > > +
> > > + for (h = 0; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
> > > + idx = 0;
> > > + head = &net->dev_index_head[h];
> > > + hlist_for_each_entry(dev, node, head, index_hlist) {
> > > + if (idx < s_idx) {
> > > + idx++;
> > > + continue;
> > > + }
> > > + alloc_size = (u16)if_nlmsg_size(dev);
> > > + break;
> > > + }
> > > + }
> > > +
> > > + return alloc_size;
> > > +}
> > > +
> >
> >
> > Sorry this wont scale. Some machines have thousand of devices.
> >
> > Just make an upper approximation, you dont need an exact one ;)
>
> The route dump does scale, can't you use a similar logic?
> The result doesn't come back as one huge allocation.
> I regularly test 600K routes on small machines.
>
Not sure I understand you Stephen.
In Greg patch, rtnl_calcit() would be called for every 4K/8K block "ip"
gets from kernel.
If you add a function to route dump that would scan the 600K routes to
get the max route size, surely you notice O(N^2) complexity instead of
O(N)
We only need to maintain a global variable to hold min_dump_alloc
[ and only increase this variable when necessary, not bother to decrease
it when removing a driver ]
next prev parent reply other threads:[~2011-05-10 3:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 22:26 [RFC V2 PATCH] rtnetlink: Add method to calculate dump info data size Greg Rose
2011-05-09 22:45 ` Stephen Hemminger
2011-05-09 22:49 ` Rose, Gregory V
2011-05-10 2:43 ` Eric Dumazet
2011-05-10 3:17 ` Stephen Hemminger
2011-05-10 3:45 ` Eric Dumazet [this message]
2011-05-10 3:49 ` David Miller
2011-05-10 4:25 ` Rose, Gregory V
2011-05-10 3:56 ` Stephen Hemminger
2011-05-10 3:58 ` David Miller
2011-05-10 4:03 ` Eric Dumazet
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=1304999127.3050.40.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=gregory.v.rose@intel.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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