linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
@ 2018-07-09 13:51 Jan Dakinevich
  2018-07-09 20:56 ` Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jan Dakinevich @ 2018-07-09 13:51 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe, Bart Van Assche, linux-rdma, linux-kernel
  Cc: Denis Lunev, Konstantin Khorenko, Jan Dakinevich

An array of pointers to SRPT contexts in ib_device is over 30KiB even
in default case, in which an amount of contexts is 4095. The patch
is intended to weed out large contigous allocation for non-DMA memory.

Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 3081c62..de167af 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
 	WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
 		&& ioctx_size != sizeof(struct srpt_send_ioctx));
 
-	ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
+	ring = kvmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
 	if (!ring)
 		goto out;
 	for (i = 0; i < ring_size; ++i) {
@@ -734,7 +734,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
 err:
 	while (--i >= 0)
 		srpt_free_ioctx(sdev, ring[i], dma_size, dir);
-	kfree(ring);
+	kvfree(ring);
 	ring = NULL;
 out:
 	return ring;
@@ -759,7 +759,7 @@ static void srpt_free_ioctx_ring(struct srpt_ioctx **ioctx_ring,
 
 	for (i = 0; i < ring_size; ++i)
 		srpt_free_ioctx(sdev, ioctx_ring[i], dma_size, dir);
-	kfree(ioctx_ring);
+	kvfree(ioctx_ring);
 }
 
 /**
-- 
2.1.4


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

* Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
  2018-07-09 13:51 [PATCH] ib_srpt: use kvmalloc to allocate ring pointers Jan Dakinevich
@ 2018-07-09 20:56 ` Bart Van Assche
  2018-07-09 22:16 ` Jason Gunthorpe
  2018-07-10  5:39 ` Leon Romanovsky
  2 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2018-07-09 20:56 UTC (permalink / raw)
  To: linux-kernel, jgg, linux-rdma, jan.dakinevich, dledford; +Cc: khorenko, den

On Mon, 2018-07-09 at 16:51 +0300, Jan Dakinevich wrote:
> An array of pointers to SRPT contexts in ib_device is over 30KiB even
> in default case, in which an amount of contexts is 4095. The patch
> is intended to weed out large contigous allocation for non-DMA memory.

Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>





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

* Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
  2018-07-09 13:51 [PATCH] ib_srpt: use kvmalloc to allocate ring pointers Jan Dakinevich
  2018-07-09 20:56 ` Bart Van Assche
@ 2018-07-09 22:16 ` Jason Gunthorpe
  2018-07-10  5:39 ` Leon Romanovsky
  2 siblings, 0 replies; 6+ messages in thread
From: Jason Gunthorpe @ 2018-07-09 22:16 UTC (permalink / raw)
  To: Jan Dakinevich
  Cc: Doug Ledford, Bart Van Assche, linux-rdma, linux-kernel,
	Denis Lunev, Konstantin Khorenko

On Mon, Jul 09, 2018 at 04:51:08PM +0300, Jan Dakinevich wrote:
> An array of pointers to SRPT contexts in ib_device is over 30KiB even
> in default case, in which an amount of contexts is 4095. The patch
> is intended to weed out large contigous allocation for non-DMA memory.
> 
> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Applied to for-next

Thanks,
Jason

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

* Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
  2018-07-09 13:51 [PATCH] ib_srpt: use kvmalloc to allocate ring pointers Jan Dakinevich
  2018-07-09 20:56 ` Bart Van Assche
  2018-07-09 22:16 ` Jason Gunthorpe
@ 2018-07-10  5:39 ` Leon Romanovsky
  2018-07-10 15:08   ` Bart Van Assche
  2 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2018-07-10  5:39 UTC (permalink / raw)
  To: Jan Dakinevich
  Cc: Doug Ledford, Jason Gunthorpe, Bart Van Assche, linux-rdma,
	linux-kernel, Denis Lunev, Konstantin Khorenko

[-- Attachment #1: Type: text/plain, Size: 1968 bytes --]

On Mon, Jul 09, 2018 at 04:51:08PM +0300, Jan Dakinevich wrote:
> An array of pointers to SRPT contexts in ib_device is over 30KiB even
> in default case, in which an amount of contexts is 4095. The patch
> is intended to weed out large contigous allocation for non-DMA memory.

kvmalloc* doesn't "weed out" large contiguous allocations, but tries to
allocate them and gracefully fallback to vmalloc if kmalloc fails.

More on that, for allocations less than page (64KB for PowerPC), it will
not call to vmalloc at all, which is fine too, because pages granularity.

If you want to get rid of "contiguous allocations", use vmalloc instead.

Thanks

>
> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 3081c62..de167af 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
>  	WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
>  		&& ioctx_size != sizeof(struct srpt_send_ioctx));
>
> -	ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
> +	ring = kvmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
>  	if (!ring)
>  		goto out;
>  	for (i = 0; i < ring_size; ++i) {
> @@ -734,7 +734,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
>  err:
>  	while (--i >= 0)
>  		srpt_free_ioctx(sdev, ring[i], dma_size, dir);
> -	kfree(ring);
> +	kvfree(ring);
>  	ring = NULL;
>  out:
>  	return ring;
> @@ -759,7 +759,7 @@ static void srpt_free_ioctx_ring(struct srpt_ioctx **ioctx_ring,
>
>  	for (i = 0; i < ring_size; ++i)
>  		srpt_free_ioctx(sdev, ioctx_ring[i], dma_size, dir);
> -	kfree(ioctx_ring);
> +	kvfree(ioctx_ring);
>  }
>
>  /**
> --
> 2.1.4
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
  2018-07-10  5:39 ` Leon Romanovsky
