From: Zijian Zhang <zijianzhang@bytedance.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: netdev@vger.kernel.org, linux-api@vger.kernel.org,
almasrymina@google.com, edumazet@google.com, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org,
axboe@kernel.dk, shuah@kernel.org,
linux-kselftest@vger.kernel.org, cong.wang@bytedance.com,
xiaochun.lu@bytedance.com
Subject: Re: [PATCH net-next v8 3/3] selftests: add MSG_ZEROCOPY msg_control notification test
Date: Thu, 1 Aug 2024 11:15:11 -0700 [thread overview]
Message-ID: <bd81277b-a443-461d-9bad-5688c7d8565d@bytedance.com> (raw)
In-Reply-To: <CAF=yD-Jt6XWSCLfZE1C+9=vcXyG-XcC2q-7Ai-HHSUt=1OrWsg@mail.gmail.com>
On 8/1/24 10:36 AM, Willem de Bruijn wrote:
> On Thu, Aug 1, 2024 at 1:30 PM Zijian Zhang <zijianzhang@bytedance.com> wrote:
>>>
>>>> -static bool do_sendmsg(int fd, struct msghdr *msg, bool do_zerocopy, int domain)
>>>> +static void add_zcopy_info(struct msghdr *msg)
>>>> +{
>>>> + struct zc_info *zc_info;
>>>> + struct cmsghdr *cm;
>>>> +
>>>> + if (!msg->msg_control)
>>>> + error(1, errno, "NULL user arg");
>>>
>>> Don't add precondition checks for code entirely under your control.
>>> This is not a user API.
>>>
>>
>> Ack.
>>
>>>> + cm = (struct cmsghdr *)msg->msg_control;
>>>> + cm->cmsg_len = CMSG_LEN(ZC_INFO_SIZE);
>>>> + cm->cmsg_level = SOL_SOCKET;
>>>> + cm->cmsg_type = SCM_ZC_NOTIFICATION;
>>>> +
>>>> + zc_info = (struct zc_info *)CMSG_DATA(cm);
>>>> + zc_info->size = ZC_NOTIFICATION_MAX;
>>>> +
>>>> + added_zcopy_info = true;
>>>
>>> Just initialize every time? Is this here to reuse the same msg_control
>>> as long as metadata is returned?
>>>
>>
>> Yes, the same msg_control will be reused.
>>
>> The overall paradiagm is,
>> start:
>> sendmsg(..)
>> sendmsg(..)
>> ... sends_since_notify sendmsgs in total
>>
>> add_zcopy_info(..)
>> sendmsg(.., msg_control)
>> do_recv_completions_sendmsg(..)
>> goto start;
>>
>> if (sends_since_notify + 1 >= cfg_notification_limit), add_zcopy_info
>> will be invoked, and the right next sendmsg will have the msg_control
>> passed in.
>>
>> If (added_zcopy_info), do_recv_completions_sendmsg will be invoked,
>> and added_zcopy_info will be set to false in it.
>
> This does not seem like it would need a global variable?
>
Agreed, maybe I can use sends_since_notify to check whether we
need to do_recv_completions_sendmsg, then we get rid of
added_zcopy_info.
>> Btw, before I put some efforts to solve the current issues, I think
>> I should wait for comments about api change from linux-api@vger.kernel.org?
>
> I'm not sure whether anyone on that list will give feedback.
>
> I would continue with revisions at a normal schedule, as long as that
> stays in the Cc.
Got it, thanks
prev parent reply other threads:[~2024-08-01 18:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 18:41 [PATCH net-next v8 0/3] net: A lightweight zero-copy notification mechanism for MSG_ZEROCOPY zijianzhang
2024-07-30 18:41 ` [PATCH net-next v8 1/3] sock: support copying cmsgs to the user space in sendmsg zijianzhang
2024-07-30 18:41 ` [PATCH net-next v8 2/3] sock: add MSG_ZEROCOPY notification mechanism based on msg_control zijianzhang
2024-07-31 22:20 ` Willem de Bruijn
2024-08-01 1:29 ` Jakub Kicinski
2024-08-01 17:52 ` Willem de Bruijn
2024-07-30 18:41 ` [PATCH net-next v8 3/3] selftests: add MSG_ZEROCOPY msg_control notification test zijianzhang
2024-07-31 22:32 ` Willem de Bruijn
2024-08-01 17:30 ` Zijian Zhang
2024-08-01 17:36 ` Willem de Bruijn
2024-08-01 18:15 ` Zijian Zhang [this message]
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=bd81277b-a443-461d-9bad-5688c7d8565d@bytedance.com \
--to=zijianzhang@bytedance.com \
--cc=almasrymina@google.com \
--cc=axboe@kernel.dk \
--cc=cong.wang@bytedance.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xiaochun.lu@bytedance.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