diff mbox series

[RFC,net-next,01/15] devlink: move code to a dedicated directory

Message ID 20221215020155.1619839-2-kuba@kernel.org (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series devlink: code split and structured instance walk | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers warning 5 maintainers not CCed: imagedong@tencent.com wedsonaf@google.com keescook@chromium.org alex.gaynor@gmail.com ojeda@kernel.org
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski Dec. 15, 2022, 2:01 a.m. UTC
The devlink code is hard to navigate with 13kLoC in one file.
I really like the way Michal split the ethtool into per-command
files and core. It'd probably be too much to split it all up,
but we can at least separate the core parts out of the per-cmd
implementations and put it in a directory so that new commands
can be separate files.

Move the code, subsequent commit will do a partial split.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/Makefile                            | 1 +
 net/core/Makefile                       | 1 -
 net/devlink/Makefile                    | 3 +++
 net/{core/devlink.c => devlink/basic.c} | 0
 4 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 net/devlink/Makefile
 rename net/{core/devlink.c => devlink/basic.c} (100%)

Comments

Jiri Pirko Dec. 15, 2022, 9:51 a.m. UTC | #1
Thu, Dec 15, 2022 at 03:01:41AM CET, kuba@kernel.org wrote:
>The devlink code is hard to navigate with 13kLoC in one file.
>I really like the way Michal split the ethtool into per-command
>files and core. It'd probably be too much to split it all up,

Why not? While you are at it, I think that we should split it right
away.


>but we can at least separate the core parts out of the per-cmd
>implementations and put it in a directory so that new commands
>can be separate files.
>
>Move the code, subsequent commit will do a partial split.
>
>Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>---
> net/Makefile                            | 1 +
> net/core/Makefile                       | 1 -
> net/devlink/Makefile                    | 3 +++
> net/{core/devlink.c => devlink/basic.c} | 0

What's "basic" about it? It sounds a bit misleading.


> 4 files changed, 4 insertions(+), 1 deletion(-)
> create mode 100644 net/devlink/Makefile
> rename net/{core/devlink.c => devlink/basic.c} (100%)
>
>diff --git a/net/Makefile b/net/Makefile
>index 6a62e5b27378..0914bea9c335 100644
>--- a/net/Makefile
>+++ b/net/Makefile
>@@ -23,6 +23,7 @@ obj-$(CONFIG_BPFILTER)		+= bpfilter/
> obj-$(CONFIG_PACKET)		+= packet/
> obj-$(CONFIG_NET_KEY)		+= key/
> obj-$(CONFIG_BRIDGE)		+= bridge/
>+obj-$(CONFIG_NET_DEVLINK)	+= devlink/

Hmm, as devlink is not really designed to be only networking thing,
perhaps this is good opportunity to move out of net/ and change the
config name to "CONFIG_DEVLINK" ?


> obj-$(CONFIG_NET_DSA)		+= dsa/
> obj-$(CONFIG_ATALK)		+= appletalk/
> obj-$(CONFIG_X25)		+= x25/
>diff --git a/net/core/Makefile b/net/core/Makefile
>index 5857cec87b83..10edd66a8a37 100644
>--- a/net/core/Makefile
>+++ b/net/core/Makefile
>@@ -33,7 +33,6 @@ obj-$(CONFIG_LWTUNNEL) += lwtunnel.o
> obj-$(CONFIG_LWTUNNEL_BPF) += lwt_bpf.o
> obj-$(CONFIG_DST_CACHE) += dst_cache.o
> obj-$(CONFIG_HWBM) += hwbm.o
>-obj-$(CONFIG_NET_DEVLINK) += devlink.o
> obj-$(CONFIG_GRO_CELLS) += gro_cells.o
> obj-$(CONFIG_FAILOVER) += failover.o
> obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o
>diff --git a/net/devlink/Makefile b/net/devlink/Makefile
>new file mode 100644
>index 000000000000..ba54922128ab
>--- /dev/null
>+++ b/net/devlink/Makefile
>@@ -0,0 +1,3 @@
>+# SPDX-License-Identifier: GPL-2.0
>+
>+obj-y := basic.o
>diff --git a/net/core/devlink.c b/net/devlink/basic.c
>similarity index 100%
>rename from net/core/devlink.c
>rename to net/devlink/basic.c




>-- 
>2.38.1
>
Jacob Keller Dec. 15, 2022, 6:44 p.m. UTC | #2
On 12/15/2022 1:51 AM, Jiri Pirko wrote:
> Thu, Dec 15, 2022 at 03:01:41AM CET, kuba@kernel.org wrote:
>> The devlink code is hard to navigate with 13kLoC in one file.
>> I really like the way Michal split the ethtool into per-command
>> files and core. It'd probably be too much to split it all up,
> 
> Why not? While you are at it, I think that we should split it right
> away.
>

 From the cover letter it sounds like "not enough time". I like 
splitting things up but would be fine with just one file per sub object 
type like one for ports, one for regions, etc.

Thanks,
Jake
Jakub Kicinski Dec. 15, 2022, 7:09 p.m. UTC | #3
On Thu, 15 Dec 2022 10:51:43 +0100 Jiri Pirko wrote:
> > net/Makefile                            | 1 +
> > net/core/Makefile                       | 1 -
> > net/devlink/Makefile                    | 3 +++
> > net/{core/devlink.c => devlink/basic.c} | 0  
> 
> What's "basic" about it? It sounds a bit misleading.

Agreed, but try to suggest a better name ;)  the_rest_of_it.c ? :)

