* [PATCH 0/5] net: use vmalloc_array() to simplify code
@ 2025-08-12 13:32 Qianfeng Rong
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
2025-08-12 20:48 ` [PATCH 0/5] net: " Jakub Kicinski
0 siblings, 2 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-12 13:32 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jiri Slaby, Nick Kossifidis, Luis Chamberlain, Brian Norris,
Francesco Dolcini, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Qianfeng Rong, Johannes Berg, Sascha Hauer, Kalle Valo,
Aditya Kumar Singh, Roopni Devanathan, Dan Carpenter,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
Remove array_size() calls and replace vmalloc() with vmalloc_array() to
simplify the code and maintain consistency with existing kmalloc_array()
usage.
Compile-tested only.
Qianfeng Rong (5):
ethtool: use vmalloc_array() to simplify code
nfp: flower: use vmalloc_array() to simplify code
ppp: use vmalloc_array() to simplify
wifi: ath5k: use vmalloc_array() to simplify code
wifi: mwifiex: use vmalloc_array() to simplify code
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
drivers/net/ethernet/netronome/nfp/flower/metadata.c | 4 ++--
drivers/net/ppp/bsd_comp.c | 4 ++--
drivers/net/wireless/ath/ath5k/debug.c | 2 +-
drivers/net/wireless/marvell/mwifiex/cfg80211.c | 4 ++--
9 files changed, 20 insertions(+), 20 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 13:32 [PATCH 0/5] net: use vmalloc_array() to simplify code Qianfeng Rong
@ 2025-08-12 13:32 ` Qianfeng Rong
2025-08-12 16:28 ` [Intel-wired-lan] " Loktionov, Aleksandr
` (2 more replies)
2025-08-12 20:48 ` [PATCH 0/5] net: " Jakub Kicinski
1 sibling, 3 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-12 13:32 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
Cc: Qianfeng Rong
Remove array_size() calls and replace vmalloc() with vmalloc_array() to
simplify the code and maintain consistency with existing kmalloc_array()
usage.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
index 1954a04460d1..bf2029144c1d 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
@@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
/* allocate temporary buffer to store rings in */
i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
- temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
+ temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 92ef33459aec..51d5cb6599ed 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device *netdev,
}
if (adapter->num_tx_queues > adapter->num_rx_queues)
- temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
- adapter->num_tx_queues));
+ temp_ring = vmalloc_array(adapter->num_tx_queues,
+ sizeof(struct igb_ring));
else
- temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
- adapter->num_rx_queues));
+ temp_ring = vmalloc_array(adapter->num_rx_queues,
+ sizeof(struct igb_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index ecb35b693ce5..f3e7218ba6f3 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device *netdev,
}
if (adapter->num_tx_queues > adapter->num_rx_queues)
- temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
- adapter->num_tx_queues));
+ temp_ring = vmalloc_array(adapter->num_tx_queues,
+ sizeof(struct igc_ring));
else
- temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
- adapter->num_rx_queues));
+ temp_ring = vmalloc_array(adapter->num_rx_queues,
+ sizeof(struct igc_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 25c3a09ad7f1..2c5d774f1ec1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
/* allocate temporary buffer to store rings in */
i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
adapter->num_rx_queues);
- temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
+ temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index 7ac53171b041..bebad564188e 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
}
if (new_tx_count != adapter->tx_ring_count) {
- tx_ring = vmalloc(array_size(sizeof(*tx_ring),
- adapter->num_tx_queues +
- adapter->num_xdp_queues));
+ tx_ring = vmalloc_array(adapter->num_tx_queues +
+ adapter->num_xdp_queues,
+ sizeof(*tx_ring));
if (!tx_ring) {
err = -ENOMEM;
goto clear_reset;
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
@ 2025-08-12 16:28 ` Loktionov, Aleksandr
2025-08-12 16:34 ` Paul Menzel
2025-08-12 20:49 ` Jakub Kicinski
2 siblings, 0 replies; 12+ messages in thread
From: Loktionov, Aleksandr @ 2025-08-12 16:28 UTC (permalink / raw)
To: Qianfeng Rong, Nguyen, Anthony L, Kitszel, Przemyslaw,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:XDP (eXpress Data Path):Keyword:(?:\b|_)xdp(?:\b|_)
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Qianfeng Rong
> Sent: Tuesday, August 12, 2025 3:32 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Alexei Starovoitov <ast@kernel.org>; Daniel
> Borkmann <daniel@iogearbox.net>; Jesper Dangaard Brouer
> <hawk@kernel.org>; John Fastabend <john.fastabend@gmail.com>;
> Stanislav Fomichev <sdf@fomichev.me>; moderated list:INTEL ETHERNET
> DRIVERS <intel-wired-lan@lists.osuosl.org>; open list:NETWORKING
> DRIVERS <netdev@vger.kernel.org>; open list <linux-
> kernel@vger.kernel.org>; open list:XDP (eXpress Data
> Path):Keyword:(?:\b|_)xdp(?:\b|_) <bpf@vger.kernel.org>
> Cc: Qianfeng Rong <rongqianfeng@vivo.com>
> Subject: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to
> simplify code
>
> Remove array_size() calls and replace vmalloc() with vmalloc_array()
> to simplify the code and maintain consistency with existing
> kmalloc_array() usage.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
> drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
> drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> index 1954a04460d1..bf2029144c1d 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> @@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device
> *netdev,
>
> /* allocate temporary buffer to store rings in */
> i = max_t(int, interface->num_tx_queues, interface-
> >num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> index 92ef33459aec..51d5cb6599ed 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> @@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device
> *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igb_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igb_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index ecb35b693ce5..f3e7218ba6f3 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device
> *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igc_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igc_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 25c3a09ad7f1..2c5d774f1ec1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device
> *netdev,
> /* allocate temporary buffer to store rings in */
> i = max_t(int, adapter->num_tx_queues + adapter-
> >num_xdp_queues,
> adapter->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> index 7ac53171b041..bebad564188e 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> @@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device
> *netdev,
> }
>
> if (new_tx_count != adapter->tx_ring_count) {
> - tx_ring = vmalloc(array_size(sizeof(*tx_ring),
> - adapter->num_tx_queues +
> - adapter->num_xdp_queues));
> + tx_ring = vmalloc_array(adapter->num_tx_queues +
> + adapter->num_xdp_queues,
> + sizeof(*tx_ring));
> if (!tx_ring) {
> err = -ENOMEM;
> goto clear_reset;
> --
> 2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
2025-08-12 16:28 ` [Intel-wired-lan] " Loktionov, Aleksandr
@ 2025-08-12 16:34 ` Paul Menzel
2025-08-14 4:05 ` Qianfeng Rong
2025-08-12 20:49 ` Jakub Kicinski
2 siblings, 1 reply; 12+ messages in thread
From: Paul Menzel @ 2025-08-12 16:34 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, intel-wired-lan, netdev, LKML, bpf
Dear Qianfeng,
Thank you for your patch.
Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
> simplify the code and maintain consistency with existing kmalloc_array()
> usage.
You could build it without and with your patch and look if the assembler
code changes.
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
> drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
> drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> index 1954a04460d1..bf2029144c1d 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> @@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
>
> /* allocate temporary buffer to store rings in */
> i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> index 92ef33459aec..51d5cb6599ed 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> @@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igb_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igb_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index ecb35b693ce5..f3e7218ba6f3 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igc_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igc_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 25c3a09ad7f1..2c5d774f1ec1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
> /* allocate temporary buffer to store rings in */
> i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
> adapter->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> index 7ac53171b041..bebad564188e 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> @@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
> }
>
> if (new_tx_count != adapter->tx_ring_count) {
> - tx_ring = vmalloc(array_size(sizeof(*tx_ring),
> - adapter->num_tx_queues +
> - adapter->num_xdp_queues));
> + tx_ring = vmalloc_array(adapter->num_tx_queues +
> + adapter->num_xdp_queues,
> + sizeof(*tx_ring));
> if (!tx_ring) {
> err = -ENOMEM;
> goto clear_reset;
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/5] net: use vmalloc_array() to simplify code
2025-08-12 13:32 [PATCH 0/5] net: use vmalloc_array() to simplify code Qianfeng Rong
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
@ 2025-08-12 20:48 ` Jakub Kicinski
2025-08-13 1:53 ` Qianfeng Rong
2025-08-13 6:49 ` Qianfeng Rong
1 sibling, 2 replies; 12+ messages in thread
From: Jakub Kicinski @ 2025-08-12 20:48 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain, Brian Norris,
Francesco Dolcini, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Johannes Berg, Sascha Hauer, Kalle Valo, Aditya Kumar Singh,
Roopni Devanathan, Dan Carpenter,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
On Tue, 12 Aug 2025 21:32:13 +0800 Qianfeng Rong wrote:
> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
> simplify the code and maintain consistency with existing kmalloc_array()
> usage.
You need to submit the first 3 as a separate series.
They get applied to a different tree than wireless patches.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
2025-08-12 16:28 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-08-12 16:34 ` Paul Menzel
@ 2025-08-12 20:49 ` Jakub Kicinski
2025-08-13 7:00 ` Qianfeng Rong
2 siblings, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2025-08-12 20:49 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
On Tue, 12 Aug 2025 21:32:14 +0800 Qianfeng Rong wrote:
> Subject: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
ethtool:
would make sense for patches which touch net/ethtool.
Please use
eth: intel:
as the subject prefix.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/5] net: use vmalloc_array() to simplify code
2025-08-12 20:48 ` [PATCH 0/5] net: " Jakub Kicinski
@ 2025-08-13 1:53 ` Qianfeng Rong
2025-08-13 6:49 ` Qianfeng Rong
1 sibling, 0 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-13 1:53 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain, Brian Norris,
Francesco Dolcini, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Johannes Berg, Sascha Hauer, Kalle Valo, Aditya Kumar Singh,
Roopni Devanathan, Dan Carpenter,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
在 2025/8/13 4:48, Jakub Kicinski 写道:
> On Tue, 12 Aug 2025 21:32:13 +0800 Qianfeng Rong wrote:
>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>> simplify the code and maintain consistency with existing kmalloc_array()
>> usage.
> You need to submit the first 3 as a separate series.
> They get applied to a different tree than wireless patches.
Ok, Will do in the next version.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/5] net: use vmalloc_array() to simplify code
2025-08-12 20:48 ` [PATCH 0/5] net: " Jakub Kicinski
2025-08-13 1:53 ` Qianfeng Rong
@ 2025-08-13 6:49 ` Qianfeng Rong
1 sibling, 0 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-13 6:49 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain, Brian Norris,
Francesco Dolcini, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Johannes Berg, Sascha Hauer, Kalle Valo, Aditya Kumar Singh,
Roopni Devanathan, Dan Carpenter,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
在 2025/8/13 4:48, Jakub Kicinski 写道:
> On Tue, 12 Aug 2025 21:32:13 +0800 Qianfeng Rong wrote:
>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>> simplify the code and maintain consistency with existing kmalloc_array()
>> usage.
> You need to submit the first 3 as a separate series.
> They get applied to a different tree than wireless patches.
Ok,Will do in the next version.
Best regards,
Qianfeng
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 20:49 ` Jakub Kicinski
@ 2025-08-13 7:00 ` Qianfeng Rong
0 siblings, 0 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-13 7:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)
在 2025/8/13 4:49, Jakub Kicinski 写道:
> On Tue, 12 Aug 2025 21:32:14 +0800 Qianfeng Rong wrote:
>> Subject: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
> ethtool:
>
> would make sense for patches which touch net/ethtool.
> Please use
>
> eth: intel:
>
> as the subject prefix.
Got it. Will do in the next version.
Best regards,
Qianfeng
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-12 16:34 ` Paul Menzel
@ 2025-08-14 4:05 ` Qianfeng Rong
2025-08-14 6:28 ` Paul Menzel
0 siblings, 1 reply; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-14 4:05 UTC (permalink / raw)
To: Paul Menzel
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, intel-wired-lan, netdev, LKML, bpf
在 2025/8/13 0:34, Paul Menzel 写道:
> [You don't often get email from pmenzel@molgen.mpg.de. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Dear Qianfeng,
>
>
> Thank you for your patch.
>
> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>> simplify the code and maintain consistency with existing kmalloc_array()
>> usage.
>
> You could build it without and with your patch and look if the assembler
> code changes.
>
Very good point, the following experiment was done:
//before apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
//after apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
diff -u original.dis patched.dis | diffstat
patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793 deletions(-)
From the above results, we can see that the assembly instructions are
reduced after applying the patch.
#define array_size(a, b) size_mul(a, b)
static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
{
size_t bytes;
if (check_mul_overflow(factor1, factor2, &bytes))
return SIZE_MAX;
return bytes;
}
void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
{
size_t bytes;
if (unlikely(check_mul_overflow(n, size, &bytes)))
return NULL;
return __vmalloc_noprof(bytes, flags);
}
And from the code, array_size() will return SIZE_MAX after detecting
overflow. SIZE_MAX is passed to vmalloc for available memory
verification before exiting and returning NULL. vmalloc_array()
will directly return NULL after detecting overflow.
Best regards,
Qianfeng
> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
>
> Kind regards,
>
> Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-14 4:05 ` Qianfeng Rong
@ 2025-08-14 6:28 ` Paul Menzel
2025-08-14 6:41 ` Qianfeng Rong
0 siblings, 1 reply; 12+ messages in thread
From: Paul Menzel @ 2025-08-14 6:28 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, intel-wired-lan, netdev, LKML, bpf
Dear Quianfeng,
Thank you very much for your reply.
Am 14.08.25 um 06:05 schrieb Qianfeng Rong:
>
> 在 2025/8/13 0:34, Paul Menzel 写道:
[…]
>> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>>> simplify the code and maintain consistency with existing kmalloc_array()
>>> usage.
>>
>> You could build it without and with your patch and look if the assembler
>> code changes.
>
> Very good point, the following experiment was done:
> //before apply patch:
> objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
>
> //after apply patch:
> objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
>
> diff -u original.dis patched.dis | diffstat
> patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793 deletions(-)
>
> From the above results, we can see that the assembly instructions are
> reduced after applying the patch.
>
>
> #define array_size(a, b) size_mul(a, b)
>
> static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
> {
> size_t bytes;
>
> if (check_mul_overflow(factor1, factor2, &bytes))
> return SIZE_MAX;
>
> return bytes;
> }
>
> void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
> {
> size_t bytes;
>
> if (unlikely(check_mul_overflow(n, size, &bytes)))
> return NULL;
> return __vmalloc_noprof(bytes, flags);
> }
>
> And from the code, array_size() will return SIZE_MAX after detecting
> overflow. SIZE_MAX is passed to vmalloc for available memory
> verification before exiting and returning NULL. vmalloc_array()
> will directly return NULL after detecting overflow.
Awesome! Thank you for digging that up. Maybe something to add to the
commit message. Maybe something like:
`vmalloc_array()` is also optimized better, resulting in less
instructions being used, which can be verified with:
objdump -dSl --prefix-addresses <changed module>.o
>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to simplify code
2025-08-14 6:28 ` Paul Menzel
@ 2025-08-14 6:41 ` Qianfeng Rong
0 siblings, 0 replies; 12+ messages in thread
From: Qianfeng Rong @ 2025-08-14 6:41 UTC (permalink / raw)
To: Paul Menzel
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, intel-wired-lan, netdev, LKML, bpf
在 2025/8/14 14:28, Paul Menzel 写道:
> [You don't often get email from pmenzel@molgen.mpg.de. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Dear Quianfeng,
>
>
> Thank you very much for your reply.
>
> Am 14.08.25 um 06:05 schrieb Qianfeng Rong:
>>
>> 在 2025/8/13 0:34, Paul Menzel 写道:
>
> […]
>
>>> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>>>> Remove array_size() calls and replace vmalloc() with
>>>> vmalloc_array() to
>>>> simplify the code and maintain consistency with existing
>>>> kmalloc_array()
>>>> usage.
>>>
>>> You could build it without and with your patch and look if the
>>> assembler
>>> code changes.
>>
>> Very good point, the following experiment was done:
>> //before apply patch:
>> objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
>>
>> //after apply patch:
>> objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
>>
>> diff -u original.dis patched.dis | diffstat
>> patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793
>> deletions(-)
>>
>> From the above results, we can see that the assembly instructions are
>> reduced after applying the patch.
>>
>>
>> #define array_size(a, b) size_mul(a, b)
>>
>> static inline size_t __must_check size_mul(size_t factor1, size_t
>> factor2)
>> {
>> size_t bytes;
>>
>> if (check_mul_overflow(factor1, factor2, &bytes))
>> return SIZE_MAX;
>>
>> return bytes;
>> }
>>
>> void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
>> {
>> size_t bytes;
>>
>> if (unlikely(check_mul_overflow(n, size, &bytes)))
>> return NULL;
>> return __vmalloc_noprof(bytes, flags);
>> }
>>
>> And from the code, array_size() will return SIZE_MAX after detecting
>> overflow. SIZE_MAX is passed to vmalloc for available memory
>> verification before exiting and returning NULL. vmalloc_array()
>> will directly return NULL after detecting overflow.
>
> Awesome! Thank you for digging that up. Maybe something to add to the
> commit message. Maybe something like:
>
> `vmalloc_array()` is also optimized better, resulting in less
> instructions being used, which can be verified with:
>
> objdump -dSl --prefix-addresses <changed module>.o
Ok,I'll release v2 later.
>
>>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
>
> Kind regards,
>
> Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-08-14 6:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 13:32 [PATCH 0/5] net: use vmalloc_array() to simplify code Qianfeng Rong
2025-08-12 13:32 ` [PATCH 1/5] ethtool: " Qianfeng Rong
2025-08-12 16:28 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-08-12 16:34 ` Paul Menzel
2025-08-14 4:05 ` Qianfeng Rong
2025-08-14 6:28 ` Paul Menzel
2025-08-14 6:41 ` Qianfeng Rong
2025-08-12 20:49 ` Jakub Kicinski
2025-08-13 7:00 ` Qianfeng Rong
2025-08-12 20:48 ` [PATCH 0/5] net: " Jakub Kicinski
2025-08-13 1:53 ` Qianfeng Rong
2025-08-13 6:49 ` Qianfeng Rong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).