Linux virtualization list
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Longjun Tang <lange_tang@163.com>
Cc: mst@redhat.com, jasowangio@gmail.com, xuanzhuo@linux.alibaba.com,
	virtualization@lists.linux.dev, netdev@vger.kernel.org,
	tanglongjun@kylinos.cn
Subject: Re: [PATCH] virtio_net: add rx-alloc-fail counter
Date: Wed, 12 Aug 2026 16:34:27 -0700	[thread overview]
Message-ID: <20260812163427.3c44ac4d@kernel.org> (raw)
In-Reply-To: <20260812012254.27668-1-lange_tang@163.com>

On Wed, 12 Aug 2026 09:22:54 +0800 Longjun Tang wrote:
> From: tanglongjun <tanglongjun@kylinos.cn>
> 
> Count buffer and skb allocation failures on the rx queue and
> report them via rx-alloc-fail in netdev qstats.

You are not plumbing the new stat into virtnet_get_base_stats()
This may be an entirely reasonable choice if you can't / don't 
want to retain the stats for the entire device (e.g. when queues
get disabled). But please explain the choice in the commit msg.

Please explain your motivation / what made you write this patch.
TBH the patches from KylinOS addresses are often slop so it would
be useful to understand whether your choices here are guided by
production experience, or not.

Last but not least, AI suggests:

> @@ -1917,8 +1919,10 @@ static struct sk_buff *receive_small_xdp(struct net_device *dev,
>  	}
>  
>  	skb = virtnet_build_skb(buf, buflen, xdp.data - buf, len);
> -	if (unlikely(!skb))
> +	if (unlikely(!skb)) {
> +		u64_stats_inc(&stats->alloc_fail);
>  		goto err;
> +	}
>  
>  	if (metasize)
>  		skb_metadata_set(skb, metasize);
The commit message says the patch counts "buffer and skb allocation
failures on the rx queue", and the uAPI description in
Documentation/netlink/specs/netdev.yaml for rx-alloc-fail says "Number of
times skb or buffer allocation failed on the Rx datapath".  Can several
allocation failure sites on the same datapath still be missed?
In this same function the earlier buffer allocation failure is not counted:
	xdp_page = xdp_linearize_page(dev, rq, &num_buf, page,
				      offset, header_offset,
				      &tlen);
	if (!xdp_page)
		goto err_xdp;
and xdp_linearize_page() returns NULL exactly on allocation failure:
	page = page_pool_alloc_pages(rq->page_pool, GFP_ATOMIC);
	if (!page)
		return NULL;
The mergeable XDP path has the same shape in receive_mergeable_xdp():
mergeable_xdp_get_buf() returns NULL when its page_pool_alloc_pages() call
fails, and that goes to err_xdp counting only xdp_drops/drops.
The AF_XDP receive path is not instrumented at all.  xsk_construct_skb(),
called from virtnet_receive_xsk_small() and virtnet_receive_xsk_merge(),
fails like this:
	skb = napi_alloc_skb(&rq->napi, size);
	if (unlikely(!skb)) {
		xsk_buff_free(xdp);
		return NULL;
	}
and xsk_append_merge_buffer() drops the remaining buffers when
napi_alloc_frag() or virtnet_skb_append_frag() fails, again without
touching alloc_fail.
So with an XSK pool bound to a queue, or with an XDP program that needs
linearization, can rx-alloc-fail stay at 0 while memory pressure is
actually causing the drops?
-- 
pw-bot: cr

  reply	other threads:[~2026-08-12 23:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  1:22 [PATCH] virtio_net: add rx-alloc-fail counter Longjun Tang
2026-08-12 23:34 ` Jakub Kicinski [this message]
2026-08-13  2:58   ` Lange Tang
  -- strict thread matches above, loose matches on Subject: below --
2026-08-11  9:10 Longjun Tang
2026-08-11 15:40 ` Jakub Kicinski

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=20260812163427.3c44ac4d@kernel.org \
    --to=kuba@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=lange_tang@163.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=tanglongjun@kylinos.cn \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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