diff mbox

[RFC] net: dsa: remove unnecessary phy.h include

Message ID 20170118001403.GJ27312@n2100.armlinux.org.uk
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Russell King (Oracle) Jan. 18, 2017, 12:14 a.m. UTC
Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
unnecessary dependency for quite a large amount of the kernel.  There's
very little which actually requires definitions from phy.h in net/dsa.h
- the include itself only wants the declaration of a couple of
structures and IFNAMSIZ.

Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
and phy_fixed.h from net/dsa.h.

This patch reduces from around 800 files rebuilt to around 40 - even
with ccache, the time difference is noticable.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
I noticed when I touched linux/phy.h that a lot of the kernel ended up
being unexpectedly rebuilt, as linux/netdevice.h includes net/dsa.h,
which then then includes linux/phy.h.  I've tested this change on both
ARM and ARM64, but I'd suggest letting the 0-day builder have a bite
at this, and then only taking it if everyone is confident that there's
a slim chance of any problems.  Also, it may need some rework to apply
to davem's tree.  All of the above makes this RFC only.

 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h | 1 +
 include/net/dsa.h                     | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

Comments

Vivien Didelot Jan. 18, 2017, 1:11 a.m. UTC | #1
Hi Russell,

Russell King - ARM Linux <linux@armlinux.org.uk> writes:

> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel.  There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
>
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
>
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

This patch applies cleanly on net-next and builds correctly after
touching include/linux/phy.h. My boards work fine with it.

Tested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Thanks,

        Vivien
