🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #3204

[PATCH net-next v4 5/7] vxlan: vnifilter: account per-VNI memory to memcg

#3204
From: Ali Firas
Date: Wed, 14 Oct 2026 12:38
50 lines
10031 bytes
vxlan_vni_alloc() allocates a struct vxlan_vni_node and a per-CPU stats
block for every VNI, both with plain GFP_KERNEL, so neither is charged
to the cgroup of the process that created the VNI. A netdevice's own
struct and its Tx/Rx queues are already GFP_KERNEL_ACCOUNT in
alloc_netdev_mqs() (commit c948f51c1654 ("memcg: enable accounting for
net_device and Tx/Rx queues")), so these per-VNI allocations are an
unaccounted part of a device that a cgroup can grow one VNI at a time.

Charge both to the caller's cgroup with GFP_KERNEL_ACCOUNT in
vxlan_vni_alloc(). __GFP_ACCOUNT only charges an allocation made from a
task in a non-root memcg, so the sole caller, which already handles a
NULL return, is unaffected outside a memcg.

The charge lands in the caller's memcg: adding VNIs from inside one
moves each node into the accounted slab and raises the cgroup's per-CPU
memory. This covers the node and its stats only; a VNI carrying a group
or remote also installs a default FDB entry, whose allocations are not
charged here and are accounted by the next patch.

Assisted-by: LLM
Signed-off-by: Ali Firas <alishmery18@gmail.com>
---
v4: reworded to cover the node and stats only; the
c948f51c1654 reference narrowed to net_device and its Tx/Rx queues;
rebased.

 drivers/net/vxlan/vxlan_vnifilter.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c
index 2999dd536625..4a631fcdf23a 100644
--- a/drivers/net/vxlan/vxlan_vnifilter.c
+++ b/drivers/net/vxlan/vxlan_vnifilter.c
@@ -825,10 +825,11 @@ static struct vxlan_vni_node *vxlan_vni_alloc(struct vxlan_dev *vxlan,
 {
 	struct vxlan_vni_node *vninode;
 
-	vninode = kzalloc_obj(*vninode);
+	vninode = kzalloc_obj(*vninode, GFP_KERNEL_ACCOUNT);
 	if (!vninode)
 		return NULL;
-	vninode->stats = netdev_alloc_pcpu_stats(struct vxlan_vni_stats_pcpu);
+	vninode->stats = __netdev_alloc_pcpu_stats(struct vxlan_vni_stats_pcpu,
+						   GFP_KERNEL_ACCOUNT);
 	if (!vninode->stats) {
 		kfree(vninode);
 		return NULL;
-- 
2.53.0
Technical Details
Message-ID: <20261014123814.388557-6-alishmery18@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346227-linux-kernel-netdev=dewy.ru
References: <20261014123814.388557-1-alishmery18@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346227-linux-kernel-netdev=dewy.ru
From: alishmery18@gmail.com (Ali Firas)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v4 5/7] vxlan: vnifilter: account per-VNI memory to memcg
Date: Wed, 14 Oct 2026 15:38:12 +0300
Organization: Usenet Network
Message-ID: <20261014123814.388557-6-alishmery18@gmail.com>
References: <20261014123814.388557-1-alishmery18@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2292888"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:r3POk3NYm2yw6pvpp6nMegjcsC0= sha256:ca+SDGHMLaT2/VhpxohmIojBpAOAmNNxfcRbJ4isXkM=
	sha1:EkbAWSbnEAXxFt1hpyXWq0Y+3WI= sha256:0dWWdYZIJ7ezh1zjVEAFBc0qKI63zv2GQTazI1FkR9A=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 2AA0B1100EC; Wed, 14 Oct 2026 15:43:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.848
X-Spam-Status: No, score=-0.848 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 1YCzFugETXih;
	Wed, 14 Oct 2026 15:43:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-346227-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 4DAD11100DE; Wed, 14 Oct 2026 15:43:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sto.lore.kernel.org (Postfix) with ESMTP id 69A91604446; Wed, 14 Oct 2026 12:40:20 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 357714DE727;
	Wed, 14 Oct 2026 12:40:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g8DlRiAq"
X-Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AE034E325D
	for <netdev@vger.kernel.org>; Wed, 14 Oct 2026 12:40:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791981618; cv=none; b=JKPLKXhcCpd/IkTZetPHXFXnAdSGcHOqhqSZBYPM0+wSN6+AzKTs2kQ6735ZuxsPjrvgUqVZkpUme7Y9iAo+jkslZ8wb1OGGs7AobKjTj4DzFxV9+tEFXdL0c1irCHj7OAIxNA7AmHvdctIzIP17Br2KBDxGIh9SW1R9ddbCi/0=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791981618; c=relaxed/simple;
	bh=wNXTzoBCRrjBH+Z97Yn4B/LpSXjRiTvMR9N5NBkt17M=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=GkeMUa/o7d2lsj7ue139NKGqGGpvBPr2vFXwfZdtXJwVzvxoDfceuN6Ssr1buVRb+DIz4iX9wuHenUTo6vPl/6sgLDJMi2zV+e7wNPrYO2Nr1FALQvWyM0Y+ePmbILxtqVYzKmKwBIwp7VY3EdZLexpAuOqdM9XOkCiOIwrkfZw=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g8DlRiAq; arc=none smtp.client-ip=209.85.221.53
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-48b060ec084so2666204f8f.0
        for <netdev@vger.kernel.org>; Wed, 14 Oct 2026 05:40:13 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1791981610; x=1792586410; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=z3ZOxRV/kduEE71z1H7/WaoBF6Ffe2PveVQAPTO2Vls=;
        b=g8DlRiAqfuNYNJfRC5/WVTksJwPTfv/UnVx/FW6s/UoV6mJ5B6guBEbQQI5ZlHTmsW
         yEuR9GjIr1/hngWF1YPv7QqeRDq7mv8g2YB8PpRBSQKeSR9Lx3a5cAqt5vdHFkuLaIM6
         ZZXFfKAKm+/HcuEtZNwUEplX7uHKOm2yVNlCt7Pzqh4/wRj58qWarG/+nKk17/w6VoXk
         TyTyGHiH42j8+M4+PLuJK39i2sMVKtf6g113NfpFJWubp6Pm4p0gJHgVbxjflnurGBZX
         O9jszhm20cLqRFf92QbsD1fLoePYZEO0c1MfpK9vB1oPRcrjmhnqrsuxZXfnwoQyQS6M
         egfQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1791981610; x=1792586410;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=z3ZOxRV/kduEE71z1H7/WaoBF6Ffe2PveVQAPTO2Vls=;
        b=OO3SPK8z5FRXYz1TuNc6BDfqVQcYeIpueFG+8RqhM1B6DiXz9UqrHPL/9IJsuwxor6
         4dDmyRM5HR5eDQIdSrwbLMRcpThEhxFZw5og7rWSK/KYlDIbN1SSewahaEIwE5YX69NZ
         M1dBz5mq5PYr1SN/Vbs1DDLVOMNsa2NWi1Pho6VECduAZ7AjT9khBwKg3vMzsb8Pk/6p
         Q/X7qi3rMKz/lBlcJXTjAJSlte+AiEOvclLEfNgXYeLplDtFNiP2eWKIvehf6lWIDEHI
         drtkozLSCOl8y48LIiu/vS+pFDEk9rCfCAfV8IfMf8yx/W8TLbo+CVaF7djxqVaNMCje
         7A5Q==
X-Gm-Message-State: AFq9FYLNDXmMLiS9Jt6ifT5686m4qM1SJ+5WWS2XJleaP5OqteARi4Y5
	3erZdz5ccGC/rVxgTAcG1drsoCTt95Y9KPdnurjmRNCPt9anb7pAC9XN0nqIDDobUYE=
X-Gm-Gg: AYBFou1JjiuXaJdYE9z8Q5qD7tAbox08Ynq5qb2YnMwN4p1/+6+u3PafZwF8/y6D4rA
	Jg/ulZpSY+ASh/Z1ZvoFUelVXd5o+rZs0yJ65lu4Fy6gc3IlNOd4dvCKdWzxfuycEveXFXgcq/N
	hhcooi1dTSxYYfl2OoHxG2bwDS72ywcxcDEUEQbvYosucNCU2gUUQDYrhkLSk2M0amBPV4pEjI9
	c8it4utQvUCCouy7D50SVEkVDitVPKUa3xghX7Ik1jhqY9JjK75qPBPpl2NIir3g6BzIGmJ8L32
	Nn/T9bH7t+NHOIHOXEONjZ36B0AErNFO+SXWcAUSaGqpgjs/eFmbSDza5v78NiOVkz9WiS8Uow+
	DrKjWWZqRRTag7Wf2bj7zd7zKOaQ6CtOjqdpiPwiYA+h/RTKxSvk+df4FlkDGDubdUDsfALG2gi
	4PjIwOJwrbgJX3h7xUVy7dQdPfyx0FZFtDkIjVdx6t/755YBvC3VJTm38dDCZUIoU=
X-Received: by 2002:a05:600c:8b65:b0:49e:6683:d23c with SMTP id 5b1f17b1804b1-4a18e3ef1bdmr287671205e9.0.1791981610296;
        Wed, 14 Oct 2026 05:40:10 -0700 (PDT)
X-Received: from kali ([169.224.126.44])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1b2ec47fcsm54163165e9.1.2026.10.14.05.40.07
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 14 Oct 2026 05:40:09 -0700 (PDT)
X-Cc: kuba@kernel.org,
	pabeni@redhat.com,
	davem@davemloft.net,
	edumazet@google.com,
	andrew+netdev@lunn.ch,
	horms@kernel.org,
	razor@blackwall.org,
	roopa@nvidia.com,
	shuah@kernel.org,
	linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Ali Firas <alishmery18@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261014123814.388557-1-alishmery18@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>