> > 4 files changed, 4 insertions(+), 1 deletion(-)
> > create mode 100644 net/devlink/Makefile
> > rename net/{core/devlink.c => devlink/basic.c} (100%)
> >
> >diff --git a/net/Makefile b/net/Makefile
> >index 6a62e5b27378..0914bea9c335 100644
> >--- a/net/Makefile
> >+++ b/net/Makefile
> >@@ -23,6 +23,7 @@ obj-$(CONFIG_BPFILTER)		+= bpfilter/
> > obj-$(CONFIG_PACKET)		+= packet/
> > obj-$(CONFIG_NET_KEY)		+= key/
> > obj-$(CONFIG_BRIDGE)		+= bridge/
> >+obj-$(CONFIG_NET_DEVLINK)	+= devlink/  
> 
> Hmm, as devlink is not really designed to be only networking thing,
> perhaps this is good opportunity to move out of net/ and change the
> config name to "CONFIG_DEVLINK" ?

Nothing against it, but don't think it belongs in this patch.
So I call scope creep.
Jakub Kicinski Dec. 15, 2022, 7:13 p.m. UTC | #4
On Thu, 15 Dec 2022 10:44:14 -0800 Jacob Keller wrote:
> On 12/15/2022 1:51 AM, Jiri Pirko wrote:
> > Thu, Dec 15, 2022 at 03:01:41AM CET, kuba@kernel.org wrote:  
> >> The devlink code is hard to navigate with 13kLoC in one file.
> >> I really like the way Michal split the ethtool into per-command
> >> files and core. It'd probably be too much to split it all up,  
> > 
> > Why not? While you are at it, I think that we should split it right
> > away.
>
>  From the cover letter it sounds like "not enough time". I like 
> splitting things up but would be fine with just one file per sub object 
> type like one for ports, one for regions, etc.

Indeed, I had to draw the line somewhere. Always plenty of
opportunities to reshuffle and improve code which has grown
organically over the years. But the sun goes down obsitnately...
Jacob Keller Dec. 15, 2022, 7:29 p.m. UTC | #5
On 12/15/2022 11:09 AM, Jakub Kicinski wrote:
> On Thu, 15 Dec 2022 10:51:43 +0100 Jiri Pirko wrote:
>>> net/Makefile                            | 1 +
>>> net/core/Makefile                       | 1 -
>>> net/devlink/Makefile                    | 3 +++
>>> net/{core/devlink.c => devlink/basic.c} | 0  
>>
>> What's "basic" about it? It sounds a bit misleading.
> 
> Agreed, but try to suggest a better name ;)  the_rest_of_it.c ? :)
> 

I tried to think of something, but you already use core elsewhere in the
series. If our long term goal really is to split everything out then
maybe "leftover.c"? Or just "devlink/devlink.c"

>>> 4 files changed, 4 insertions(+), 1 deletion(-)
>>> create mode 100644 net/devlink/Makefile
>>> rename net/{core/devlink.c => devlink/basic.c} (100%)
>>>
>>> diff --git a/net/Makefile b/net/Makefile
>>> index 6a62e5b27378..0914bea9c335 100644
>>> --- a/net/Makefile
>>> +++ b/net/Makefile
>>> @@ -23,6 +23,7 @@ obj-$(CONFIG_BPFILTER)		+= bpfilter/
>>> obj-$(CONFIG_PACKET)		+= packet/
>>> obj-$(CONFIG_NET_KEY)		+= key/
>>> obj-$(CONFIG_BRIDGE)		+= bridge/
>>> +obj-$(CONFIG_NET_DEVLINK)	+= devlink/  
>>
>> Hmm, as devlink is not really designed to be only networking thing,
>> perhaps this is good opportunity to move out of net/ and change the
>> config name to "CONFIG_DEVLINK" ?
> 
> Nothing against it, but don't think it belongs in this patch.
> So I call scope creep.

Right. I think this patch set focusing on just the iteration for dumping
is good.
Jakub Kicinski Dec. 15, 2022, 7:48 p.m. UTC | #6
On Thu, 15 Dec 2022 11:29:02 -0800 Jacob Keller wrote:
> >> What's "basic" about it? It sounds a bit misleading.  
> > 
> > Agreed, but try to suggest a better name ;)  the_rest_of_it.c ? :)
> 
> I tried to think of something, but you already use core elsewhere in the
> series. If our long term goal really is to split everything out then
> maybe "leftover.c"? Or just "devlink/devlink.c"

leftover.c is fine by me. Jiri?
Jiri Pirko Dec. 16, 2022, 9:09 a.m. UTC | #7
Thu, Dec 15, 2022 at 08:48:29PM CET, kuba@kernel.org wrote:
>On Thu, 15 Dec 2022 11:29:02 -0800 Jacob Keller wrote:
>> >> What's "basic" about it? It sounds a bit misleading.  
>> > 
>> > Agreed, but try to suggest a better name ;)  the_rest_of_it.c ? :)
>> 
>> I tried to think of something, but you already use core elsewhere in the
>> series. If our long term goal really is to split everything out then
>> maybe "leftover.c"? Or just "devlink/devlink.c"
>
>leftover.c is fine by me. Jiri?

If the goal is to remove the file entirely eventually, I'm okay with
that.
Jiri Pirko Dec. 16, 2022, 9:10 a.m. UTC | #8
Thu, Dec 15, 2022 at 08:09:25PM CET, kuba@kernel.org wrote:
>On Thu, 15 Dec 2022 10:51:43 +0100 Jiri Pirko wrote:
>> > net/Makefile                            | 1 +
>> > net/core/Makefile                       | 1 -
>> > net/devlink/Makefile                    | 3 +++
>> > net/{core/devlink.c => devlink/basic.c} | 0  
>> 
>> What's "basic" about it? It sounds a bit misleading.
>
>Agreed, but try to suggest a better name ;)  the_rest_of_it.c ? :)
>
>> > 4 files changed, 4 insertions(+), 1 deletion(-)
>> > create mode 100644 net/devlink/Makefile
>> > rename net/{core/devlink.c => devlink/basic.c} (100%)
>> >
>> >diff --git a/net/Makefile b/net/Makefile
>> >index 6a62e5b27378..0914bea9c335 100644
>> >--- a/net/Makefile
>> >+++ b/net/Makefile
>> >@@ -23,6 +23,7 @@ obj-$(CONFIG_BPFILTER)		+= bpfilter/
>> > obj-$(CONFIG_PACKET)		+= packet/
>> > obj-$(CONFIG_NET_KEY)		+= key/
>> > obj-$(CONFIG_BRIDGE)		+= bridge/
>> >+obj-$(CONFIG_NET_DEVLINK)	+= devlink/  
>> 
>> Hmm, as devlink is not really designed to be only networking thing,
>> perhaps this is good opportunity to move out of net/ and change the
>> config name to "CONFIG_DEVLINK" ?
>
>Nothing against it, but don't think it belongs in this patch.
>So I call scope creep.

