Article View: linux.kernel.netdev
Article #26081Re: [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb bytes per queue
From: Alireza Asgari
Date: Thu, 03 Dec 2026 01:08
Date: Thu, 03 Dec 2026 01:08
73 lines
13635 bytes
13635 bytes
Hi Florian,
Thanks for the review, and sorry for the slow reply.
> I think u32 is fine for those.
I used u64 because the byte allowance is derived from queue_maxlen, and
the multiplication can exceed 4 GiB. I don't have a use case for more
than that in one queue. I'd keep the packet limit as configured, compute
the byte allowance in u64, and cap it at U32_MAX before storing it.
Would that match what you had in mind?
> I'd suggest DEBUG_NET_WARN_ONCE() here, unless you have a strong
> preference/reason for a full splat here.
Agreed. I'll use DEBUG_NET_WARN_ON_ONCE(inst->mem_used) for the teardown
check.
Thanks,
Alireza
From: Florian Westphal <fw@strlen.de>
To: <alireza@asgari.net>
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>
Date: Mon, 16 Nov 2026 23:46:29 +0100
Subject: Re: [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb bytes per queue
> 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:
<1a23971f6b0.1bb54762693766.1734365631840356032@asgari.net>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376190-linux-kernel-netdev=dewy.ruReferences:
<20261115-b4-nfqueue-memory-accounting-v1-0-b9cc30819997@asgari.net> <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net> <avuHxb9In-dIYj_G@strlen.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376190-linux-kernel-netdev=dewy.ru From: alireza@asgari.net (Alireza Asgari) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb bytes per queue Date: Thu, 03 Dec 2026 02:08:19 +0100 Organization: Usenet Network Message-ID: <1a23971f6b0.1bb54762693766.1734365631840356032@asgari.net> References: <20261115-b4-nfqueue-memory-accounting-v1-0-b9cc30819997@asgari.net> <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net> <avuHxb9In-dIYj_G@strlen.de> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2103482"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NIZgNqrnD7piTjzoabpZtVsu0h4= sha256:uSiMiUrX58ERVLXnASXLIyWpBxSMcTJLSKQZMnJ+FF4= sha1:t8jFi9voD9Z5VY01YB6xXs6pkyY= sha256:V6nuixAWgGyUd+haW5BGK/Gwhj7RixJpUVXk27HEjq0= 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 186E61177D8; Thu, 3 Dec 2026 04:10:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.751 X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, 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-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=asgari.net 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 vJGG7jWLkJul; Thu, 3 Dec 2026 04:10:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376190-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=asgari.net X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 4E6651177BD; Thu, 3 Dec 2026 04:09:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E0C572838A; Thu, 3 Dec 2026 01:09:47 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796260187; b=hTjfO74sJB5qCB89AAkdCzJuMEcNlgcfP9RF1jq2H9T83qZjKuR1djdfLglwwVCiBJHn 82YExU9/wG7VwYUHf2VsMUrUr7PfUUh9adcJt6eubjVtebC/W8vIsAsgxNxPFx/DQRvBl d1agGITTZPo6AYQl1AP/7asF4FxGB1oR9ip4LVdzKN8M+/O2gXPbmA8AjQFVHMwdlHeOw aZRXYRTrl7W5hoUdW2kQ411d6fBJihkjUBofaXOP41yDmyb/lW9buGXYU6XkTInvCLpSW VKZ6w2+jZ2tgtfBBt/DrcRzDKxQTJ4LY9jWIOzaOeO9Ri+IQ0O5b4cDFqZNFblQSf7w== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796260187; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date: From:To:Cc:Message-ID:In-Reply-To:References:Subject:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Importance:User-Agent:X-Mailer; bh=MEwSzIkEIpVPg4I9mfscvLcr0NQ1Fkwj39AkpnAhPzE=; b=xdu21wjzV6w2OmZDcpCTTtU9rA15l6MUAwsuEZO/hPotPFkRbZuLMH/cpKwjlI5HFmvP UKCu6NEn+ISj/V5507Kw8KM/J7XkWruiajQnz6airc8QKpMMoReub3LrFSbunpLRAtXil ZWdfObSmQPRLKTbTdk1dfO99aAcnnoZftPHfRuALxD/ljvusgIc20Y70hMt62r46qToyE tatNNKnCaqv1Sp91l5poRo/Avlu1odBEgKSKcfulqkL+dTfMdPGUU1wat1RHagtA0YWsO tah3v/KxWlpxL5RUaRuJCwHHxIoYj5oHZ9mY3Kz1XKQbZ0Ri9Sa1paWvm2zgMMEx/6g== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=asgari.net header.i=@asgari.net header.a=rsa-sha256 header.s=zmail header.b=JcdbxdbZ; dmarc=none header.from=asgari.net; spf=pass smtp.mailfrom=asgari.net; 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 169B7606A32F; Thu, 3 Dec 2026 01:09:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=asgari.net header.i=@asgari.net header.a=rsa-sha256 header.s=zmail header.b=JcdbxdbZ X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=136.143.169.50 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796260176; b=acp3jgPF+gOCJ0D66it/e6G1/cLC9NYJjbBFoR3J84+ePUjxKGChgxAWqUYSlE9mnqDf dv6ZJTM02KQ8hX4Yr3A6f8Lh4wYZkGOzxorXzom1LP5SmOK9FfOBDBQGQ3yHvXjhG+9Hc zhkZLrMkuzRRx1qO/mr2eCgwozfxy0ANzWZ5+3po1Us5ElUOOtGU76kvJq8FPd/1/D2af /2FTlG6VRc6YwGMnXJl8toVVRl57e/m+Wm5r+SUnXBZ3DH0ItyCuCOQQ1UIRPhGJUc+Wl OZrMvgFyidPeB7YbTWAuahV+eCIHFywrKhHS8ctIx3uRU6f74wJDZxvyVLyUBRl6ZZw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796260176; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Message-ID: In-Reply-To:References:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Importance:User-Agent:X-Mailer; bh=MEwSzIkEIpVPg4I9mfscvLcr0NQ1Fkwj39AkpnAhPzE=; b=5imxt4BuB3bwhXkuuXibanx8BoeUknT26J8NXj2jfUQt/uDUGm6JMlASMUro6JEeKFj3 0WLX8B515VLI92Xc5CI3xvnF852gAdIRuz4xLj/WFQk0xOL89WHjF5NRpFVxVOHzYoYq/ h/r6pkaQuH7K+d3El6jpuEekzf8s1ZFDsD0V+fPgCti3hCG0+lUkX4numVFdEEvc/88kF PhC3rCU1LWZn0uF1T3s6B10P4TzgDc52oAPrE3C4l3jh/2MknK+iqcg4POC7TV/DmY2AU pufD0BLtodGCvXVHtTWXACmSbHFb3GvpeMPJ/+6UP83EDcKsI3PsAQ38Yxu6MrupGSA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=asgari.net; spf=pass smtp.mailfrom=asgari.net; dkim=pass header.d=asgari.net header.i=@asgari.net header.a=rsa-sha256 header.s=zmail header.b=JcdbxdbZ; arc=pass header.oldest-pass=0 smtp.remote-ip=136.143.169.50 X-Received: from sender-of-o50.zoho.eu (sender-of-o50.zoho.eu [136.143.169.50]) (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 C6985606A322; Thu, 3 Dec 2026 01:09:34 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C6985606A322 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=asgari.net X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asgari.net X-ARC-Seal: i=1; a=rsa-sha256; t=1796260101; cv=none; d=zohomail.eu; s=zohoarc; b=Wk+1DFh4vwZq5pu3k+lg+9KoWJQls1NYn8mH8H75P842H2THLeg3yKlCSZWQAxCNDuHHoodDxB2kUYGjJS1rUL22virX90McSH34aYBcVUcoGVvr+loDpuTgdps4gFXkpjgmqh0ocJ8L0asLcuGpsntPQ2L1eU2b3J3bY4FBrCM= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1796260101; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=MEwSzIkEIpVPg4I9mfscvLcr0NQ1Fkwj39AkpnAhPzE=; b=Y1ABSj53Qhwo+SGT9Xp3/kntbAe3nkO8600lB8Qz+i1B22wTV0Zs3PTL25BQo7XFobcwSB7qe1dx2zJtdT9TAneR2DDkqC8bQMKal2fgAAsAjnI7zCuv5P80xK4Wa6PBi8any2cEMGSE8+k1BXBkod8qxXeHxNdFP7/wceBXDf8= X-ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=asgari.net; spf=pass smtp.mailfrom=alireza@asgari.net; dmarc=pass header.from=<alireza@asgari.net> X-DKIM-Signature: a=rsa-sha256; b=JcdbxdbZD41WQUrCUTrSLKenrfDUEHkrasV0u6p7uhnOrct8SPkwHNS4vlHihoWwetyP3p7t+2WMAK6sYPC/onAIx1z84Do7TGZDQYYc1fqt+NN2+LznxVgrevrxD85XrhF6tONR+nurjP3yzzOtPQmprvC2QrrxjbJDabuNf/Q=; c=relaxed/relaxed; s=zmail; d=asgari.net; v=1; bh=MEwSzIkEIpVPg4I9mfscvLcr0NQ1Fkwj39AkpnAhPzE=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; X-Received: from mail.zoho.eu by mx.zoho.eu with SMTP id 1796260099785260.68242869912706; Thu, 3 Dec 2026 02:08:19 +0100 (CET) X-Cc: "netfilter-devel" <netfilter-devel@vger.kernel.org>, "linux-mm" <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" <cgroups@vger.kernel.org>, "netdev" <netdev@vger.kernel.org>, "linux-kselftest" <linux-kselftest@vger.kernel.org> X-In-Reply-To: <avuHxb9In-dIYj_G@strlen.de> 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-Importance: Medium X-User-Agent: Zoho Mail X-Mailer: Zoho Mail