lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180710053944.GN3014@mtr-leonro.mtl.com>
Date:   Tue, 10 Jul 2018 08:39:44 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Jan Dakinevich <jan.dakinevich@...tuozzo.com>
Cc:     Doug Ledford <dledford@...hat.com>, Jason Gunthorpe <jgg@...pe.ca>,
        Bart Van Assche <bart.vanassche@....com>,
        linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
        Denis Lunev <den@...tuozzo.com>,
        Konstantin Khorenko <khorenko@...tuozzo.com>
Subject: Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers

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@...tuozzo.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
>

Download attachment "signature.asc" of type "application/pgp-signature" (802 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