Florian Fainelli Jan. 18, 2017, 1:13 a.m. UTC | #2
On 01/17/2017 04:14 PM, Russell King - ARM Linux wrote:
> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel.  There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
> 
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
> 
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> ---
> I noticed when I touched linux/phy.h that a lot of the kernel ended up
> being unexpectedly rebuilt, as linux/netdevice.h includes net/dsa.h,
> which then then includes linux/phy.h.  I've tested this change on both
> ARM and ARM64, but I'd suggest letting the 0-day builder have a bite
> at this, and then only taking it if everyone is confident that there's
> a slim chance of any problems.  Also, it may need some rework to apply
> to davem's tree.  All of the above makes this RFC only.
> 
>  drivers/net/dsa/mv88e6xxx/mv88e6xxx.h | 1 +
>  include/net/dsa.h                     | 6 ++++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> index a319c06d82e3..d247b0639ed4 100644
> --- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> @@ -15,6 +15,7 @@
>  #include <linux/if_vlan.h>
>  #include <linux/irq.h>
>  #include <linux/gpio/consumer.h>
> +#include <linux/phy.h>
>  
>  #ifndef UINT64_MAX
>  #define UINT64_MAX		(u64)(~((u64)0))
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index b122196d5a1f..887b2f98f9ea 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -11,15 +11,17 @@
>  #ifndef __LINUX_NET_DSA_H
>  #define __LINUX_NET_DSA_H
>  
> +#include <linux/if.h>
>  #include <linux/if_ether.h>
>  #include <linux/list.h>
>  #include <linux/timer.h>
>  #include <linux/workqueue.h>
>  #include <linux/of.h>
> -#include <linux/phy.h>
> -#include <linux/phy_fixed.h>
>  #include <linux/ethtool.h>
>  
> +struct phy_device;
> +struct fixed_phy_status;
> +
>  enum dsa_tag_protocol {
>  	DSA_TAG_PROTO_NONE = 0,
>  	DSA_TAG_PROTO_DSA,
>
David Miller Jan. 18, 2017, 9:37 p.m. UTC | #3
From: Russell King - ARM Linux <linux@armlinux.org.uk>
Date: Wed, 18 Jan 2017 00:14:03 +0000

> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel.  There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
> 
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
> 
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied, thanks.
Russell King (Oracle) Jan. 18, 2017, 9:46 p.m. UTC | #4
On Wed, Jan 18, 2017 at 04:37:14PM -0500, David Miller wrote:
> From: Russell King - ARM Linux <linux@armlinux.org.uk>
> Date: Wed, 18 Jan 2017 00:14:03 +0000
> 
> > Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> > unnecessary dependency for quite a large amount of the kernel.  There's
> > very little which actually requires definitions from phy.h in net/dsa.h
> > - the include itself only wants the declaration of a couple of
> > structures and IFNAMSIZ.
> > 
> > Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> > mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> > and phy_fixed.h from net/dsa.h.
> > 
> > This patch reduces from around 800 files rebuilt to around 40 - even
> > with ccache, the time difference is noticable.
> > 
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> 
> Applied, thanks.

Hmm, now that's _really_ interesting.

I think you've said to others to send patches with RFC in them when they
aren't to be applied.  I sent this with RFC in, and it still got applied.

This is _really_ unfortunate, as the 0-day builder has been sending me a
stream of build errors over it, and I now have a branch with 9 patches
plus this one in fixing those errors...

And I did say in the comments below the --- that it should be left a few
days for the 0-day builder to run through it and find those errors.

Ho hum.
David Miller Jan. 18, 2017, 9:47 p.m. UTC | #5
From: David Miller <davem@davemloft.net>

Date: Wed, 18 Jan 2017 16:37:14 -0500 (EST)

> From: Russell King - ARM Linux <linux@armlinux.org.uk>

> Date: Wed, 18 Jan 2017 00:14:03 +0000

> 

>> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an

>> unnecessary dependency for quite a large amount of the kernel.  There's

>> very little which actually requires definitions from phy.h in net/dsa.h

>> - the include itself only wants the declaration of a couple of

>> structures and IFNAMSIZ.

>> 

>> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to

>> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h

>> and phy_fixed.h from net/dsa.h.

>> 

>> This patch reduces from around 800 files rebuilt to around 40 - even

>> with ccache, the time difference is noticable.

>> 

>> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

> 

> Applied, thanks.


Acutallly, I'm reverting this, it breaks the build all over the place.

The problem is that it seems that somehow we are getting an implicit
module.h include via phy.h and this propagates all over the tree.  So
I get failures like:

net/core/netprio_cgroup.c:303:16: error: expected declaration specifiers or ‘...’ before string constant
 MODULE_LICENSE("GPL v2");
 ...
net/sunrpc/xprtrdma/svc_rdma_backchannel.c: In function ‘xprt_rdma_bc_put’:
net/sunrpc/xprtrdma/svc_rdma_backchannel.c:277:2: error: implicit declaration of function ‘module_put’ [-Werror=implicit-function-declaration]
  module_put(THIS_MODULE);
  ^
net/sunrpc/xprtrdma/svc_rdma_backchannel.c: In function ‘xprt_setup_rdma_bc’:
net/sunrpc/xprtrdma/svc_rdma_backchannel.c:348:7: error: implicit declaration of function ‘try_module_get’ [-Werror=implicit-function-declaration]
  if (!try_module_get(THIS_MODULE))

Please resubmit this after you can successfully complete an allmodconfig build.

Thanks.
David Miller Jan. 18, 2017, 9:48 p.m. UTC | #6
From: Russell King - ARM Linux <linux@armlinux.org.uk>
Date: Wed, 18 Jan 2017 21:46:28 +0000

> On Wed, Jan 18, 2017 at 04:37:14PM -0500, David Miller wrote:
>> From: Russell King - ARM Linux <linux@armlinux.org.uk>
>> Date: Wed, 18 Jan 2017 00:14:03 +0000
>> 
>> > Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
>> > unnecessary dependency for quite a large amount of the kernel.  There's
>> > very little which actually requires definitions from phy.h in net/dsa.h
>> > - the include itself only wants the declaration of a couple of
>> > structures and IFNAMSIZ.
>> > 
>> > Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
>> > mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
>> > and phy_fixed.h from net/dsa.h.
>> > 
>> > This patch reduces from around 800 files rebuilt to around 40 - even
>> > with ccache, the time difference is noticable.
>> > 
>> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> 
>> Applied, thanks.
> 
> Hmm, now that's _really_ interesting.

It got reviewed-by and seemed reasonable.

I am always allowed to use my judgment to turn an RFC into a patch
I actually apply, especially when other developers review the change.

If you read your email now you'll see that I reverted it before
pushing it out, because of the fallout you mention.
Russell King (Oracle) Jan. 31, 2017, 7:17 p.m. UTC | #7
Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
unnecessary dependency for quite a large amount of the kernel.  There's
very little which actually requires definitions from phy.h in net/dsa.h
- the include itself only wants the declaration of a couple of
structures and IFNAMSIZ.

Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
and phy_fixed.h from net/dsa.h.

This patch reduces from around 800 files rebuilt to around 40 - even
with ccache, the time difference is noticable.

In order to make this change, several drivers need to be updated to
include necessary headers that they were picking up through this
include.  This has resulted in a much larger patch series.

I'm assuming the 0-day builder has had 24 hours with this series, and
hasn't reported any further issues with it - the last issue was two
weeks ago (before I became ill) which I fixed over the last weekend.

I'm hoping this doesn't conflict with what's already in net-next...

 arch/mips/cavium-octeon/octeon-platform.c             | 4 ----
 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h                 | 1 +
 drivers/net/ethernet/broadcom/bgmac.c                 | 2 ++
 drivers/net/ethernet/cadence/macb.h                   | 2 ++
 drivers/net/ethernet/cavium/liquidio/lio_main.c       | 1 +
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c    | 1 +
 drivers/net/ethernet/cavium/liquidio/octeon_console.c | 1 +
 drivers/net/ethernet/freescale/fman/fman_memac.c      | 1 +
 drivers/net/ethernet/marvell/mvneta.c                 | 1 +
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c       | 1 +
 drivers/net/usb/lan78xx.c                             | 1 +
 drivers/net/wireless/ath/ath5k/ahb.c                  | 2 +-
 drivers/target/iscsi/iscsi_target_login.c             | 1 +
 include/net/dsa.h                                     | 6 ++++--
 net/core/netprio_cgroup.c                             | 1 +
 net/sunrpc/xprtrdma/svc_rdma_backchannel.c            | 1 +
 16 files changed, 20 insertions(+), 7 deletions(-)
Florian Fainelli Feb. 1, 2017, 2:42 a.m. UTC | #8
On 01/31/2017 11:17 AM, Russell King - ARM Linux wrote:
> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel.  There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
> 
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
> 
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
> 
> In order to make this change, several drivers need to be updated to
> include necessary headers that they were picking up through this
> include.  This has resulted in a much larger patch series.
> 
> I'm assuming the 0-day builder has had 24 hours with this series, and
> hasn't reported any further issues with it - the last issue was two
> weeks ago (before I became ill) which I fixed over the last weekend.
> 
> I'm hoping this doesn't conflict with what's already in net-next...

For the entire series:

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Thanks a lot for doing that.

> 
>  arch/mips/cavium-octeon/octeon-platform.c             | 4 ----
>  drivers/net/dsa/mv88e6xxx/mv88e6xxx.h                 | 1 +
>  drivers/net/ethernet/broadcom/bgmac.c                 | 2 ++
>  drivers/net/ethernet/cadence/macb.h                   | 2 ++
>  drivers/net/ethernet/cavium/liquidio/lio_main.c       | 1 +
>  drivers/net/ethernet/cavium/liquidio/lio_vf_main.c    | 1 +
>  drivers/net/ethernet/cavium/liquidio/octeon_console.c | 1 +
>  drivers/net/ethernet/freescale/fman/fman_memac.c      | 1 +
>  drivers/net/ethernet/marvell/mvneta.c                 | 1 +
>  drivers/net/ethernet/qualcomm/emac/emac-sgmii.c       | 1 +
>  drivers/net/usb/lan78xx.c                             | 1 +
>  drivers/net/wireless/ath/ath5k/ahb.c                  | 2 +-
>  drivers/target/iscsi/iscsi_target_login.c             | 1 +
>  include/net/dsa.h                                     | 6 ++++--
>  net/core/netprio_cgroup.c                             | 1 +
>  net/sunrpc/xprtrdma/svc_rdma_backchannel.c            | 1 +
>  16 files changed, 20 insertions(+), 7 deletions(-)
>
diff mbox

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
index a319c06d82e3..d247b0639ed4 100644
--- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
@@ -15,6 +15,7 @@ 
 #include <linux/if_vlan.h>
 #include <linux/irq.h>
 #include <linux/gpio/consumer.h>
+#include <linux/phy.h>
 
 #ifndef UINT64_MAX
 #define UINT64_MAX		(u64)(~((u64)0))
diff --git a/include/net/dsa.h b/include/net/dsa.h
index b122196d5a1f..887b2f98f9ea 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -11,15 +11,17 @@ 
 #ifndef __LINUX_NET_DSA_H
 #define __LINUX_NET_DSA_H
 
+#include <linux/if.h>
 #include <linux/if_ether.h>
 #include <linux/list.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/of.h>
-#include <linux/phy.h>
-#include <linux/phy_fixed.h>
 #include <linux/ethtool.h>
 
+struct phy_device;
+struct fixed_phy_status;
+
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE = 0,
 	DSA_TAG_PROTO_DSA,