mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Jakub Kicinski <kuba@kernel.org>, Breno Leitao <leitao@debian.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, <quic_jjohnson@quicinc.com>,
	<kvalo@kernel.org>, <leon@kernel.org>,
	<dennis.dalessandro@cornelisnetworks.com>,
	Jiri Pirko <jiri@resnulli.us>, Simon Horman <horms@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Coco Li <lixiaoyan@google.com>,
	"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net: create a dummy net_device allocator
Date: Thu, 28 Mar 2024 15:57:29 +0100	[thread overview]
Message-ID: <25a2266c-8ae4-41f5-9b80-beaf174043d1@intel.com> (raw)
In-Reply-To: <20240327161731.6b100cb8@kernel.org>

From: Jakub Kicinski <kuba@kernel.org>
Date: Wed, 27 Mar 2024 16:17:31 -0700

> On Wed, 27 Mar 2024 13:08:04 -0700 Breno Leitao wrote:
>> It is impossible to use init_dummy_netdev together with alloc_netdev()
>> as the 'setup' argument.
>>
>> This is because alloc_netdev() initializes some fields in the net_device
>> structure, and later init_dummy_netdev() memzero them all. This causes
>> some problems as reported here:
>>
>> 	https://lore.kernel.org/all/20240322082336.49f110cc@kernel.org/
>>
>> Split the init_dummy_netdev() function in two. Create a new function called
>> init_dummy_netdev_core() that does not memzero the net_device structure.
>> Then have init_dummy_netdev() memzero-ing and calling
>> init_dummy_netdev_core(), keeping the old behaviour.
>>
>> init_dummy_netdev_core() is the new function that could be called as an
>> argument for alloc_netdev().
>>
>> Also, create a helper to allocate and initialize dummy net devices,
>> leveraging init_dummy_netdev_core() as the setup argument. This function
>> basically simplify the allocation of dummy devices, by allocating and
>> initializing it. Freeing the device continue to be done through
>> free_netdev()
> 
> Ah, but you need to make it part of the series with some caller.
> Maybe convert all the ethernet ones?
> 
> $ git grep 'struct net_device [^*]*;' -- drivers/net/ethernet/
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c:      struct net_device       netdev;
> drivers/net/ethernet/marvell/prestera/prestera_rxtx.c:  struct net_device napi_dev;
> drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c:static struct net_device test_netdev = {};
> drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:static struct net_device test_netdev = {};

There are much more of them unfortunately. Pretty much every user of
init_dummy_netdev()[0].

I would prefer *replacing* init_dummy_netdev() with
alloc_dummy_netdev(), so that we'll be sure there are no embedded
&net_devices and we can use a proper flex array there.

[0] https://elixir.bootlin.com/linux/v6.9-rc1/A/ident/init_dummy_netdev

Thanks,
Olek

  reply	other threads:[~2024-03-28 14:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 20:08 Breno Leitao
2024-03-27 23:17 ` Jakub Kicinski
2024-03-28 14:57   ` Alexander Lobakin [this message]
2024-03-28 15:02 ` Alexander Lobakin
2024-03-28 17:10   ` Jakub Kicinski
2024-03-28 17:46     ` Breno Leitao
2024-03-28 17:40   ` Breno Leitao
2024-04-02 18:01 ` Leon Romanovsky
2024-04-02 18:17   ` 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=25a2266c-8ae4-41f5-9b80-beaf174043d1@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=leitao@debian.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixiaoyan@google.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_jjohnson@quicinc.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®