Skip to contentSkip to conversation

lib: Allow for the DIM library to be modular

PATCH Applied Florian Fainelli 3 participants 5 messages May 6, 2024 – May 8, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib: Allow for the DIM library to be modular

Allow the Dynamic Interrupt Moderation (DIM) library to be built as a module. This is particularly useful in an Android GKI (Google Kernel Image) configuration where everything is built as a module, including Ethernet controller drivers. Having to build DIMLIB into the kernel image with potentially no user is wasteful.

---
Changes in v2:

- Added MODULE_DESCRIPTION()

 lib/Kconfig      | 2 +-
 lib/dim/Makefile | 4 ++--
 lib/dim/dim.c    | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)
lib/Kconfig +1 -1
index 4557bb8a5256..d33a268bc256 100644
@@ -628,7 +628,7 @@ config SIGNATURE
 	  Implementation is done using GnuPG MPI library
 
 config DIMLIB
-	bool
+	tristate
 	help
 	  Dynamic Interrupt Moderation library.
 	  Implements an algorithm for dynamically changing CQ moderation values
lib/dim/Makefile +2 -2
index 1d6858a108cb..c4cc4026c451 100644
@@ -2,6 +2,6 @@
 # DIM Dynamic Interrupt Moderation library
 #
 
-obj-$(CONFIG_DIMLIB) += dim.o
+obj-$(CONFIG_DIMLIB) += dimlib.o
 
-dim-y := dim.o net_dim.o rdma_dim.o
+dimlib-objs := dim.o net_dim.o rdma_dim.o
lib/dim/dim.c +3 -0
index e89aaf07bde5..83b65ac74d73 100644
@@ -82,3 +82,6 @@ bool dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
 	return true;
 }
 EXPORT_SYMBOL(dim_calc_stats);
+
+MODULE_DESCRIPTION("Dynamic Interrupt Moderation (DIM) library");
+MODULE_LICENSE("Dual BSD/GPL");
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw

From: Florian Fainelli <[email protected]>
Date: Mon, 6 May 2024 10:50:40 -0700

Quoted 5 lines

Allow the Dynamic Interrupt Moderation (DIM) library to be built as a module. This is particularly useful in an Android GKI (Google Kernel Image) configuration where everything is built as a module, including Ethernet controller drivers. Having to build DIMLIB into the kernel image with potentially no user is wasteful.

Some bloat-o-meter -c vmlinux.{before,after} would be good to have here. The library is small, but I personally would like to see it modular.

Quoted 2 lines
Quoted 28 lines

---
Changes in v2:

- Added MODULE_DESCRIPTION()

 lib/Kconfig      | 2 +-
 lib/dim/Makefile | 4 ++--
 lib/dim/dim.c    | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)
lib/Kconfig +1 -1
index 4557bb8a5256..d33a268bc256 100644
@@ -628,7 +628,7 @@ config SIGNATURE
 	  Implementation is done using GnuPG MPI library
 
 config DIMLIB
-	bool
+	tristate
 	help
 	  Dynamic Interrupt Moderation library.
 	  Implements an algorithm for dynamically changing CQ moderation values
lib/dim/Makefile +0 -0
index 1d6858a108cb..c4cc4026c451 100644

lib/dim/Makefile line 5

Quoted 5 lines
lib/dim/Makefile +1 -1
@@ -2,6 +2,6 @@
 # DIM Dynamic Interrupt Moderation library
 #
 
-obj-$(CONFIG_DIMLIB) += dim.o
+obj-$(CONFIG_DIMLIB) += dimlib.o

I guess you renamed it due to that there's already a module named 'dim'?

Quoted 8 lines
lib/dim/Makefile +1 -1
-dim-y := dim.o net_dim.o rdma_dim.o
+dimlib-objs := dim.o net_dim.o rdma_dim.o
lib/dim/dim.c +0 -0
index e89aaf07bde5..83b65ac74d73 100644

lib/dim/dim.c bool dim_calc_stats(struct dim_sample *start, struct dim_sample *end, · line 87

Quoted 6 lines
lib/dim/dim.c +3 -0
@@ -82,3 +82,6 @@ bool dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
 	return true;
 }
 EXPORT_SYMBOL(dim_calc_stats);
+
+MODULE_DESCRIPTION("Dynamic Interrupt Moderation (DIM) library");
+MODULE_LICENSE("Dual BSD/GPL");

Thanks,
Olek

#2 lore raw
Quoted 11 lines · Alexander Lobakin

From: Florian Fainelli <[email protected]>
Date: Mon, 6 May 2024 10:50:40 -0700

Quoted 5 lines

Allow the Dynamic Interrupt Moderation (DIM) library to be built as a module. This is particularly useful in an Android GKI (Google Kernel Image) configuration where everything is built as a module, including Ethernet controller drivers. Having to build DIMLIB into the kernel image with potentially no user is wasteful.

Some bloat-o-meter -c vmlinux.{before,after} would be good to have here. The library is small, but I personally would like to see it modular.

./scripts/bloat-o-meter vmlinux vmlinux.after add/remove: 1/16 grow/shrink: 0/0 up/down: 8/-1980 (-1972)
Function old new delta

e843419@0740_00005048_4014                     -       8      +8
e843419@07b3_000055c6_5944                     8       -      -8
dim_park_on_top                                8       -      -8
dim_park_tired                                16       -     -16
net_dim_get_def_tx_moderation                 24       -     -24
net_dim_get_def_rx_moderation                 24       -     -24
dim_turn                                      52       -     -52
net_dim_get_rx_moderation                     60       -     -60
net_dim_get_tx_moderation                     64       -     -64
tx_profile                                    80       -     -80
rx_profile                                    80       -     -80
dim_on_top                                    84       -     -84
net_dim_step                                 132       -    -132
dim_calc_stats                               172       -    -172
net_dim_stats_compare                        176       -    -176
net_dim                                      464       -    -464
rdma_dim                                     536       -    -536

Total: Before=12668884, After=12666912, chg -0.02%

This is on arm64 FWIW.

Quoted 37 lines
Quoted 3 lines
Quoted 31 lines

---
Changes in v2:

- Added MODULE_DESCRIPTION()

  lib/Kconfig      | 2 +-
  lib/dim/Makefile | 4 ++--
  lib/dim/dim.c    | 3 +++
  3 files changed, 6 insertions(+), 3 deletions(-)
lib/Kconfig +1 -1
index 4557bb8a5256..d33a268bc256 100644
@@ -628,7 +628,7 @@ config SIGNATURE
  	  Implementation is done using GnuPG MPI library
 
  config DIMLIB
-	bool
+	tristate
  	help
  	  Dynamic Interrupt Moderation library.
  	  Implements an algorithm for dynamically changing CQ moderation values
lib/dim/Makefile +0 -0
index 1d6858a108cb..c4cc4026c451 100644
@@ -2,6 +2,6 @@
  # DIM Dynamic Interrupt Moderation library
  #
 
Quoted 4 lines

lib/dim/Makefile line 5

Quoted 2 lines
lib/dim/Makefile +1 -1
-obj-$(CONFIG_DIMLIB) += dim.o
+obj-$(CONFIG_DIMLIB) += dimlib.o

I guess you renamed it due to that there's already a module named 'dim'?

This is required to avoid the follow recursive dependency:

make[4]: Circular lib/dim/dim.o <- lib/dim/dim.o dependency dropped.

Signature · 1 line
Florian
#3 lore raw

From: Florian Fainelli <[email protected]>
Date: Tue, 7 May 2024 10:08:19 -0700

Quoted 35 lines · Alexander Lobakin
Quoted 11 lines

From: Florian Fainelli <[email protected]>
Date: Mon,  6 May 2024 10:50:40 -0700

Quoted 5 lines

Allow the Dynamic Interrupt Moderation (DIM) library to be built as a module. This is particularly useful in an Android GKI (Google Kernel Image) configuration where everything is built as a module, including Ethernet controller drivers. Having to build DIMLIB into the kernel image with potentially no user is wasteful.

Some bloat-o-meter -c vmlinux.{before,after} would be good to have here. The library is small, but I personally would like to see it modular.

./scripts/bloat-o-meter vmlinux vmlinux.after add/remove: 1/16 grow/shrink: 0/0 up/down: 8/-1980 (-1972) Function                                     old     new   delta e843419@0740_00005048_4014                     -       8      +8 e843419@07b3_000055c6_5944                     8       -      -8 dim_park_on_top                                8       -      -8 dim_park_tired                                16       -     -16 net_dim_get_def_tx_moderation                 24       -     -24 net_dim_get_def_rx_moderation                 24       -     -24 dim_turn                                      52       -     -52 net_dim_get_rx_moderation                     60       -     -60 net_dim_get_tx_moderation                     64       -     -64 tx_profile                                    80       -     -80 rx_profile                                    80       -     -80 dim_on_top                                    84       -     -84 net_dim_step                                 132       -    -132 dim_calc_stats                               172       -    -172 net_dim_stats_compare                        176       -    -176 net_dim                                      464       -    -464 rdma_dim                                     536       -    -536
Total: Before=12668884, After=12666912, chg -0.02%

Quoted 1 line

This is on arm64 FWIW.

-2 Kb sounds reasonable I'd say. This doesn't even require adding new exports, nice.

Quoted 42 lines
Quoted 33 lines
Quoted 4 lines
Quoted 26 lines

---
Changes in v2:

- Added MODULE_DESCRIPTION()

  lib/Kconfig      | 2 +-
  lib/dim/Makefile | 4 ++--
  lib/dim/dim.c    | 3 +++

  3 files changed, 6 insertions(+), 3 deletions(-)
lib/Kconfig +0 -0
index 4557bb8a5256..d33a268bc256 100644
@@ -628,7 +628,7 @@ config SIGNATURE

        Implementation is done using GnuPG MPI library config DIMLIB
-    bool
+    tristate
      help
        Dynamic Interrupt Moderation library. Implements an algorithm for dynamically changing CQ moderation values

lib/dim/Makefile +0 -1
index 1d6858a108cb..c4cc4026c451 100644
--- a/lib/dim/Makefile
Quoted 8 lines
Quoted 6 lines

+++ b/lib/dim/Makefile

lib/dim/Makefile +0 -0
@@ -2,6 +2,6 @@
   # DIM Dynamic Interrupt Moderation library
   #

  -obj-$(CONFIG_DIMLIB) += dim.o
+obj-$(CONFIG_DIMLIB) += dimlib.o

I guess you renamed it due to that there's already a module named 'dim'?

Quoted 3 lines

This is required to avoid the follow recursive dependency:

make[4]: Circular lib/dim/dim.o <- lib/dim/dim.o dependency dropped.

Aaah I see!

Thanks,
Olek

#4 lore raw
In reply to Florian Fainelli
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 6 May 2024 10:50:40 -0700 you wrote:

Allow the Dynamic Interrupt Moderation (DIM) library to be built as a module. This is particularly useful in an Android GKI (Google Kernel Image) configuration where everything is built as a module, including Ethernet controller drivers. Having to build DIMLIB into the kernel image with potentially no user is wasteful.

[...]

Here is the summary with links:
- [net-next,v2] lib: Allow for the DIM library to be modular

    https://git.kernel.org/netdev/net-next/c/0d5044b4e774

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html