2022-04-27 11:43:01

by Vasily Averin

[permalink] [raw]
Subject: [PATCH] memcg: enable accounting for veth queues

veth netdevice defines own rx queues and allocates array containing
up to 4095 ~750-bytes-long 'struct veth_rq' elements. Such allocation
is quite huge and should be accounted to memcg.

Signed-off-by: Vasily Averin <[email protected]>
---
drivers/net/veth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index d29fb9759cc9..bd67f458641a 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1310,7 +1310,7 @@ static int veth_alloc_queues(struct net_device *dev)
struct veth_priv *priv = netdev_priv(dev);
int i;

- priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL);
+ priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL_ACCOUNT);
if (!priv->rq)
return -ENOMEM;

--
2.31.1


2022-04-27 17:26:16

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] memcg: enable accounting for veth queues

On Wed, 27 Apr 2022 13:34:29 +0300 Vasily Averin wrote:
> Subject: [PATCH] memcg: enable accounting for veth queues

This is a pure networking patch, right? The prefix should be "net: ",
I think.

> veth netdevice defines own rx queues and allocates array containing
> up to 4095 ~750-bytes-long 'struct veth_rq' elements. Such allocation
> is quite huge and should be accounted to memcg.
>
> Signed-off-by: Vasily Averin <[email protected]>

2022-04-28 01:57:48

by Vasily Averin

[permalink] [raw]
Subject: Re: [PATCH] memcg: enable accounting for veth queues

On 4/27/22 19:58, Jakub Kicinski wrote:
> On Wed, 27 Apr 2022 13:34:29 +0300 Vasily Averin wrote:
>> Subject: [PATCH] memcg: enable accounting for veth queues
>
> This is a pure networking patch, right? The prefix should be "net: ",
> I think.
Thank you for the remark, I'll fix it.

Initially it was a part of the patch accounted resources accounted
when creating a new netdevice, but then I moved this piece to
a separate patch, because unlike other cases, it is specific to veth.

Thank you,
Vasily Averin

2022-05-03 01:12:15

by Vasily Averin

[permalink] [raw]
Subject: [PATCH net] net: enable memcg accounting for veth queues

veth netdevice defines own rx queues and allocates array containing
up to 4095 ~750-bytes-long 'struct veth_rq' elements. Such allocation
is quite huge and should be accounted to memcg.

Signed-off-by: Vasily Averin <[email protected]>
---
drivers/net/veth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index d29fb9759cc9..bd67f458641a 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1310,7 +1310,7 @@ static int veth_alloc_queues(struct net_device *dev)
struct veth_priv *priv = netdev_priv(dev);
int i;

- priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL);
+ priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL_ACCOUNT);
if (!priv->rq)
return -ENOMEM;

--
2.31.1