Netdev List
 help / color / mirror / Atom feed
From: Konstantin Shabanov <mail@etehtsea.me>
To: kuba@kernel.org
Cc: corbet@lwn.net, davem@davemloft.net, edumazet@google.com,
	horms@kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, mail@etehtsea.me,
	netdev@vger.kernel.org, pabeni@redhat.com,
	skhan@linuxfoundation.org
Subject: Re: [PATCH] docs: netlink: Correct buffer sizing info
Date: Fri, 15 May 2026 22:57:41 +0700	[thread overview]
Message-ID: <20260515155741.25082-1-mail@etehtsea.me> (raw)
In-Reply-To: <20260512172757.10c43c86@kernel.org>

On Tue, 12 May 2026 17:27:57 -0700 Jakub Kicinski wrote:
> On Tue, 12 May 2026 17:30:53 +0700 Konstantin Shabanov wrote:
> > Update the docs to match the code (include/linux/netlink.h):
> >
> >   /*
> >    *	skb should fit one page. This choice is good for headerless malloc.
> >    *	But we should limit to 8K so that userspace does not have to
> >    *	use enormous buffer sizes on recvmsg() calls just to avoid
> >    *	MSG_TRUNC when PAGE_SIZE is very large.
> >   */
> >   #if PAGE_SIZE < 8192UL
> >   #define NLMSG_GOODSIZE	SKB_WITH_OVERHEAD(PAGE_SIZE)
> >   #else
> >   #define NLMSG_GOODSIZE	SKB_WITH_OVERHEAD(8192UL)
> >   #endif
>
> You should explain what you think the problem is in the commit message.
> Maybe if you did you'd realize you're comparing kernel header comment
> to user space guidance which are (obviously?) the inverse of each
> other..

I thought that the comment is self-explaining:

  * But we should limit to 8K so that userspace does not have to
  *	use enormous buffer sizes on recvmsg() calls just to avoid
  *	MSG_TRUNC when PAGE_SIZE is very large.

The problem is that according to the comment, kernel isn't going to send
more than 8K in a single reply and the documentation is currently recommends the opposite:
to create _at least_ 8K buffer what looks excessive.
Also, the logic in the comment is aligned with userspace libraries (libmnl [1]
and wireguard-tools [2]).

[1]: https://git.netfilter.org/libmnl/tree/include/libmnl/libmnl.h?id=54dea548d796653534645c6e3c8577eaf7d77411#n20
[2]: https://git.zx2c4.com/wireguard-tools/tree/src/netlink.h?id=a998407747005ea7e4e0258d96f105c97241e1d3#n70

  reply	other threads:[~2026-05-15 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 10:30 [PATCH] docs: netlink: Correct buffer sizing info Konstantin Shabanov
2026-05-13  0:27 ` Jakub Kicinski
2026-05-15 15:57   ` Konstantin Shabanov [this message]
2026-05-15 22:51     ` Jakub Kicinski
2026-05-15 23:10 ` patchwork-bot+netdevbpf

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=20260515155741.25082-1-mail@etehtsea.me \
    --to=mail@etehtsea.me \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=skhan@linuxfoundation.org \
    /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