Skip to contentSkip to conversation

veth: Free queues on link delete

PATCH Superseded [email protected] 4 participants 4 messages Aug 15, 2018 – Aug 16, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 veth: Free queues on link delete

From: David Ahern <[email protected]>

kmemleak reported new suspected memory leaks.

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff880130b6ec00 (size 1024):
  comm "ip", pid 916, jiffies 4296194668 (age 7251.672s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000001ed37cc9>] kmemleak_alloc+0x70/0x94
    [<00000000646dfdeb>] slab_post_alloc_hook+0x42/0x52
    [<0000000004aba61b>] __kmalloc+0x101/0x142
    [<0000000054d50e21>] kmalloc_array.constprop.20+0x1e/0x26 [veth]
    [<000000008238855a>] veth_newlink+0x147/0x3ac [veth]
...

The allocation in question is veth_alloc_queues.

Free the queues on a delete.

Fixes 638264dc90227 ("veth: Support per queue XDP ring")
---
 drivers/net/veth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/veth.c +1 -0
index e3202af72df5..bef7d212f04e 100644
@@ -1205,6 +1205,7 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
 	struct veth_priv *priv;
 	struct net_device *peer;
 
+	veth_free_queues(dev);
 	priv = netdev_priv(dev);
 	peer = rtnl_dereference(priv->peer);
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 17 lines · On 2018/08/15 7:36, [email protected] wrote:

From: David Ahern <[email protected]>

kmemleak reported new suspected memory leaks.

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff880130b6ec00 (size 1024):
  comm "ip", pid 916, jiffies 4296194668 (age 7251.672s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000001ed37cc9>] kmemleak_alloc+0x70/0x94
    [<00000000646dfdeb>] slab_post_alloc_hook+0x42/0x52
    [<0000000004aba61b>] __kmalloc+0x101/0x142
    [<0000000054d50e21>] kmalloc_array.constprop.20+0x1e/0x26 [veth]
    [<000000008238855a>] veth_newlink+0x147/0x3ac [veth]
...
Quoted 3 lines

The allocation in question is veth_alloc_queues.

Free the queues on a delete.

Oops, thanks for catching this.

Quoted 11 lines
Fixes 638264dc90227 ("veth: Support per queue XDP ring")
---
 drivers/net/veth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/veth.c +0 -0
index e3202af72df5..bef7d212f04e 100644

drivers/net/veth.c static void veth_dellink(struct net_device *dev, struct list_head *head) · line 1210

Quoted 6 lines
drivers/net/veth.c +1 -0
@@ -1205,6 +1205,7 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
 	struct veth_priv *priv;
 	struct net_device *peer;
 
+	veth_free_queues(dev);
 	priv = netdev_priv(dev);
 	peer = rtnl_dereference(priv->peer);

We need to free up peer queues as well.
Also isn't this for net-next though it is now closed?

Signature · 1 line
Toshiaki Makita
#2 lore raw
Quoted 38 lines · Toshiaki Makita
Quoted 17 lines · On 2018/08/15 7:36, [email protected] wrote:

From: David Ahern <[email protected]>

kmemleak reported new suspected memory leaks.

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff880130b6ec00 (size 1024):
  comm "ip", pid 916, jiffies 4296194668 (age 7251.672s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000001ed37cc9>] kmemleak_alloc+0x70/0x94
    [<00000000646dfdeb>] slab_post_alloc_hook+0x42/0x52
    [<0000000004aba61b>] __kmalloc+0x101/0x142
    [<0000000054d50e21>] kmalloc_array.constprop.20+0x1e/0x26 [veth]
    [<000000008238855a>] veth_newlink+0x147/0x3ac [veth]
...
Quoted 3 lines

The allocation in question is veth_alloc_queues.

Free the queues on a delete.

Oops, thanks for catching this.

Quoted 14 lines
Fixes 638264dc90227 ("veth: Support per queue XDP ring")
---
 drivers/net/veth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/veth.c +0 -0
index e3202af72df5..bef7d212f04e 100644
@@ -1205,6 +1205,7 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
 	struct veth_priv *priv;
 	struct net_device *peer;
 
Quoted 5 lines

drivers/net/veth.c static void veth_dellink(struct net_device *dev, struct list_head *head) · line 1210

Quoted 3 lines
drivers/net/veth.c +1 -0
+	veth_free_queues(dev);
 	priv = netdev_priv(dev);
 	peer = rtnl_dereference(priv->peer);

We need to free up peer queues as well.

missed that. Odd that kmemleak was not complaining.

Quoted 2 lines

Also isn't this for net-next though it is now closed?

yes. was not sure if net-next is now net.

will send a v2.

#3 lore raw
In reply to [email protected]
I love your patch! Yet something to improve:

Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]

url: https://github.com/0day-ci/linux/commits/dsahern-kernel-org/veth-Free-queues-on-link-delete/20180816-073955
config: i386-randconfig-x016-201832 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

drivers//net/veth.c: In function 'veth_dellink':

>> drivers//net/veth.c:476:2: error: implicit declaration of function 'veth_free_queues'; did you mean 'veth_dev_free'? [-Werror=implicit-function-declaration]
     veth_free_queues(dev);
     ^~~~~~~~~~~~~~~~
     veth_dev_free

cc1: some warnings being treated as errors

vim +476 drivers//net/veth.c

470
471 static void veth_dellink(struct net_device *dev, struct list_head *head)
472 {
473 struct veth_priv *priv;
474 struct net_device *peer;
475

 > 476		veth_free_queues(dev);

477 priv = netdev_priv(dev);
478 peer = rtnl_dereference(priv->peer);
479
480 /* Note : dellink() is called from default_device_exit_batch(),
481 * before a rcu_synchronize() point. The devices are guaranteed
482 * not being freed before one RCU grace period.
483 */
484 RCU_INIT_POINTER(priv->peer, NULL);
485 unregister_netdevice_queue(dev, head);
486
487 if (peer) {
488 priv = netdev_priv(peer);
489 RCU_INIT_POINTER(priv->peer, NULL);
490 unregister_netdevice_queue(peer, head);
491 }
492 }
493

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation