Re: [PATCH] ethernet: octeontx2: avoid linking objects into multiple modules

From: Jacob Keller
Date: Thu May 30 2024 - 13:54:50 EST




On 5/28/2024 8:25 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> Each object file contains information about which module it gets linked
> into, so linking the same file into multiple modules now causes a warning:
>
> scripts/Makefile.build:254: drivers/net/ethernet/marvell/octeontx2/nic/Makefile: otx2_devlink.o is added to multiple modules: rvu_nicpf rvu_nicvf
>

When I tried to build, I don't see any warnings produced on the current
net-next with W=1. Is this something new and not yet in net-next tree?
If not, how do I enable this warning in my local build?

> Change the way that octeontx2 ethernet is built by moving the common
> file into a separate module with exported symbols instead.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---

The change makes sense to me. I built and tested both before and after
this change.

On my system, before the build change, the driver built to 3 separate
modules totaling 2029176 bytes:

> -rw-r--r--. 1 jekeller jekeller 72104 May 30 10:46 otx2_ptp.ko
> -rw-r--r--. 1 jekeller jekeller 1774008 May 30 10:46 rvu_nicpf.ko
> -rw-r--r--. 1 jekeller jekeller 183064 May 30 10:46 rvu_nicvf.ko
After this change, the driver builds to 5 separate modules totaling
1977984 bytes:

> -rw-r--r--. 1 jekeller jekeller 81480 May 30 10:46 otx2_dcbnl.ko
> -rw-r--r--. 1 jekeller jekeller 19784 May 30 10:46 otx2_devlink.ko
> -rw-r--r--. 1 jekeller jekeller 72104 May 30 10:46 otx2_ptp.ko
> -rw-r--r--. 1 jekeller jekeller 1698880 May 30 10:46 rvu_nicpf.ko
> -rw-r--r--. 1 jekeller jekeller 105736 May 30 10:46 rvu_nicvf.ko

This is a savings of 51192 bytes from removing the duplicated object code.

Reviewed-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>