* [PATCH 1/2] netprio_cgroup: Remove update_netdev_tables() since it is unnecessary
@ 2012-09-11 11:22 Srivatsa S. Bhat
2012-09-11 11:22 ` [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly Srivatsa S. Bhat
0 siblings, 1 reply; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-09-11 11:22 UTC (permalink / raw)
To: davem, nhorman
Cc: john.r.fastabend, gaofeng, eric.dumazet, mark.d.rustad, lizefan,
netdev, linux-kernel, Srivatsa S. Bhat
The update_netdev_tables() function appears to be unnecessary, since the
write_update_netdev_table() function will adjust the priomaps as and when
required anyway. So drop the usage of update_netdev_tables() entirely.
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
net/core/netprio_cgroup.c | 32 --------------------------------
1 files changed, 0 insertions(+), 32 deletions(-)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index c75e3f9..fd339bb0 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -109,32 +109,6 @@ static int write_update_netdev_table(struct net_device *dev)
return ret;
}
-static int update_netdev_tables(void)
-{
- int ret = 0;
- struct net_device *dev;
- u32 max_len;
- struct netprio_map *map;
-
- rtnl_lock();
- max_len = atomic_read(&max_prioidx) + 1;
- for_each_netdev(&init_net, dev) {
- map = rtnl_dereference(dev->priomap);
- /*
- * don't allocate priomap if we didn't
- * change net_prio.ifpriomap (map == NULL),
- * this will speed up skb_update_prio.
- */
- if (map && map->priomap_len < max_len) {
- ret = extend_netdev_table(dev, max_len);
- if (ret < 0)
- break;
- }
- }
- rtnl_unlock();
- return ret;
-}
-
static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
{
struct cgroup_netprio_state *cs;
@@ -153,12 +127,6 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
goto out;
}
- ret = update_netdev_tables();
- if (ret < 0) {
- put_prioidx(cs->prioidx);
- goto out;
- }
-
return &cs->css;
out:
kfree(cs);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly
2012-09-11 11:22 [PATCH 1/2] netprio_cgroup: Remove update_netdev_tables() since it is unnecessary Srivatsa S. Bhat
@ 2012-09-11 11:22 ` Srivatsa S. Bhat
2012-09-11 11:42 ` David Laight
0 siblings, 1 reply; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-09-11 11:22 UTC (permalink / raw)
To: davem, nhorman
Cc: john.r.fastabend, gaofeng, eric.dumazet, mark.d.rustad, lizefan,
netdev, linux-kernel, Srivatsa S. Bhat
* Check for non-NULL old_priomap outside the loop, since its
not going to change.
* Copy the old_priomap's length to a local variable and use
that for loop control, instead of costly pointer-dereferences.
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
net/core/netprio_cgroup.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index fd339bb0..0775bc9 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -73,7 +73,7 @@ static int extend_netdev_table(struct net_device *dev, u32 new_len)
((sizeof(u32) * new_len));
struct netprio_map *new_priomap = kzalloc(new_size, GFP_KERNEL);
struct netprio_map *old_priomap;
- int i;
+ int i, old_len;
old_priomap = rtnl_dereference(dev->priomap);
@@ -82,10 +82,12 @@ static int extend_netdev_table(struct net_device *dev, u32 new_len)
return -ENOMEM;
}
- for (i = 0;
- old_priomap && (i < old_priomap->priomap_len);
- i++)
- new_priomap->priomap[i] = old_priomap->priomap[i];
+ if (old_priomap) {
+ old_len = old_priomap->priomap_len;
+
+ for (i = 0; i < old_len; i++)
+ new_priomap->priomap[i] = old_priomap->priomap[i];
+ }
new_priomap->priomap_len = new_len;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly
2012-09-11 11:22 ` [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly Srivatsa S. Bhat
@ 2012-09-11 11:42 ` David Laight
2012-09-11 15:33 ` Neil Horman
2012-09-12 6:05 ` Srivatsa S. Bhat
0 siblings, 2 replies; 5+ messages in thread
From: David Laight @ 2012-09-11 11:42 UTC (permalink / raw)
To: Srivatsa S. Bhat, davem, nhorman
Cc: john.r.fastabend, gaofeng, eric.dumazet, mark.d.rustad, lizefan,
netdev, linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 596 bytes --]
> - for (i = 0;
> - old_priomap && (i < old_priomap->priomap_len);
> - i++)
> - new_priomap->priomap[i] = old_priomap->priomap[i];
> + if (old_priomap) {
> + old_len = old_priomap->priomap_len;
> +
> + for (i = 0; i < old_len; i++)
> + new_priomap->priomap[i] = old_priomap->priomap[i];
> + }
Or:
memcpy(new_priomap->priomap, old_priomap->priomap,
old_priomap->priomap_len * sizeof old_priomap->priomap[0]);
David
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly
2012-09-11 11:42 ` David Laight
@ 2012-09-11 15:33 ` Neil Horman
2012-09-12 6:05 ` Srivatsa S. Bhat
1 sibling, 0 replies; 5+ messages in thread
From: Neil Horman @ 2012-09-11 15:33 UTC (permalink / raw)
To: David Laight
Cc: Srivatsa S. Bhat, davem, john.r.fastabend, gaofeng, eric.dumazet,
mark.d.rustad, lizefan, netdev, linux-kernel
On Tue, Sep 11, 2012 at 12:42:23PM +0100, David Laight wrote:
> > - for (i = 0;
> > - old_priomap && (i < old_priomap->priomap_len);
> > - i++)
> > - new_priomap->priomap[i] = old_priomap->priomap[i];
> > + if (old_priomap) {
> > + old_len = old_priomap->priomap_len;
> > +
> > + for (i = 0; i < old_len; i++)
> > + new_priomap->priomap[i] = old_priomap->priomap[i];
> > + }
>
> Or:
> memcpy(new_priomap->priomap, old_priomap->priomap,
> old_priomap->priomap_len * sizeof old_priomap->priomap[0]);
>
> David
>
Yes, the memcpy would be better here.
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly
2012-09-11 11:42 ` David Laight
2012-09-11 15:33 ` Neil Horman
@ 2012-09-12 6:05 ` Srivatsa S. Bhat
1 sibling, 0 replies; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-09-12 6:05 UTC (permalink / raw)
To: David Laight
Cc: davem, nhorman, john.r.fastabend, gaofeng, eric.dumazet,
mark.d.rustad, lizefan, netdev, linux-kernel
On 09/11/2012 05:12 PM, David Laight wrote:
>> - for (i = 0;
>> - old_priomap && (i < old_priomap->priomap_len);
>> - i++)
>> - new_priomap->priomap[i] = old_priomap->priomap[i];
>> + if (old_priomap) {
>> + old_len = old_priomap->priomap_len;
>> +
>> + for (i = 0; i < old_len; i++)
>> + new_priomap->priomap[i] = old_priomap->priomap[i];
>> + }
>
> Or:
> memcpy(new_priomap->priomap, old_priomap->priomap,
> old_priomap->priomap_len * sizeof old_priomap->priomap[0]);
>
Ah, indeed that would be better. I'll send out an updated version of the
patches. Thanks!
Regards,
Srivatsa S. Bhat
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-12 6:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11 11:22 [PATCH 1/2] netprio_cgroup: Remove update_netdev_tables() since it is unnecessary Srivatsa S. Bhat
2012-09-11 11:22 ` [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly Srivatsa S. Bhat
2012-09-11 11:42 ` David Laight
2012-09-11 15:33 ` Neil Horman
2012-09-12 6:05 ` Srivatsa S. Bhat
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).