linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers
@ 2018-07-09 13:51 Jan Dakinevich
  2018-07-16 16:19 ` Jan Dakinevich
  2018-07-23 21:38 ` Jason Gunthorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Dakinevich @ 2018-07-09 13:51 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe, Leon Romanovsky, Yuval Shaia,
	Alex Vesker, Erez Shitrit, Feras Daoud, Kees Cook,
	Evgenii Smirnov, linux-rdma, linux-kernel
  Cc: Denis Lunev, Konstantin Khorenko, Jan Dakinevich

This table by default takes 32KiB which is 3rd memory order. Meanwhile,
this memory is not aimed for DMA operation and could be safely allocated
by vmalloc.

Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
---
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 26cde95..cb752df 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
 		return -ENOMEM;
 	set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
 	size = roundup_pow_of_two(arp_tbl.gc_thresh3);
-	buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
+	buckets = kvcalloc(size, sizeof(*buckets), GFP_KERNEL);
 	if (!buckets) {
 		kfree(htbl);
 		return -ENOMEM;
@@ -1554,7 +1554,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
 	struct ipoib_neigh __rcu **buckets = htbl->buckets;
 	struct ipoib_neigh_table *ntbl = htbl->ntbl;
 
-	kfree(buckets);
+	kvfree(buckets);
 	kfree(htbl);
 	complete(&ntbl->deleted);
 }
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers
  2018-07-09 13:51 [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers Jan Dakinevich
@ 2018-07-16 16:19 ` Jan Dakinevich
  2018-07-16 18:18   ` Håkon Bugge
  2018-07-23 21:38 ` Jason Gunthorpe
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Dakinevich @ 2018-07-16 16:19 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe, Leon Romanovsky, Yuval Shaia,
	Alex Vesker, Erez Shitrit, Feras Daoud, Kees Cook,
	Evgenii Smirnov, linux-rdma, linux-kernel
  Cc: Denis Lunev, Konstantin Khorenko

On Mon,  9 Jul 2018 16:51:03 +0300
Jan Dakinevich <jan.dakinevich@virtuozzo.com> wrote:

> This table by default takes 32KiB which is 3rd memory order.
> Meanwhile, this memory is not aimed for DMA operation and could be
> safely allocated by vmalloc.
> 
> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
> ---
>  drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 26cde95..cb752df
> 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct
> ipoib_dev_priv *priv) return -ENOMEM;
>  	set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
>  	size = roundup_pow_of_two(arp_tbl.gc_thresh3);
> -	buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
> +	buckets = kvcalloc(size, sizeof(*buckets), GFP_KERNEL);
>  	if (!buckets) {
>  		kfree(htbl);
>  		return -ENOMEM;
> @@ -1554,7 +1554,7 @@ static void neigh_hash_free_rcu(struct rcu_head
> *head) struct ipoib_neigh __rcu **buckets = htbl->buckets;
>  	struct ipoib_neigh_table *ntbl = htbl->ntbl;
>  
> -	kfree(buckets);
> +	kvfree(buckets);
>  	kfree(htbl);
>  	complete(&ntbl->deleted);
>  }

ping

-- 
Best regards
Jan Dakinevich

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers
  2018-07-16 16:19 ` Jan Dakinevich
@ 2018-07-16 18:18   ` Håkon Bugge
  0 siblings, 0 replies; 4+ messages in thread
From: Håkon Bugge @ 2018-07-16 18:18 UTC (permalink / raw)
  To: Jan Dakinevich
  Cc: Doug Ledford, Jason Gunthorpe, Leon Romanovsky, Yuval Shaia,
	Alex Vesker, Erez Shitrit, Feras Daoud, Kees Cook,
	Evgenii Smirnov, OFED mailing list, linux-kernel, Denis Lunev,
	Konstantin Khorenko



> On 16 Jul 2018, at 18:19, Jan Dakinevich <jan.dakinevich@virtuozzo.com> wrote:
> 
> On Mon,  9 Jul 2018 16:51:03 +0300
> Jan Dakinevich <jan.dakinevich@virtuozzo.com> wrote:
> 
>> This table by default takes 32KiB which is 3rd memory order.

Only if PAGE_SIZE is 4KiB...

>> Meanwhile, this memory is not aimed for DMA operation and could be
>> safely allocated by vmalloc.
>> 
>> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>

lgtm,

Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>


Thxs, Håkon

>> ---
>> drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 26cde95..cb752df
>> 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> @@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct
>> ipoib_dev_priv *priv) return -ENOMEM;
>> 	set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
>> 	size = roundup_pow_of_two(arp_tbl.gc_thresh3);
>> -	buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
>> +	buckets = kvcalloc(size, sizeof(*buckets), GFP_KERNEL);
>> 	if (!buckets) {
>> 		kfree(htbl);
>> 		return -ENOMEM;
>> @@ -1554,7 +1554,7 @@ static void neigh_hash_free_rcu(struct rcu_head
>> *head) struct ipoib_neigh __rcu **buckets = htbl->buckets;
>> 	struct ipoib_neigh_table *ntbl = htbl->ntbl;
>> 
>> -	kfree(buckets);
>> +	kvfree(buckets);
>> 	kfree(htbl);
>> 	complete(&ntbl->deleted);
>> }
> 
> ping
> 
> -- 
> Best regards
> Jan Dakinevich
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers
  2018-07-09 13:51 [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers Jan Dakinevich
  2018-07-16 16:19 ` Jan Dakinevich
@ 2018-07-23 21:38 ` Jason Gunthorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2018-07-23 21:38 UTC (permalink / raw)
  To: Jan Dakinevich
  Cc: Doug Ledford, Leon Romanovsky, Yuval Shaia, Alex Vesker,
	Erez Shitrit, Feras Daoud, Kees Cook, Evgenii Smirnov,
	linux-rdma, linux-kernel, Denis Lunev, Konstantin Khorenko

On Mon, Jul 09, 2018 at 04:51:03PM +0300, Jan Dakinevich wrote:
> This table by default takes 32KiB which is 3rd memory order. Meanwhile,
> this memory is not aimed for DMA operation and could be safely allocated
> by vmalloc.
> 
> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
> Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
> ---
>  drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-23 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-09 13:51 [PATCH] IPoIB: use kvzalloc to allocate an array of bucket pointers Jan Dakinevich
2018-07-16 16:19 ` Jan Dakinevich
2018-07-16 18:18   ` Håkon Bugge
2018-07-23 21:38 ` Jason Gunthorpe

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).