* [PATCH v2 0/3] net: use vmalloc_array() to simplify code
@ 2025-08-14 10:20 Qianfeng Rong
2025-08-14 10:20 ` [PATCH v2 1/3] eth: intel: " Qianfeng Rong
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Qianfeng Rong @ 2025-08-14 10:20 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev,
moderated list:INTEL ETHERNET DRIVERS,
open list:NETWORKING DRIVERS, open list,
open list:NETRONOME ETHERNET DRIVERS,
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.
vmalloc_array() is also optimized better, resulting in less instructions
being used [1].
[1]: https://lore.kernel.org/lkml/abc66ec5-85a4-47e1-9759-2f60ab111971@vivo.com/
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
Changes in v2:
- Submit wireless patches separately and modified the commit message and
subject prefix.
---
Qianfeng Rong (3):
eth: intel: use vmalloc_array() to simplify code
nfp: flower: use vmalloc_array() to simplify code
ppp: 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 ++--
7 files changed, 17 insertions(+), 17 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/3] eth: intel: use vmalloc_array() to simplify code 2025-08-14 10:20 [PATCH v2 0/3] net: use vmalloc_array() to simplify code Qianfeng Rong @ 2025-08-14 10:20 ` Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 2/3] nfp: flower: " Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 3/3] ppp: " Qianfeng Rong 2 siblings, 0 replies; 7+ messages in thread From: Qianfeng Rong @ 2025-08-14 10:20 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, Aleksandr Loktionov, Paul Menzel Remove array_size() calls and replace vmalloc() with vmalloc_array() to simplify the code and maintain consistency with existing kmalloc_array() usage. vmalloc_array() is also optimized better, resulting in less instructions being used. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> --- 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] 7+ messages in thread
* [PATCH v2 2/3] nfp: flower: use vmalloc_array() to simplify code 2025-08-14 10:20 [PATCH v2 0/3] net: use vmalloc_array() to simplify code Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 1/3] eth: intel: " Qianfeng Rong @ 2025-08-14 10:20 ` Qianfeng Rong 2025-08-15 17:50 ` Jakub Kicinski 2025-08-16 5:58 ` kernel test robot 2025-08-14 10:20 ` [PATCH v2 3/3] ppp: " Qianfeng Rong 2 siblings, 2 replies; 7+ messages in thread From: Qianfeng Rong @ 2025-08-14 10:20 UTC (permalink / raw) To: Jakub Kicinski, Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, open list:NETRONOME ETHERNET DRIVERS, open list:NETWORKING DRIVERS, open list Cc: Qianfeng Rong Remove array_size() calls and replace vmalloc() with vmalloc_array() in nfp_flower_metadata_init(). vmalloc_array() is also optimized better, resulting in less instructions being used. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> --- drivers/net/ethernet/netronome/nfp/flower/metadata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 80e4675582bf..137e526e2584 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -564,8 +564,8 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, /* Init ring buffer and unallocated stats_ids. */ priv->stats_ids.free_list.buf = - vmalloc(array_size(NFP_FL_STATS_ELEM_RS, - priv->stats_ring_size)); + vmalloc_array(NFP_FL_STATS_ELEM_RS, + priv->stats_ring_size); if (!priv->stats_ids.free_list.buf) goto err_free_last_used; -- 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] nfp: flower: use vmalloc_array() to simplify code 2025-08-14 10:20 ` [PATCH v2 2/3] nfp: flower: " Qianfeng Rong @ 2025-08-15 17:50 ` Jakub Kicinski 2025-08-16 7:35 ` Qianfeng Rong 2025-08-16 5:58 ` kernel test robot 1 sibling, 1 reply; 7+ messages in thread From: Jakub Kicinski @ 2025-08-15 17:50 UTC (permalink / raw) To: Qianfeng Rong Cc: Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, open list:NETRONOME ETHERNET DRIVERS, open list:NETWORKING DRIVERS, open list On Thu, 14 Aug 2025 18:20:54 +0800 Qianfeng Rong wrote: > - vmalloc(array_size(NFP_FL_STATS_ELEM_RS, > - priv->stats_ring_size)); > + vmalloc_array(NFP_FL_STATS_ELEM_RS, > + priv->stats_ring_size); This generates a bunch of warnings on gcc when building with W=1 -- pw-bot: cr ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] nfp: flower: use vmalloc_array() to simplify code 2025-08-15 17:50 ` Jakub Kicinski @ 2025-08-16 7:35 ` Qianfeng Rong 0 siblings, 0 replies; 7+ messages in thread From: Qianfeng Rong @ 2025-08-16 7:35 UTC (permalink / raw) To: Jakub Kicinski Cc: Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, open list:NETRONOME ETHERNET DRIVERS, open list:NETWORKING DRIVERS, open list 在 2025/8/16 1:50, Jakub Kicinski 写道: > On Thu, 14 Aug 2025 18:20:54 +0800 Qianfeng Rong wrote: >> - vmalloc(array_size(NFP_FL_STATS_ELEM_RS, >> - priv->stats_ring_size)); >> + vmalloc_array(NFP_FL_STATS_ELEM_RS, >> + priv->stats_ring_size); > This generates a bunch of warnings on gcc when building with W=1 Thank you for pointing this out. I will research the issue and fix the warning immediately. Best regards, Qianfeng ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] nfp: flower: use vmalloc_array() to simplify code 2025-08-14 10:20 ` [PATCH v2 2/3] nfp: flower: " Qianfeng Rong 2025-08-15 17:50 ` Jakub Kicinski @ 2025-08-16 5:58 ` kernel test robot 1 sibling, 0 replies; 7+ messages in thread From: kernel test robot @ 2025-08-16 5:58 UTC (permalink / raw) To: Qianfeng Rong, Jakub Kicinski, Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, open list:NETRONOME ETHERNET DRIVERS, open list:NETWORKING DRIVERS, open list Cc: oe-kbuild-all, netdev, Qianfeng Rong Hi Qianfeng, kernel test robot noticed the following build warnings: [auto build test WARNING on tnguy-next-queue/dev-queue] [also build test WARNING on tnguy-net-queue/dev-queue net-next/main net/main linus/master v6.17-rc1 next-20250815] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Qianfeng-Rong/eth-intel-use-vmalloc_array-to-simplify-code/20250814-183400 base: https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue patch link: https://lore.kernel.org/r/20250814102100.151942-3-rongqianfeng%40vivo.com patch subject: [PATCH v2 2/3] nfp: flower: use vmalloc_array() to simplify code config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20250816/202508161307.IWBBnNXY-lkp@intel.com/config) compiler: s390-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508161307.IWBBnNXY-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202508161307.IWBBnNXY-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from include/linux/vmalloc.h:5, from drivers/net/ethernet/netronome/nfp/flower/metadata.c:8: drivers/net/ethernet/netronome/nfp/flower/metadata.c: In function 'nfp_flower_metadata_init': >> include/linux/stddef.h:24:42: warning: 'vmalloc_array_noprof' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:239:16: note: in definition of macro 'alloc_hooks_tag' 239 | typeof(_do_alloc) _res; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ include/linux/stddef.h:24:42: note: earlier argument should specify number of elements, later size of each element 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:239:16: note: in definition of macro 'alloc_hooks_tag' 239 | typeof(_do_alloc) _res; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ >> include/linux/stddef.h:24:42: warning: 'vmalloc_array_noprof' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:243:24: note: in definition of macro 'alloc_hooks_tag' 243 | _res = _do_alloc; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ include/linux/stddef.h:24:42: note: earlier argument should specify number of elements, later size of each element 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:243:24: note: in definition of macro 'alloc_hooks_tag' 243 | _res = _do_alloc; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ >> include/linux/stddef.h:24:42: warning: 'vmalloc_array_noprof' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:246:24: note: in definition of macro 'alloc_hooks_tag' 246 | _res = _do_alloc; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ include/linux/stddef.h:24:42: note: earlier argument should specify number of elements, later size of each element 24 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) | ^ include/linux/alloc_tag.h:246:24: note: in definition of macro 'alloc_hooks_tag' 246 | _res = _do_alloc; \ | ^~~~~~~~~ include/linux/vmalloc.h:192:33: note: in expansion of macro 'alloc_hooks' 192 | #define vmalloc_array(...) alloc_hooks(vmalloc_array_noprof(__VA_ARGS__)) | ^~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:17: note: in expansion of macro 'vmalloc_array' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/main.h:29:41: note: in expansion of macro 'sizeof_field' 29 | #define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \ | ^~~~~~~~~~~~ drivers/net/ethernet/netronome/nfp/flower/metadata.c:567:31: note: in expansion of macro 'NFP_FL_STATS_ELEM_RS' 567 | vmalloc_array(NFP_FL_STATS_ELEM_RS, | ^~~~~~~~~~~~~~~~~~~~ vim +24 include/linux/stddef.h 3876488444e712 Denys Vlasenko 2015-03-09 17 4229a470175be1 Kees Cook 2018-01-10 18 /** e7f18c22e6bea2 Kees Cook 2021-08-19 19 * sizeof_field() - Report the size of a struct field in bytes 4229a470175be1 Kees Cook 2018-01-10 20 * 4229a470175be1 Kees Cook 2018-01-10 21 * @TYPE: The structure containing the field of interest 4229a470175be1 Kees Cook 2018-01-10 22 * @MEMBER: The field to return the size of 4229a470175be1 Kees Cook 2018-01-10 23 */ 4229a470175be1 Kees Cook 2018-01-10 @24 #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) 4229a470175be1 Kees Cook 2018-01-10 25 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] ppp: use vmalloc_array() to simplify code 2025-08-14 10:20 [PATCH v2 0/3] net: use vmalloc_array() to simplify code Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 1/3] eth: intel: " Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 2/3] nfp: flower: " Qianfeng Rong @ 2025-08-14 10:20 ` Qianfeng Rong 2 siblings, 0 replies; 7+ messages in thread From: Qianfeng Rong @ 2025-08-14 10:20 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, open list:NETWORKING DRIVERS, open list Cc: Qianfeng Rong Remove array_size() calls and replace vmalloc() with vmalloc_array() in bsd_alloc(). vmalloc_array() is also optimized better, resulting in less instructions being used. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> --- drivers/net/ppp/bsd_comp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ppp/bsd_comp.c b/drivers/net/ppp/bsd_comp.c index 55954594e157..f385b759d5cf 100644 --- a/drivers/net/ppp/bsd_comp.c +++ b/drivers/net/ppp/bsd_comp.c @@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) * Allocate space for the dictionary. This may be more than one page in * length. */ - db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict))); + db->dict = vmalloc_array(hsize, sizeof(struct bsd_dict)); if (!db->dict) { bsd_free (db); @@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) */ else { - db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1))); + db->lens = vmalloc_array(maxmaxcode + 1, sizeof(db->lens[0])); if (!db->lens) { bsd_free (db); -- 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-16 7:35 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-08-14 10:20 [PATCH v2 0/3] net: use vmalloc_array() to simplify code Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 1/3] eth: intel: " Qianfeng Rong 2025-08-14 10:20 ` [PATCH v2 2/3] nfp: flower: " Qianfeng Rong 2025-08-15 17:50 ` Jakub Kicinski 2025-08-16 7:35 ` Qianfeng Rong 2025-08-16 5:58 ` kernel test robot 2025-08-14 10:20 ` [PATCH v2 3/3] ppp: " Qianfeng Rong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®