From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Willem de Bruijn <willemb@google.com>, Jason Wang <jasowang@redhat.com>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Shuah Khan <shuah@kernel.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org,
linux-kselftest@vger.kernel.org,
Yuri Benditovich <yuri.benditovich@daynix.com>,
Andrew Melnychenko <andrew@daynix.com>,
Stephen Hemminger <stephen@networkplumber.org>,
gur.stavi@huawei.com, devel@daynix.com
Subject: Re: [PATCH net v3 9/9] tap: Use tun's vnet-related code
Date: Tue, 21 Jan 2025 14:27:12 +0900 [thread overview]
Message-ID: <92675e51-cbaf-4905-8cf8-dff741a26db9@daynix.com> (raw)
In-Reply-To: <CA+FuTSec1z7-8nNNc1ZXkzekDrFHPnvYKFf8PNZg89VuwhoWSw@mail.gmail.com>
On 2025/01/20 20:19, Willem de Bruijn wrote:
> On Mon, Jan 20, 2025 at 1:37 AM Jason Wang <jasowang@redhat.com> wrote:
>>
>> On Fri, Jan 17, 2025 at 6:35 PM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>>>
>>> On 2025/01/17 18:23, Willem de Bruijn wrote:
>>>> Akihiko Odaki wrote:
>>>>> tun and tap implements the same vnet-related features so reuse the code.
>>>>>
>>>>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>>>>> ---
>>>>> drivers/net/Kconfig | 1 +
>>>>> drivers/net/Makefile | 6 +-
>>>>> drivers/net/tap.c | 152 +++++--------------------------------------------
>>>>> drivers/net/tun_vnet.c | 5 ++
>>>>> 4 files changed, 24 insertions(+), 140 deletions(-)
>>>>>
>>>>> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
>>>>> index 1fd5acdc73c6..c420418473fc 100644
>>>>> --- a/drivers/net/Kconfig
>>>>> +++ b/drivers/net/Kconfig
>>>>> @@ -395,6 +395,7 @@ config TUN
>>>>> tristate "Universal TUN/TAP device driver support"
>>>>> depends on INET
>>>>> select CRC32
>>>>> + select TAP
>>>>> help
>>>>> TUN/TAP provides packet reception and transmission for user space
>>>>> programs. It can be viewed as a simple Point-to-Point or Ethernet
>>>>> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
>>>>> index bb8eb3053772..2275309a97ee 100644
>>>>> --- a/drivers/net/Makefile
>>>>> +++ b/drivers/net/Makefile
>>>>> @@ -29,9 +29,9 @@ obj-y += mdio/
>>>>> obj-y += pcs/
>>>>> obj-$(CONFIG_RIONET) += rionet.o
>>>>> obj-$(CONFIG_NET_TEAM) += team/
>>>>> -obj-$(CONFIG_TUN) += tun-drv.o
>>>>> -tun-drv-y := tun.o tun_vnet.o
>>>>> -obj-$(CONFIG_TAP) += tap.o
>>>>> +obj-$(CONFIG_TUN) += tun.o
>>>>
>>>> Is reversing the previous changes to tun.ko intentional?
>>>>
>>>> Perhaps the previous approach with a new CONFIG_TUN_VNET is preferable
>>>> over this. In particular over making TUN select TAP, a new dependency.
>>>
>>> Jason, you also commented about CONFIG_TUN_VNET for the previous
>>> version. Do you prefer the old approach, or the new one? (Or if you have
>>> another idea, please tell me.)
>>
>> Ideally, if we can make TUN select TAP that would be better. But there
>> are some subtle differences in the multi queue implementation. We will
>> end up with some useless code for TUN unless we can unify the multi
>> queue logic. It might not be worth it to change the TUN's multi queue
>> logic so having a new file seems to be better.
>
> +1 on deduplicating further. But this series is complex enough. Let's not
> expand that.
>
> The latest approach with a separate .o file may have some performance
> cost by converting likely inlined code into real function calls.
> Another option is to move it all into tun_vnet.h. That also resolves
> the Makefile issues.
I measured the size difference between the latest inlining approaches.
The numbers may vary depending on the system configuration of course,
but they should be useful for reference.
The below shows sizes when having a separate module: 106496 bytes in total
# lsmod
Module Size Used by
tap 28672 0
tun 61440 0
tun_vnet 16384 2 tun,tap
The below shows sizes when inlining: 102400 bytes in total
# lsmod
Module Size Used by
tap 32768 0
tun 69632 0
So having a separate module costs 4096 bytes more.
These two approaches should have similar tendency for run-time and
compile-time performance; the code is so trivial that the overhead of
having one additional module is dominant.
The only downside of having all in tun_vnet.h is that it will expose its
internal macros and functions, which I think tolerable.
next prev parent reply other threads:[~2025-01-21 5:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 8:08 [PATCH net v3 0/9] tun: Unify vnet implementation Akihiko Odaki
2025-01-16 8:08 ` [PATCH net v3 1/9] tun: Refactor CONFIG_TUN_VNET_CROSS_LE Akihiko Odaki
2025-01-17 9:57 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 2/9] tun: Avoid double-tracking iov_iter length changes Akihiko Odaki
2025-01-17 10:03 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 3/9] tun: Keep hdr_len in tun_get_user() Akihiko Odaki
2025-01-17 10:17 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 4/9] tun: Decouple vnet from tun_struct Akihiko Odaki
2025-01-17 9:16 ` Willem de Bruijn
2025-01-17 10:28 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 5/9] tun: Decouple vnet handling Akihiko Odaki
2025-01-17 9:18 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 6/9] tun: Extract the vnet handling code Akihiko Odaki
2025-01-17 10:42 ` Willem de Bruijn
2025-01-16 8:08 ` [PATCH net v3 7/9] tap: Avoid double-tracking iov_iter length changes Akihiko Odaki
2025-01-16 8:08 ` [PATCH net v3 8/9] tap: Keep hdr_len in tap_get_user() Akihiko Odaki
2025-01-16 8:08 ` [PATCH net v3 9/9] tap: Use tun's vnet-related code Akihiko Odaki
2025-01-17 9:23 ` Willem de Bruijn
2025-01-17 10:35 ` Akihiko Odaki
2025-01-20 0:36 ` Jason Wang
2025-01-20 11:19 ` Willem de Bruijn
2025-01-21 5:27 ` Akihiko Odaki [this message]
2025-01-21 14:44 ` Willem de Bruijn
2025-01-16 8:14 ` [PATCH net v3 0/9] tun: Unify vnet implementation Michael S. Tsirkin
2025-01-16 12:54 ` Willem de Bruijn
2025-01-17 6:50 ` Akihiko Odaki
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=92675e51-cbaf-4905-8cf8-dff741a26db9@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=andrew@daynix.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devel@daynix.com \
--cc=edumazet@google.com \
--cc=gur.stavi@huawei.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stephen@networkplumber.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yuri.benditovich@daynix.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
all inboxes | Powered by JetHome®