@ 2018-07-10 15:08   ` Bart Van Assche
  2018-07-10 15:53     ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-07-10 15:08 UTC (permalink / raw)
  To: leon, jan.dakinevich
  Cc: linux-kernel, den, jgg, linux-rdma, dledford, khorenko

On Tue, 2018-07-10 at 08:39 +0300, Leon Romanovsky wrote:
> On Mon, Jul 09, 2018 at 04:51:08PM +0300, Jan Dakinevich wrote:
> > An array of pointers to SRPT contexts in ib_device is over 30KiB even
> > in default case, in which an amount of contexts is 4095. The patch
> > is intended to weed out large contigous allocation for non-DMA memory.
> 
> kvmalloc* doesn't "weed out" large contiguous allocations, but tries to
> allocate them and gracefully fallback to vmalloc if kmalloc fails.
> 
> More on that, for allocations less than page (64KB for PowerPC), it will
> not call to vmalloc at all, which is fine too, because pages granularity.
> 
> If you want to get rid of "contiguous allocations", use vmalloc instead.

vmalloc() has a very significant disadvantage compared to kvmalloc(): with
vmalloc() it is guaranteed that memory allocations will be slow. That's not
the case for kvmalloc() if the number of bytes that is allocated is small
enough.

Bart.





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

* Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers
  2018-07-10 15:08   ` Bart Van Assche
@ 2018-07-10 15:53     ` Leon Romanovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2018-07-10 15:53 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: jan.dakinevich, linux-kernel, den, jgg, linux-rdma, dledford, khorenko

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

On Tue, Jul 10, 2018 at 03:08:38PM +0000, Bart Van Assche wrote:
> On Tue, 2018-07-10 at 08:39 +0300, Leon Romanovsky wrote:
> > On Mon, Jul 09, 2018 at 04:51:08PM +0300, Jan Dakinevich wrote:
> > > An array of pointers to SRPT contexts in ib_device is over 30KiB even
> > > in default case, in which an amount of contexts is 4095. The patch
> > > is intended to weed out large contigous allocation for non-DMA memory.
> >
> > kvmalloc* doesn't "weed out" large contiguous allocations, but tries to
> > allocate them and gracefully fallback to vmalloc if kmalloc fails.
> >
> > More on that, for allocations less than page (64KB for PowerPC), it will
> > not call to vmalloc at all, which is fine too, because pages granularity.
> >
> > If you want to get rid of "contiguous allocations", use vmalloc instead.
>
> vmalloc() has a very significant disadvantage compared to kvmalloc(): with
> vmalloc() it is guaranteed that memory allocations will be slow. That's not
> the case for kvmalloc() if the number of bytes that is allocated is small
> enough.

Bart,

I'm not arguing, just pointing that the commit message doesn't reflect
actual change.

Thanks

>
> Bart.
>
>
>
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2018-07-10 15:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-09 13:51 [PATCH] ib_srpt: use kvmalloc to allocate ring pointers Jan Dakinevich
2018-07-09 20:56 ` Bart Van Assche
2018-07-09 22:16 ` Jason Gunthorpe
2018-07-10  5:39 ` Leon Romanovsky
2018-07-10 15:08   ` Bart Van Assche
2018-07-10 15:53     ` Leon Romanovsky

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