Yeah, but I mean, since you move it from /net/core to /net/, why not
just move it to / ?
Jakub Kicinski Dec. 16, 2022, 6:32 p.m. UTC | #9
On Fri, 16 Dec 2022 10:10:41 +0100 Jiri Pirko wrote:
> >> Hmm, as devlink is not really designed to be only networking thing,
> >> perhaps this is good opportunity to move out of net/ and change the
> >> config name to "CONFIG_DEVLINK" ?  
> >
> >Nothing against it, but don't think it belongs in this patch.
> >So I call scope creep.  
> 
> Yeah, but I mean, since you move it from /net/core to /net/, why not
> just move it to / ?

It still needs to depend on NET for sockets, right?
Jacob Keller Dec. 16, 2022, 11:26 p.m. UTC | #10
On 12/16/2022 10:32 AM, Jakub Kicinski wrote:
> On Fri, 16 Dec 2022 10:10:41 +0100 Jiri Pirko wrote:
>>>> Hmm, as devlink is not really designed to be only networking thing,
>>>> perhaps this is good opportunity to move out of net/ and change the
>>>> config name to "CONFIG_DEVLINK" ?  
>>>
>>> Nothing against it, but don't think it belongs in this patch.
>>> So I call scope creep.  
>>
>> Yeah, but I mean, since you move it from /net/core to /net/, why not
>> just move it to / ?
> 
> It still needs to depend on NET for sockets, right?

Its going to depend on whatever Generic Netlink depends on yea.
diff mbox series

Patch

diff --git a/net/Makefile b/net/Makefile
index 6a62e5b27378..0914bea9c335 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -23,6 +23,7 @@  obj-$(CONFIG_BPFILTER)		+= bpfilter/
 obj-$(CONFIG_PACKET)		+= packet/
 obj-$(CONFIG_NET_KEY)		+= key/
 obj-$(CONFIG_BRIDGE)		+= bridge/
+obj-$(CONFIG_NET_DEVLINK)	+= devlink/
 obj-$(CONFIG_NET_DSA)		+= dsa/
 obj-$(CONFIG_ATALK)		+= appletalk/
 obj-$(CONFIG_X25)		+= x25/
diff --git a/net/core/Makefile b/net/core/Makefile
index 5857cec87b83..10edd66a8a37 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -33,7 +33,6 @@  obj-$(CONFIG_LWTUNNEL) += lwtunnel.o
 obj-$(CONFIG_LWTUNNEL_BPF) += lwt_bpf.o
 obj-$(CONFIG_DST_CACHE) += dst_cache.o
 obj-$(CONFIG_HWBM) += hwbm.o
-obj-$(CONFIG_NET_DEVLINK) += devlink.o
 obj-$(CONFIG_GRO_CELLS) += gro_cells.o
 obj-$(CONFIG_FAILOVER) += failover.o
 obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o
diff --git a/net/devlink/Makefile b/net/devlink/Makefile
new file mode 100644
index 000000000000..ba54922128ab
--- /dev/null
+++ b/net/devlink/Makefile
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y := basic.o
diff --git a/net/core/devlink.c b/net/devlink/basic.c
similarity index 100%
rename from net/core/devlink.c
rename to net/devlink/basic.c