* [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors @ 2017-05-12 6:10 Yuval Shaia [not found] ` <1494569451-2567-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Yuval Shaia @ 2017-05-12 6:10 UTC (permalink / raw) To: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> --- v0 -> v1: * s/"min_t("/"min_t(int" v1 -> v2: * Use min3 instead of min_t twice v2 -> v3: * Change commit log header message to reflect the changes made in v2 v3 -> v4: * Cast return value from num_online_cpus to int to avoid compilation errors from "sparse" --- drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 7032054..83aab1e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -2862,12 +2862,10 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) int port = 0; if (msi_x) { - int nreq = dev->caps.num_ports * num_online_cpus() + 1; - - nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, - nreq); - if (nreq > MAX_MSIX) - nreq = MAX_MSIX; + int nreq = min3(dev->caps.num_ports * + (int)num_online_cpus() + 1, + dev->caps.num_eqs - dev->caps.reserved_eqs, + MAX_MSIX); entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); if (!entries) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1494569451-2567-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors [not found] ` <1494569451-2567-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2017-05-14 19:01 ` Yuval Shaia 2017-05-15 4:43 ` Leon Romanovsky 2017-05-15 18:20 ` David Miller 1 sibling, 1 reply; 6+ messages in thread From: Yuval Shaia @ 2017-05-14 19:01 UTC (permalink / raw) To: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA, leonro-VPRAkNaXOzVWk0Htik3J/w On Fri, May 12, 2017 at 09:10:51AM +0300, Yuval Shaia wrote: > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > --- > v0 -> v1: > * s/"min_t("/"min_t(int" > v1 -> v2: > * Use min3 instead of min_t twice > v2 -> v3: > * Change commit log header message to reflect the changes made in > v2 > v3 -> v4: > * Cast return value from num_online_cpus to int to avoid > compilation errors from "sparse" Hi Leon, Got your r-b for v3, can you please review v4? Thanks, > --- > drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c > index 7032054..83aab1e 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/main.c > +++ b/drivers/net/ethernet/mellanox/mlx4/main.c > @@ -2862,12 +2862,10 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) > int port = 0; > > if (msi_x) { > - int nreq = dev->caps.num_ports * num_online_cpus() + 1; > - > - nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, > - nreq); > - if (nreq > MAX_MSIX) > - nreq = MAX_MSIX; > + int nreq = min3(dev->caps.num_ports * > + (int)num_online_cpus() + 1, > + dev->caps.num_eqs - dev->caps.reserved_eqs, > + MAX_MSIX); > > entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); > if (!entries) > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors 2017-05-14 19:01 ` Yuval Shaia @ 2017-05-15 4:43 ` Leon Romanovsky [not found] ` <20170515044304.GV3616-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Leon Romanovsky @ 2017-05-15 4:43 UTC (permalink / raw) To: Yuval Shaia Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 2584 bytes --] On Sun, May 14, 2017 at 10:01:34PM +0300, Yuval Shaia wrote: > On Fri, May 12, 2017 at 09:10:51AM +0300, Yuval Shaia wrote: > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > > --- > > v0 -> v1: > > * s/"min_t("/"min_t(int" > > v1 -> v2: > > * Use min3 instead of min_t twice > > v2 -> v3: > > * Change commit log header message to reflect the changes made in > > v2 > > v3 -> v4: > > * Cast return value from num_online_cpus to int to avoid > > compilation errors from "sparse" > > Hi Leon, > Got your r-b for v3, can you please review v4? What was the sparse error? num_online_cpus() is declared as "unsigned int", so you don't need to do casting. ➜ linux-rdma git:(master) git grep num_online_cpus include/ include/linux/cpumask.h:#define num_online_cpus() cpumask_weight(cpu_online_mask) include/linux/cpumask.h:#define num_online_cpus() 1U ➜ linux-rdma git:(master) git grep cpumask_weight include/ include/linux/cpumask.h:static inline unsigned int cpumask_weight(const struct cpumask *srcp) Thanks > > Thanks, > > > --- > > drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++++------ > > 1 file changed, 4 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c > > index 7032054..83aab1e 100644 > > --- a/drivers/net/ethernet/mellanox/mlx4/main.c > > +++ b/drivers/net/ethernet/mellanox/mlx4/main.c > > @@ -2862,12 +2862,10 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) > > int port = 0; > > > > if (msi_x) { > > - int nreq = dev->caps.num_ports * num_online_cpus() + 1; > > - > > - nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, > > - nreq); > > - if (nreq > MAX_MSIX) > > - nreq = MAX_MSIX; > > + int nreq = min3(dev->caps.num_ports * > > + (int)num_online_cpus() + 1, > > + dev->caps.num_eqs - dev->caps.reserved_eqs, > > + MAX_MSIX); > > > > entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); > > if (!entries) > > -- > > 2.7.4 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20170515044304.GV3616-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>]
* Re: [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors [not found] ` <20170515044304.GV3616-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org> @ 2017-05-15 7:53 ` Yuval Shaia 2017-05-15 8:12 ` Leon Romanovsky 0 siblings, 1 reply; 6+ messages in thread From: Yuval Shaia @ 2017-05-15 7:53 UTC (permalink / raw) To: Leon Romanovsky Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA On Mon, May 15, 2017 at 07:43:04AM +0300, Leon Romanovsky wrote: > On Sun, May 14, 2017 at 10:01:34PM +0300, Yuval Shaia wrote: > > On Fri, May 12, 2017 at 09:10:51AM +0300, Yuval Shaia wrote: > > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > > > --- > > > v0 -> v1: > > > * s/"min_t("/"min_t(int" > > > v1 -> v2: > > > * Use min3 instead of min_t twice > > > v2 -> v3: > > > * Change commit log header message to reflect the changes made in > > > v2 > > > v3 -> v4: > > > * Cast return value from num_online_cpus to int to avoid > > > compilation errors from "sparse" > > > > Hi Leon, > > Got your r-b for v3, can you please review v4? > > What was the sparse error? > > num_online_cpus() is declared as "unsigned int", so you don't need to do casting. > > ➜ linux-rdma git:(master) git grep num_online_cpus include/ > include/linux/cpumask.h:#define num_online_cpus() cpumask_weight(cpu_online_mask) > include/linux/cpumask.h:#define num_online_cpus() 1U > > ➜ linux-rdma git:(master) git grep cpumask_weight include/ > include/linux/cpumask.h:static inline unsigned int cpumask_weight(const struct cpumask *srcp) But num_eqs and reserved_eqs are ints so assuming the error is that i asked min3 to compare unsigned int with int. This casting cannot do harm because anyway the result is stored in int variable. > > Thanks > > > > > Thanks, > > > > > --- > > > drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++++------ > > > 1 file changed, 4 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c > > > index 7032054..83aab1e 100644 > > > --- a/drivers/net/ethernet/mellanox/mlx4/main.c > > > +++ b/drivers/net/ethernet/mellanox/mlx4/main.c > > > @@ -2862,12 +2862,10 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) > > > int port = 0; > > > > > > if (msi_x) { > > > - int nreq = dev->caps.num_ports * num_online_cpus() + 1; > > > - > > > - nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, > > > - nreq); > > > - if (nreq > MAX_MSIX) > > > - nreq = MAX_MSIX; > > > + int nreq = min3(dev->caps.num_ports * > > > + (int)num_online_cpus() + 1, > > > + dev->caps.num_eqs - dev->caps.reserved_eqs, > > > + MAX_MSIX); > > > > > > entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); > > > if (!entries) > > > -- > > > 2.7.4 > > > > > > -- > > > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > > > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors 2017-05-15 7:53 ` Yuval Shaia @ 2017-05-15 8:12 ` Leon Romanovsky 0 siblings, 0 replies; 6+ messages in thread From: Leon Romanovsky @ 2017-05-15 8:12 UTC (permalink / raw) To: Yuval Shaia Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1636 bytes --] On Mon, May 15, 2017 at 10:53:24AM +0300, Yuval Shaia wrote: > On Mon, May 15, 2017 at 07:43:04AM +0300, Leon Romanovsky wrote: > > On Sun, May 14, 2017 at 10:01:34PM +0300, Yuval Shaia wrote: > > > On Fri, May 12, 2017 at 09:10:51AM +0300, Yuval Shaia wrote: > > > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > > > > --- > > > > v0 -> v1: > > > > * s/"min_t("/"min_t(int" > > > > v1 -> v2: > > > > * Use min3 instead of min_t twice > > > > v2 -> v3: > > > > * Change commit log header message to reflect the changes made in > > > > v2 > > > > v3 -> v4: > > > > * Cast return value from num_online_cpus to int to avoid > > > > compilation errors from "sparse" > > > > > > Hi Leon, > > > Got your r-b for v3, can you please review v4? > > > > What was the sparse error? > > > > num_online_cpus() is declared as "unsigned int", so you don't need to do casting. > > > > ➜ linux-rdma git:(master) git grep num_online_cpus include/ > > include/linux/cpumask.h:#define num_online_cpus() cpumask_weight(cpu_online_mask) > > include/linux/cpumask.h:#define num_online_cpus() 1U > > > > ➜ linux-rdma git:(master) git grep cpumask_weight include/ > > include/linux/cpumask.h:static inline unsigned int cpumask_weight(const struct cpumask *srcp) > > But num_eqs and reserved_eqs are ints so assuming the error is that i > asked min3 to compare unsigned int with int. > > This casting cannot do harm because anyway the result is stored in int > variable. Thanks, Reviewed-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors [not found] ` <1494569451-2567-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 2017-05-14 19:01 ` Yuval Shaia @ 2017-05-15 18:20 ` David Miller 1 sibling, 0 replies; 6+ messages in thread From: David Miller @ 2017-05-15 18:20 UTC (permalink / raw) To: yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA From: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> Date: Fri, 12 May 2017 09:10:51 +0300 > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > --- > v0 -> v1: > * s/"min_t("/"min_t(int" > v1 -> v2: > * Use min3 instead of min_t twice > v2 -> v3: > * Change commit log header message to reflect the changes made in > v2 > v3 -> v4: > * Cast return value from num_online_cpus to int to avoid > compilation errors from "sparse" Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-15 18:20 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-12 6:10 [PATCH v4] net/mlx4_core: Use min3 to select number of MSI-X vectors Yuval Shaia [not found] ` <1494569451-2567-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 2017-05-14 19:01 ` Yuval Shaia 2017-05-15 4:43 ` Leon Romanovsky [not found] ` <20170515044304.GV3616-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org> 2017-05-15 7:53 ` Yuval Shaia 2017-05-15 8:12 ` Leon Romanovsky 2017-05-15 18:20 ` David Miller
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).