Netdev List
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <avuHxb9In-dIYj_G@strlen.de> (raw)
In-Reply-To: <20261115-b4-nfqueue-memory-accounting-v1-6-b9cc30819997@asgari.net>

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.

  reply	other threads:[~2026-11-16 22:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 22:34 [PATCH RFC nf-next 0/9] netfilter: nfqueue: account queued memory and reserve capacity Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 1/9] memcg: saturate deferred memory.high page debt Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 2/9] memcg: bound memory.high delay arithmetic Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 3/9] memcg: add KUnit coverage for memory.high accounting Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 4/9] memcg: add an owner-bound capacity reservation interface Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 5/9] memcg: test capacity reservation rollback and refunds Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 6/9] netfilter: nfqueue: account saved skb bytes per queue Alireza Asgari via B4 Relay
2026-11-16 22:46   ` Florian Westphal [this message]
2026-11-15 22:34 ` [PATCH RFC nf-next 7/9] netfilter: nfqueue: reserve capacity against the bound owner Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 8/9] netfilter: nfqueue: add KUnit memory accounting coverage Alireza Asgari via B4 Relay
2026-11-15 22:34 ` [PATCH RFC nf-next 9/9] selftests: netfilter: exercise nfqueue memory accounting Alireza Asgari via B4 Relay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avuHxb9In-dIYj_G@strlen.de \
    --to=fw@strlen.de \
    --cc=akpm@linux-foundation.org \
    --cc=alireza@asgari.net \
    --cc=cgroups@vger.kernel.org \
    --cc=chris@chrisdown.name \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=husong@kylinos.cn \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    --cc=vdavydov.dev@gmail.com \
    --cc=zhangjiao2@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox