🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17487

Re: [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb bytes per queue

#17487
From: Florian Westphal
Date: Mon, 16 Nov 2026 22:46
42 lines
9173 bytes
Alireza Asgari via B4 Relay <devnull+alireza.asgari.net@kernel.org> wrote:
> --- a/net/netfilter/nfnetlink_queue.c
> +++ b/net/netfilter/nfnetlink_queue.c
> @@ -92,6 +92,8 @@ struct nfqnl_instance {
>  	unsigned int	queue_total;
>  	unsigned int	id_sequence;		/* 'sequence' of pkt ids */
>  	struct list_head queue_list;		/* packets in queue */
> +	u64 mem_limit;
> +	u64 mem_used;

I think u32 is fine for those.  Or do you see a use case for 2**32 mbyte
worth of queued packets?

> +/* All release paths use the saved admission cost, including notification undo. */
> +static void nfqnl_mem_uncharge(struct nfqnl_instance *queue,
> +			       struct nf_queue_entry *entry)
> +{
> +	lockdep_assert_held(&queue->lock);
> +	queue->mem_used -= entry->truesize;
> +	entry->truesize = 0;
> +}
> +
>  static struct nfqnl_instance *
>  instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)
>  {
> @@ -152,6 +176,7 @@ instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)
>  	inst->queue_num = queue_num;
>  	inst->peer_portid = portid;
>  	inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
> +	inst->mem_limit = nfqnl_mem_limit(NFQNL_QMAX_DEFAULT);
>  	inst->copy_range = NFQNL_MAX_COPY_RANGE;
>  	inst->copy_mode = NFQNL_COPY_NONE;
>  	spin_lock_init(&inst->lock);
> @@ -199,6 +224,7 @@ static void instance_destroy_work(struct work_struct *work)
>  	rcu_read_lock();
>  	nfqnl_flush(inst, NULL, 0);
>  	rcu_read_unlock();
> +	WARN_ON_ONCE(inst->mem_used);

I'd suggest DEBUG_NET_WARN_ONCE() here, unless you have a strong
preference/reason for a full splat here.
Technical Details
Message-ID: <avuHxb9In-dIYj_G@strlen.de>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364779-linux-kernel-netdev=dewy.ru
References: <20261115-b4-nfqueue-memory-accounting-v1-0-b9cc30819997@asgari.net> <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364779-linux-kernel-netdev=dewy.ru
From: fw@strlen.de (Florian Westphal)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb
 bytes per queue
Date: Mon, 16 Nov 2026 23:46:29 +0100
Organization: Usenet Network
Message-ID: <avuHxb9In-dIYj_G@strlen.de>
References: <20261115-b4-nfqueue-memory-accounting-v1-0-b9cc30819997@asgari.net>
 <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2185612"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+IDttwHO2U1X72V1GOKoUACRNUg= sha256:nOrdbhPYHMSqKZBp2YvvmZMYeoUqa7VrDLkcLuM3AKM=
	sha1:Ty2Ql4pDAVV2shfBSl+l/QJvYDo= sha256:wg12yiXO0K7g1N1gybePFzC6jnQwwsN5+F2f0/LQs5Q=
Content-Disposition: inline
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 1D0DD114D97; Tue, 17 Nov 2026 01:47:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
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 tRHX8KCLtL2x;
	Tue, 17 Nov 2026 01:46:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364779-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=strlen.de
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 52FD9114D81; Tue, 17 Nov 2026 01:46:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 766042B774; Mon, 16 Nov 2026 22:46:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794869201;
	b=EiiSDQxCdFoq0D9uCc55+frr7QVnK9z7P6ogRo+/F7sx8LBxUKrz+wczL1pRWOhqfTdC
	 WgMezhM+hiyXA0ZTQd6xrAej5xoruoHBSIlDL/nZWSlFDY5yrYXjYgOCIGgnWz1s8/NWo
	 dnqh2PctjJ7wL7njbQFXYTXlLwvfRRdelDjR4O3K9trvLHC0QYxsS8GlSxVK3z8dMI2nI
	 yVJGYW8Zd427pj5WRrIdYc4GjZLRDkiJ2lKk0qptj6y9QOpUYnaVaQ2BzOQNLcmCYgi4q
	 jTof6sRVTT6jgoqQAazB2kvXsYtbQSxYr2/QZ/Dc1f/pb5AELasHWixF89jBZnMw1LA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794869201;
	h=X-Original-To:Received:DMARC-Filter:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To;
	bh=jqSwoAjsDQRdlLqv7HFSYNZ2dAycXMwZNoLGHbmfdsw=;
	b=IlqW5ZYhTId8ljqz9U0iBDVeTxttSENXI189SY1GPiCG33f0d6wNtd6YGLr39YzjXuTb
	 cmHoTSxeepIi2KUwS8M5DiUWk5cJ0eTySk/EL9iThWM2nIFUQX0W5Xa86ZmTk2sDmI2Jh
	 FVLuGnY5NXj/DeJTP8bbKZUJ/KEKHsPANhucN8ugDgPxtrb15UOGkdHzzYqeGNAuRJsYr
	 WCUCER1yOsT5akGadaWGs/8bsYkJCOESKUIHX01eRS1YRb9X5hFONkq1sRvq8hjgICQfB
	 Ok3sriDqiGW9fs9JmSIabnLFFsf2w3/mVoi3pTO/iCoaDH98x0rQnTzSTq+eHl4wlsg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=strlen.de;
	spf=pass smtp.mailfrom=strlen.de;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D781606A332;
	Mon, 16 Nov 2026 22:46:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.216.245.30
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794869195;
	b=jQja6/sFmfijt/H+0TDEl01Uij0NdaDdVhMpLYc0/gYFy6QjQfSUBmLfo/A8wpoXk+1d
	 0IxfYKdcyVf1NLAMplGtxe1bp4c3cOaJmuu01gApN8kiH7Xn8V0lMlq8GuJvhoBi5CtJr
	 Qcb++tFmN+eIo/mdHZD45xtlTxb+BF9VkFM/1JI/aIQs9OM00pSCzKPJiG+ZS5mqPNfLK
	 RCgEpK6jWuZ0q+5zZpcdF5aoWgkxPOYy7PKcAQZE0GkhuLm9H1/lkGbo0a5MN4VJJ2pZ6
	 +OMkHvf1PX5Zhjru/lFX0n1lEYrWFrC4rUo7zfmU4CUJ3Jy0oSA+oQZRu3VbSNyUGsw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794869195;
	h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=jqSwoAjsDQRdlLqv7HFSYNZ2dAycXMwZNoLGHbmfdsw=;
	b=J+q6xif0AUu8Hdp8v/aeeVOUlX0gpa/Uf4R+bYKkrToZsWVPZ42kDogxcq3Al1AbkmQd
	 ot1xfd1uErOOpEEKNxOijFATw016MKYogTTAaFReGXM4yhntgEn80Ijo42pmIUDxnQ7D2
	 vjUoaFZGn9QPyGCOeLdK/guvaJ+T0q75peY6nY+8hmMTeVTQ0f02UdSiWM8v2rp0Ocf4n
	 qT+vplNQitk5saVuRMIzriqBnSkbzL9CBOmWqoH49G0REdn2sHnwFQRtR3s1aGXVEp0RW
	 ZITjNsFGMp/jxnct4bNojQsYi1O0wddRh9+gXuQbr1LT2Ca1dOBaSbxdRtRnnAHZ8rg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=strlen.de;
	spf=pass smtp.mailfrom=strlen.de;
	arc=none smtp.remote-ip=91.216.245.30
X-Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82B8A606A323;
	Mon, 16 Nov 2026 22:46:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82B8A606A323
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de
X-Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)
	id 6663260D56; Mon, 16 Nov 2026 23:46:32 +0100 (CET)
X-Cc: netfilter-devel@vger.kernel.org, linux-mm@kvack.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>, Phil Sutter <phil@nwl.cc>,
	Shuah Khan <shuah@kernel.org>, Tejun Heo <tj@kernel.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Chris Down <chris@chrisdown.name>,
	Zhang Jiao <zhangjiao2@cmss.chinamobile.com>,
	Song Hu <husong@kylinos.cn>, cgroups@vger.kernel.org,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net>