* [PATCH net 0/2] DIM fixes for 5.3
@ 2019-07-23 7:22 Leon Romanovsky
2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Leon Romanovsky @ 2019-07-23 7:22 UTC (permalink / raw)
To: David S . Miller
Cc: Leon Romanovsky, Doug Ledford, Jason Gunthorpe, RDMA mailing list,
Tal Gilboa, Yamin Friedman, Saeed Mahameed, linux-netdev
From: Leon Romanovsky <leonro@mellanox.com>
Hi,
Those two fixes for recently merged DIM patches, both exposed through
RDMa DIM usage.
Thanks
Leon Romanovsky (1):
lib/dim: Fix -Wunused-const-variable warnings
Yamin Friedman (1):
linux/dim: Fix overflow in dim calculation
drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
.../net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
.../net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 +-
include/linux/dim.h | 56 -------------------
lib/dim/dim.c | 4 +-
lib/dim/net_dim.c | 56 +++++++++++++++++++
7 files changed, 63 insertions(+), 63 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH net 1/2] linux/dim: Fix overflow in dim calculation 2019-07-23 7:22 [PATCH net 0/2] DIM fixes for 5.3 Leon Romanovsky @ 2019-07-23 7:22 ` Leon Romanovsky 2019-07-23 17:22 ` Saeed Mahameed 2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky 2019-07-25 18:34 ` [PATCH net 0/2] DIM fixes for 5.3 David Miller 2 siblings, 1 reply; 9+ messages in thread From: Leon Romanovsky @ 2019-07-23 7:22 UTC (permalink / raw) To: David S . Miller Cc: Leon Romanovsky, Doug Ledford, Jason Gunthorpe, RDMA mailing list, Tal Gilboa, Yamin Friedman, Saeed Mahameed, linux-netdev From: Yamin Friedman <yaminf@mellanox.com> While using net_dim, a dim_sample was used without ever initializing the comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential overflow, it should not be a problem to save the final result in an int because after the division by epms the value should not be larger than a few thousand. [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23 [ 1040.130118] signed integer overflow: [ 1040.131643] 134718714 * 100 cannot be represented in type 'int' Fixes: 398c2b05bbee ("linux/dim: Add completions count to dim_sample") Signed-off-by: Yamin Friedman <yaminf@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> --- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- lib/dim/dim.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index b9c5cea8db16..9483553ce444 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -992,7 +992,7 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget) { struct bcm_sysport_priv *priv = container_of(napi, struct bcm_sysport_priv, napi); - struct dim_sample dim_sample; + struct dim_sample dim_sample = {}; unsigned int work_done = 0; work_done = bcm_sysport_desc_rx(priv, budget); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7134d2c3eb1c..7070349915bc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2136,7 +2136,7 @@ static int bnxt_poll(struct napi_struct *napi, int budget) } } if (bp->flags & BNXT_FLAG_DIM) { - struct dim_sample dim_sample; + struct dim_sample dim_sample = {}; dim_update_sample(cpr->event_ctr, cpr->rx_packets, diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index a2b57807453b..d3a0b614dbfa 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1895,7 +1895,7 @@ static int bcmgenet_rx_poll(struct napi_struct *napi, int budget) { struct bcmgenet_rx_ring *ring = container_of(napi, struct bcmgenet_rx_ring, napi); - struct dim_sample dim_sample; + struct dim_sample dim_sample = {}; unsigned int work_done; work_done = bcmgenet_desc_rx(ring, budget); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index c50b6f0769c8..49b06b256c92 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c @@ -49,7 +49,7 @@ static inline bool mlx5e_channel_no_affinity_change(struct mlx5e_channel *c) static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq) { struct mlx5e_sq_stats *stats = sq->stats; - struct dim_sample dim_sample; + struct dim_sample dim_sample = {}; if (unlikely(!test_bit(MLX5E_SQ_STATE_AM, &sq->state))) return; @@ -61,7 +61,7 @@ static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq) static void mlx5e_handle_rx_dim(struct mlx5e_rq *rq) { struct mlx5e_rq_stats *stats = rq->stats; - struct dim_sample dim_sample; + struct dim_sample dim_sample = {}; if (unlikely(!test_bit(MLX5E_RQ_STATE_AM, &rq->state))) return; diff --git a/lib/dim/dim.c b/lib/dim/dim.c index 439d641ec796..38045d6d0538 100644 --- a/lib/dim/dim.c +++ b/lib/dim/dim.c @@ -74,8 +74,8 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end, delta_us); curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us); if (curr_stats->epms != 0) - curr_stats->cpe_ratio = - (curr_stats->cpms * 100) / curr_stats->epms; + curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL( + curr_stats->cpms * 100, curr_stats->epms); else curr_stats->cpe_ratio = 0; -- 2.20.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 1/2] linux/dim: Fix overflow in dim calculation 2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky @ 2019-07-23 17:22 ` Saeed Mahameed 2019-07-23 18:04 ` Leon Romanovsky 0 siblings, 1 reply; 9+ messages in thread From: Saeed Mahameed @ 2019-07-23 17:22 UTC (permalink / raw) To: davem@davemloft.net, leon@kernel.org Cc: Jason Gunthorpe, Yamin Friedman, linux-rdma@vger.kernel.org, Tal Gilboa, Leon Romanovsky, dledford@redhat.com, netdev@vger.kernel.org On Tue, 2019-07-23 at 10:22 +0300, Leon Romanovsky wrote: > From: Yamin Friedman <yaminf@mellanox.com> > > While using net_dim, a dim_sample was used without ever initializing > the > comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential > overflow, it should not be a problem to save the final result in an > int > because after the division by epms the value should not be larger > than a > few thousand. > > [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23 > [ 1040.130118] signed integer overflow: > [ 1040.131643] 134718714 * 100 cannot be represented in type 'int' > > Fixes: 398c2b05bbee ("linux/dim: Add completions count to > dim_sample") > Signed-off-by: Yamin Friedman <yaminf@mellanox.com> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> > --- > drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- > drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- > lib/dim/dim.c | 4 ++-- > 5 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c > b/drivers/net/ethernet/broadcom/bcmsysport.c > index b9c5cea8db16..9483553ce444 100644 > --- a/drivers/net/ethernet/broadcom/bcmsysport.c > +++ b/drivers/net/ethernet/broadcom/bcmsysport.c > @@ -992,7 +992,7 @@ static int bcm_sysport_poll(struct napi_struct > *napi, int budget) > { > struct bcm_sysport_priv *priv = > container_of(napi, struct bcm_sysport_priv, napi); > - struct dim_sample dim_sample; > + struct dim_sample dim_sample = {}; net_dim implementation doesn't care about sample->comp_ctr, so this is unnecessary for the sake of fixing the rdma overflow issue, but it doens't hurt anyone to have this change in this patch, although Tariq already sent me a fix that i applied to my internal queues. > unsigned int work_done = 0; > > work_done = bcm_sysport_desc_rx(priv, budget); > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c > b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > index 7134d2c3eb1c..7070349915bc 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > @@ -2136,7 +2136,7 @@ static int bnxt_poll(struct napi_struct *napi, > int budget) > } > } > if (bp->flags & BNXT_FLAG_DIM) { > - struct dim_sample dim_sample; > + struct dim_sample dim_sample = {}; > > dim_update_sample(cpr->event_ctr, > cpr->rx_packets, > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c > b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > index a2b57807453b..d3a0b614dbfa 100644 > --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c > +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > @@ -1895,7 +1895,7 @@ static int bcmgenet_rx_poll(struct napi_struct > *napi, int budget) > { > struct bcmgenet_rx_ring *ring = container_of(napi, > struct bcmgenet_rx_ring, napi); > - struct dim_sample dim_sample; > + struct dim_sample dim_sample = {}; > unsigned int work_done; > > work_done = bcmgenet_desc_rx(ring, budget); > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c > b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c > index c50b6f0769c8..49b06b256c92 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c > @@ -49,7 +49,7 @@ static inline bool > mlx5e_channel_no_affinity_change(struct mlx5e_channel *c) > static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq) > { > struct mlx5e_sq_stats *stats = sq->stats; > - struct dim_sample dim_sample; > + struct dim_sample dim_sample = {}; > > if (unlikely(!test_bit(MLX5E_SQ_STATE_AM, &sq->state))) > return; > @@ -61,7 +61,7 @@ static void mlx5e_handle_tx_dim(struct mlx5e_txqsq > *sq) > static void mlx5e_handle_rx_dim(struct mlx5e_rq *rq) > { > struct mlx5e_rq_stats *stats = rq->stats; > - struct dim_sample dim_sample; > + struct dim_sample dim_sample = {}; > > if (unlikely(!test_bit(MLX5E_RQ_STATE_AM, &rq->state))) > return; > diff --git a/lib/dim/dim.c b/lib/dim/dim.c > index 439d641ec796..38045d6d0538 100644 > --- a/lib/dim/dim.c > +++ b/lib/dim/dim.c > @@ -74,8 +74,8 @@ void dim_calc_stats(struct dim_sample *start, > struct dim_sample *end, > delta_us); > curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, > delta_us); > if (curr_stats->epms != 0) BTW unrelated to this changed but curr_stats->epms can never be 0 due to DIV_ROUND_UP. we can save a condition here. > - curr_stats->cpe_ratio = > - (curr_stats->cpms * 100) / curr_stats- > >epms; > + curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL( > + curr_stats->cpms * 100, curr_stats->epms); > else > curr_stats->cpe_ratio = 0; > LGTM, Acked-by: Saeed Mahameed <saeedm@mellanox.com> > -- > 2.20.1 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 1/2] linux/dim: Fix overflow in dim calculation 2019-07-23 17:22 ` Saeed Mahameed @ 2019-07-23 18:04 ` Leon Romanovsky 0 siblings, 0 replies; 9+ messages in thread From: Leon Romanovsky @ 2019-07-23 18:04 UTC (permalink / raw) To: Saeed Mahameed Cc: davem@davemloft.net, Jason Gunthorpe, Yamin Friedman, linux-rdma@vger.kernel.org, Tal Gilboa, dledford@redhat.com, netdev@vger.kernel.org On Tue, Jul 23, 2019 at 05:22:43PM +0000, Saeed Mahameed wrote: > On Tue, 2019-07-23 at 10:22 +0300, Leon Romanovsky wrote: > > From: Yamin Friedman <yaminf@mellanox.com> > > > > While using net_dim, a dim_sample was used without ever initializing > > the > > comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential > > overflow, it should not be a problem to save the final result in an > > int > > because after the division by epms the value should not be larger > > than a > > few thousand. > > > > [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23 > > [ 1040.130118] signed integer overflow: > > [ 1040.131643] 134718714 * 100 cannot be represented in type 'int' > > > > Fixes: 398c2b05bbee ("linux/dim: Add completions count to > > dim_sample") > > Signed-off-by: Yamin Friedman <yaminf@mellanox.com> > > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> > > --- > > drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- > > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- > > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- > > drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- > > lib/dim/dim.c | 4 ++-- > > 5 files changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c > > b/drivers/net/ethernet/broadcom/bcmsysport.c > > index b9c5cea8db16..9483553ce444 100644 > > --- a/drivers/net/ethernet/broadcom/bcmsysport.c > > +++ b/drivers/net/ethernet/broadcom/bcmsysport.c > > @@ -992,7 +992,7 @@ static int bcm_sysport_poll(struct napi_struct > > *napi, int budget) > > { > > struct bcm_sysport_priv *priv = > > container_of(napi, struct bcm_sysport_priv, napi); > > - struct dim_sample dim_sample; > > + struct dim_sample dim_sample = {}; > > net_dim implementation doesn't care about sample->comp_ctr, so this is > unnecessary for the sake of fixing the rdma overflow issue, but it > doens't hurt anyone to have this change in this patch. Yes, this is why we decided to change all drivers and not mlx5 only. Thanks ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings 2019-07-23 7:22 [PATCH net 0/2] DIM fixes for 5.3 Leon Romanovsky 2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky @ 2019-07-23 7:22 ` Leon Romanovsky 2019-07-23 15:57 ` Bart Van Assche 2019-07-23 17:05 ` Saeed Mahameed 2019-07-25 18:34 ` [PATCH net 0/2] DIM fixes for 5.3 David Miller 2 siblings, 2 replies; 9+ messages in thread From: Leon Romanovsky @ 2019-07-23 7:22 UTC (permalink / raw) To: David S . Miller Cc: Leon Romanovsky, Doug Ledford, Jason Gunthorpe, RDMA mailing list, Tal Gilboa, Yamin Friedman, Saeed Mahameed, linux-netdev From: Leon Romanovsky <leonro@mellanox.com> DIM causes to the following warnings during kernel compilation which indicates that tx_profile and rx_profile are supposed to be declared in *.c and not in *.h files. In file included from ./include/rdma/ib_verbs.h:64, from ./include/linux/mlx5/device.h:37, from ./include/linux/mlx5/driver.h:51, from ./include/linux/mlx5/vport.h:36, from drivers/infiniband/hw/mlx5/ib_virt.c:34: ./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not used [-Wunused-const-variable=] 326 | tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { | ^~~~~~~~~~ ./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not used [-Wunused-const-variable=] 320 | rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { | ^~~~~~~~~~ Fixes: 4f75da3666c0 ("linux/dim: Move implementation to .c files") Signed-off-by: Leon Romanovsky <leonro@mellanox.com> --- include/linux/dim.h | 56 --------------------------------------------- lib/dim/net_dim.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/linux/dim.h b/include/linux/dim.h index d3a0fbfff2bb..9fa4b3f88c39 100644 --- a/include/linux/dim.h +++ b/include/linux/dim.h @@ -272,62 +272,6 @@ dim_update_sample_with_comps(u16 event_ctr, u64 packets, u64 bytes, u64 comps, /* Net DIM */ -/* - * Net DIM profiles: - * There are different set of profiles for each CQ period mode. - * There are different set of profiles for RX/TX CQs. - * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES - */ -#define NET_DIM_PARAMS_NUM_PROFILES 5 -#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 -#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 -#define NET_DIM_DEF_PROFILE_CQE 1 -#define NET_DIM_DEF_PROFILE_EQE 1 - -#define NET_DIM_RX_EQE_PROFILES { \ - {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ -} - -#define NET_DIM_RX_CQE_PROFILES { \ - {2, 256}, \ - {8, 128}, \ - {16, 64}, \ - {32, 64}, \ - {64, 64} \ -} - -#define NET_DIM_TX_EQE_PROFILES { \ - {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ - {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ -} - -#define NET_DIM_TX_CQE_PROFILES { \ - {5, 128}, \ - {8, 64}, \ - {16, 32}, \ - {32, 32}, \ - {64, 32} \ -} - -static const struct dim_cq_moder -rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { - NET_DIM_RX_EQE_PROFILES, - NET_DIM_RX_CQE_PROFILES, -}; - -static const struct dim_cq_moder -tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { - NET_DIM_TX_EQE_PROFILES, - NET_DIM_TX_CQE_PROFILES, -}; - /** * net_dim_get_rx_moderation - provide a CQ moderation object for the given RX profile * @cq_period_mode: CQ period mode diff --git a/lib/dim/net_dim.c b/lib/dim/net_dim.c index 5bcc902c5388..a4db51c21266 100644 --- a/lib/dim/net_dim.c +++ b/lib/dim/net_dim.c @@ -5,6 +5,62 @@ #include <linux/dim.h> +/* + * Net DIM profiles: + * There are different set of profiles for each CQ period mode. + * There are different set of profiles for RX/TX CQs. + * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES + */ +#define NET_DIM_PARAMS_NUM_PROFILES 5 +#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 +#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 +#define NET_DIM_DEF_PROFILE_CQE 1 +#define NET_DIM_DEF_PROFILE_EQE 1 + +#define NET_DIM_RX_EQE_PROFILES { \ + {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ +} + +#define NET_DIM_RX_CQE_PROFILES { \ + {2, 256}, \ + {8, 128}, \ + {16, 64}, \ + {32, 64}, \ + {64, 64} \ +} + +#define NET_DIM_TX_EQE_PROFILES { \ + {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ + {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ +} + +#define NET_DIM_TX_CQE_PROFILES { \ + {5, 128}, \ + {8, 64}, \ + {16, 32}, \ + {32, 32}, \ + {64, 32} \ +} + +static const struct dim_cq_moder +rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { + NET_DIM_RX_EQE_PROFILES, + NET_DIM_RX_CQE_PROFILES, +}; + +static const struct dim_cq_moder +tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { + NET_DIM_TX_EQE_PROFILES, + NET_DIM_TX_CQE_PROFILES, +}; + struct dim_cq_moder net_dim_get_rx_moderation(u8 cq_period_mode, int ix) { -- 2.20.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings 2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky @ 2019-07-23 15:57 ` Bart Van Assche 2019-07-23 17:05 ` Saeed Mahameed 1 sibling, 0 replies; 9+ messages in thread From: Bart Van Assche @ 2019-07-23 15:57 UTC (permalink / raw) To: Leon Romanovsky, David S . Miller Cc: Leon Romanovsky, Doug Ledford, Jason Gunthorpe, RDMA mailing list, Tal Gilboa, Yamin Friedman, Saeed Mahameed, linux-netdev On 7/23/19 12:22 AM, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@mellanox.com> > > DIM causes to the following warnings during kernel compilation > which indicates that tx_profile and rx_profile are supposed to > be declared in *.c and not in *.h files. Thanks Leon for this fix. Reviewed-by: Bart Van Assche <bvanassche@acm.org> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings 2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky 2019-07-23 15:57 ` Bart Van Assche @ 2019-07-23 17:05 ` Saeed Mahameed 2019-07-23 18:01 ` Leon Romanovsky 1 sibling, 1 reply; 9+ messages in thread From: Saeed Mahameed @ 2019-07-23 17:05 UTC (permalink / raw) To: cai@lca.pw, davem@davemloft.net, leon@kernel.org Cc: Jason Gunthorpe, Yamin Friedman, linux-rdma@vger.kernel.org, Tal Gilboa, Leon Romanovsky, dledford@redhat.com, netdev@vger.kernel.org On Tue, 2019-07-23 at 10:22 +0300, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@mellanox.com> > > DIM causes to the following warnings during kernel compilation > which indicates that tx_profile and rx_profile are supposed to > be declared in *.c and not in *.h files. > > In file included from ./include/rdma/ib_verbs.h:64, > from ./include/linux/mlx5/device.h:37, > from ./include/linux/mlx5/driver.h:51, > from ./include/linux/mlx5/vport.h:36, > from drivers/infiniband/hw/mlx5/ib_virt.c:34: > ./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not > used [-Wunused-const-variable=] > 326 | > tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > | ^~~~~~~~~~ > ./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not > used [-Wunused-const-variable=] > 320 | > rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > | ^~~~~~~~~~ > > Fixes: 4f75da3666c0 ("linux/dim: Move implementation to .c files") > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> A similar patch was already submitted to linux-kernel ML, "[PATCH] linux/dim: fix -Wunused-const-variable warnings" I basically asked Qian to do the same as you did in this patch. Anyway i guess it is ok to drop that patch and keep this one. Acked-by: Saeed Mahameed <saeedm@mellanox.com> > --- > include/linux/dim.h | 56 ----------------------------------------- > ---- > lib/dim/net_dim.c | 56 > +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 56 insertions(+), 56 deletions(-) > > diff --git a/include/linux/dim.h b/include/linux/dim.h > index d3a0fbfff2bb..9fa4b3f88c39 100644 > --- a/include/linux/dim.h > +++ b/include/linux/dim.h > @@ -272,62 +272,6 @@ dim_update_sample_with_comps(u16 event_ctr, u64 > packets, u64 bytes, u64 comps, > > /* Net DIM */ > > -/* > - * Net DIM profiles: > - * There are different set of profiles for each CQ period > mode. > - * There are different set of profiles for RX/TX CQs. > - * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES > - */ > -#define NET_DIM_PARAMS_NUM_PROFILES 5 > -#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 > -#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 > -#define NET_DIM_DEF_PROFILE_CQE 1 > -#define NET_DIM_DEF_PROFILE_EQE 1 > - > -#define NET_DIM_RX_EQE_PROFILES { \ > - {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > -} > - > -#define NET_DIM_RX_CQE_PROFILES { \ > - {2, 256}, \ > - {8, 128}, \ > - {16, 64}, \ > - {32, 64}, \ > - {64, 64} \ > -} > - > -#define NET_DIM_TX_EQE_PROFILES { \ > - {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > - {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ > -} > - > -#define NET_DIM_TX_CQE_PROFILES { \ > - {5, 128}, \ > - {8, 64}, \ > - {16, 32}, \ > - {32, 32}, \ > - {64, 32} \ > -} > - > -static const struct dim_cq_moder > -rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > - NET_DIM_RX_EQE_PROFILES, > - NET_DIM_RX_CQE_PROFILES, > -}; > - > -static const struct dim_cq_moder > -tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > - NET_DIM_TX_EQE_PROFILES, > - NET_DIM_TX_CQE_PROFILES, > -}; > - > /** > * net_dim_get_rx_moderation - provide a CQ moderation object for > the given RX profile > * @cq_period_mode: CQ period mode > diff --git a/lib/dim/net_dim.c b/lib/dim/net_dim.c > index 5bcc902c5388..a4db51c21266 100644 > --- a/lib/dim/net_dim.c > +++ b/lib/dim/net_dim.c > @@ -5,6 +5,62 @@ > > #include <linux/dim.h> > > +/* > + * Net DIM profiles: > + * There are different set of profiles for each CQ period > mode. > + * There are different set of profiles for RX/TX CQs. > + * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES > + */ > +#define NET_DIM_PARAMS_NUM_PROFILES 5 > +#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 > +#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 > +#define NET_DIM_DEF_PROFILE_CQE 1 > +#define NET_DIM_DEF_PROFILE_EQE 1 > + > +#define NET_DIM_RX_EQE_PROFILES { \ > + {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > +} > + > +#define NET_DIM_RX_CQE_PROFILES { \ > + {2, 256}, \ > + {8, 128}, \ > + {16, 64}, \ > + {32, 64}, \ > + {64, 64} \ > +} > + > +#define NET_DIM_TX_EQE_PROFILES { \ > + {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > + {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ > +} > + > +#define NET_DIM_TX_CQE_PROFILES { \ > + {5, 128}, \ > + {8, 64}, \ > + {16, 32}, \ > + {32, 32}, \ > + {64, 32} \ > +} > + > +static const struct dim_cq_moder > +rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > + NET_DIM_RX_EQE_PROFILES, > + NET_DIM_RX_CQE_PROFILES, > +}; > + > +static const struct dim_cq_moder > +tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > + NET_DIM_TX_EQE_PROFILES, > + NET_DIM_TX_CQE_PROFILES, > +}; > + > struct dim_cq_moder > net_dim_get_rx_moderation(u8 cq_period_mode, int ix) > { > -- > 2.20.1 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings 2019-07-23 17:05 ` Saeed Mahameed @ 2019-07-23 18:01 ` Leon Romanovsky 0 siblings, 0 replies; 9+ messages in thread From: Leon Romanovsky @ 2019-07-23 18:01 UTC (permalink / raw) To: Saeed Mahameed Cc: cai@lca.pw, davem@davemloft.net, Jason Gunthorpe, Yamin Friedman, linux-rdma@vger.kernel.org, Tal Gilboa, dledford@redhat.com, netdev@vger.kernel.org On Tue, Jul 23, 2019 at 05:05:19PM +0000, Saeed Mahameed wrote: > On Tue, 2019-07-23 at 10:22 +0300, Leon Romanovsky wrote: > > From: Leon Romanovsky <leonro@mellanox.com> > > > > DIM causes to the following warnings during kernel compilation > > which indicates that tx_profile and rx_profile are supposed to > > be declared in *.c and not in *.h files. > > > > In file included from ./include/rdma/ib_verbs.h:64, > > from ./include/linux/mlx5/device.h:37, > > from ./include/linux/mlx5/driver.h:51, > > from ./include/linux/mlx5/vport.h:36, > > from drivers/infiniband/hw/mlx5/ib_virt.c:34: > > ./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not > > used [-Wunused-const-variable=] > > 326 | > > tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > | ^~~~~~~~~~ > > ./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not > > used [-Wunused-const-variable=] > > 320 | > > rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > | ^~~~~~~~~~ > > > > Fixes: 4f75da3666c0 ("linux/dim: Move implementation to .c files") > > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> > > A similar patch was already submitted to linux-kernel ML, > "[PATCH] linux/dim: fix -Wunused-const-variable warnings" Are you talking about this merged patch? If yes, it was incomplete. ommit bedc0fd0f9b517698193d644f914b33951856fd2 Author: Qian Cai <cai@lca.pw> Date: Thu Jul 11 09:55:56 2019 -0400 RDMA/core: Fix -Wunused-const-variable warnings > > I basically asked Qian to do the same as you did in this patch. > Anyway i guess it is ok to drop that patch and keep this one. > > Acked-by: Saeed Mahameed <saeedm@mellanox.com> > > > --- > > include/linux/dim.h | 56 ----------------------------------------- > > ---- > > lib/dim/net_dim.c | 56 > > +++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 56 insertions(+), 56 deletions(-) > > > > diff --git a/include/linux/dim.h b/include/linux/dim.h > > index d3a0fbfff2bb..9fa4b3f88c39 100644 > > --- a/include/linux/dim.h > > +++ b/include/linux/dim.h > > @@ -272,62 +272,6 @@ dim_update_sample_with_comps(u16 event_ctr, u64 > > packets, u64 bytes, u64 comps, > > > > /* Net DIM */ > > > > -/* > > - * Net DIM profiles: > > - * There are different set of profiles for each CQ period > > mode. > > - * There are different set of profiles for RX/TX CQs. > > - * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES > > - */ > > -#define NET_DIM_PARAMS_NUM_PROFILES 5 > > -#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 > > -#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 > > -#define NET_DIM_DEF_PROFILE_CQE 1 > > -#define NET_DIM_DEF_PROFILE_EQE 1 > > - > > -#define NET_DIM_RX_EQE_PROFILES { \ > > - {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > -} > > - > > -#define NET_DIM_RX_CQE_PROFILES { \ > > - {2, 256}, \ > > - {8, 128}, \ > > - {16, 64}, \ > > - {32, 64}, \ > > - {64, 64} \ > > -} > > - > > -#define NET_DIM_TX_EQE_PROFILES { \ > > - {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > - {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ > > -} > > - > > -#define NET_DIM_TX_CQE_PROFILES { \ > > - {5, 128}, \ > > - {8, 64}, \ > > - {16, 32}, \ > > - {32, 32}, \ > > - {64, 32} \ > > -} > > - > > -static const struct dim_cq_moder > > -rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > - NET_DIM_RX_EQE_PROFILES, > > - NET_DIM_RX_CQE_PROFILES, > > -}; > > - > > -static const struct dim_cq_moder > > -tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > - NET_DIM_TX_EQE_PROFILES, > > - NET_DIM_TX_CQE_PROFILES, > > -}; > > - > > /** > > * net_dim_get_rx_moderation - provide a CQ moderation object for > > the given RX profile > > * @cq_period_mode: CQ period mode > > diff --git a/lib/dim/net_dim.c b/lib/dim/net_dim.c > > index 5bcc902c5388..a4db51c21266 100644 > > --- a/lib/dim/net_dim.c > > +++ b/lib/dim/net_dim.c > > @@ -5,6 +5,62 @@ > > > > #include <linux/dim.h> > > > > +/* > > + * Net DIM profiles: > > + * There are different set of profiles for each CQ period > > mode. > > + * There are different set of profiles for RX/TX CQs. > > + * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES > > + */ > > +#define NET_DIM_PARAMS_NUM_PROFILES 5 > > +#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 > > +#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128 > > +#define NET_DIM_DEF_PROFILE_CQE 1 > > +#define NET_DIM_DEF_PROFILE_EQE 1 > > + > > +#define NET_DIM_RX_EQE_PROFILES { \ > > + {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > +} > > + > > +#define NET_DIM_RX_CQE_PROFILES { \ > > + {2, 256}, \ > > + {8, 128}, \ > > + {16, 64}, \ > > + {32, 64}, \ > > + {64, 64} \ > > +} > > + > > +#define NET_DIM_TX_EQE_PROFILES { \ > > + {1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \ > > + {128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \ > > +} > > + > > +#define NET_DIM_TX_CQE_PROFILES { \ > > + {5, 128}, \ > > + {8, 64}, \ > > + {16, 32}, \ > > + {32, 32}, \ > > + {64, 32} \ > > +} > > + > > +static const struct dim_cq_moder > > +rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > + NET_DIM_RX_EQE_PROFILES, > > + NET_DIM_RX_CQE_PROFILES, > > +}; > > + > > +static const struct dim_cq_moder > > +tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { > > + NET_DIM_TX_EQE_PROFILES, > > + NET_DIM_TX_CQE_PROFILES, > > +}; > > + > > struct dim_cq_moder > > net_dim_get_rx_moderation(u8 cq_period_mode, int ix) > > { > > -- > > 2.20.1 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 0/2] DIM fixes for 5.3 2019-07-23 7:22 [PATCH net 0/2] DIM fixes for 5.3 Leon Romanovsky 2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky 2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky @ 2019-07-25 18:34 ` David Miller 2 siblings, 0 replies; 9+ messages in thread From: David Miller @ 2019-07-25 18:34 UTC (permalink / raw) To: leon; +Cc: leonro, dledford, jgg, linux-rdma, talgi, yaminf, saeedm, netdev From: Leon Romanovsky <leon@kernel.org> Date: Tue, 23 Jul 2019 10:22:46 +0300 > Those two fixes for recently merged DIM patches, both exposed through > RDMa DIM usage. Series applied. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-07-25 18:34 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-07-23 7:22 [PATCH net 0/2] DIM fixes for 5.3 Leon Romanovsky 2019-07-23 7:22 ` [PATCH net 1/2] linux/dim: Fix overflow in dim calculation Leon Romanovsky 2019-07-23 17:22 ` Saeed Mahameed 2019-07-23 18:04 ` Leon Romanovsky 2019-07-23 7:22 ` [PATCH net 2/2] lib/dim: Fix -Wunused-const-variable warnings Leon Romanovsky 2019-07-23 15:57 ` Bart Van Assche 2019-07-23 17:05 ` Saeed Mahameed 2019-07-23 18:01 ` Leon Romanovsky 2019-07-25 18:34 ` [PATCH net 0/2] DIM fixes for 5.3 David Miller
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.