Re: [PATCH net-next v2 17/17] net: Kill MSG_SENDPAGE_NOTLAST

From: Willem de Bruijn
Date: Tue Jun 20 2023 - 08:59:27 EST


David Howells wrote:
> Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx> wrote:
>
> > Is it intentional to add MSG_MORE here in this patch?
> >
> > I do see that patch 3 removes this branch:
>
> Yeah. I think I may have tcp_bpf a bit wrong with regard to handling
> MSG_MORE.
>
> How about the attached version of tcp_bpf_push()?
>
> I wonder if it's save to move the setting of MSG_SENDPAGE_NOPOLICY out of the
> loop as I've done here. The caller holds the socket lock.
>
> Also, I'm not sure whether to take account of apply/apply_bytes when setting
> MSG_MORE mid-message, or whether to just go on whether we've reached
> sge->length yet. (I'm not sure exactly how tcp_bpf works).

I'm not very familiar with it either.

Instead of inferring whether MSG_MORE is safe to set, as below, sufficient to
rely on the caller to pass it when appropriate?

size = min(apply_bytes, sge->length). I doubt that size < apply_bytes is
ever intended.

And instead of this former branch

if (flags & MSG_SENDPAGE_NOTLAST)
msghdr.msg_flags |= MSG_MORE;

update any caller to pass MSG_MORE instead of MSG_SENDPAGE_NOTLAST, if not yet
done so.

> msghdr.msg_flags = flags;
>
> /* Determine if we need to set MSG_MORE. */
> if (!(msghdr.msg_flags & MSG_MORE)) {
> if (apply && size < apply_bytes)
> msghdr.msg_flags |= MSG_MORE;
> else if (!apply && size < sge->length &&
> msg->sg.start != msg->sg.end)
> msghdr.msg_flags |= MSG_MORE;
> }