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] [day] [month] [year] [list]
Date:   Fri, 20 Jan 2023 17:00:34 +0530
From:   Deepak R Varma <drv@...lo.com>
To:     Russell King <linux@...linux.org.uk>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     Saurabh Singh Sengar <ssengar@...rosoft.com>,
        Praveen Kumar <kumarpraveen@...ux.microsoft.com>
Subject: Re: [PATCH] ARM/dma-mapping: use kvzalloc for fallback memory
 allocation need

On Tue, Dec 20, 2022 at 10:55:11AM +0530, Deepak R Varma wrote:
> When the memory sizes are not known upfront, it is preferred to use the
> kvzalloc helper function instead of direct conditional evaluation of
> size and kzalloc/vzalloc fallback design. The kvzalloc helper function
> in this case is more efficient as it avoids indefinite kzalloc retries
> when a small memory size is needed but is unavailable.
> This LWN article has further details on the advantages of using
> kvzalloc in case of fallback memory allocation needs:
>  	https://lwn.net/Articles/711653/
> 
> This patch proposal is based on following Coccinelle warning using the
> kvmalloc.cocci semantic patch.
> 
> arch/arm/mm/dma-mapping.c:858:28-29: WARNING opportunity for kvmalloc
> 
> Signed-off-by: Deepak R Varma <drv@...lo.com>

Hello,
May I please request a review and feedback on this patch proposal?

Thank you,
./drv

> ---
> Note: The patch proposal is compile tested only.
> 
>  arch/arm/mm/dma-mapping.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index c135f6e37a00..2b79af377a81 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -855,10 +855,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
>  	int i = 0;
>  	int order_idx = 0;
> 
> -	if (array_size <= PAGE_SIZE)
> -		pages = kzalloc(array_size, GFP_KERNEL);
> -	else
> -		pages = vzalloc(array_size);
> +	pages = kvzalloc(array_size, GFP_KERNEL);
>  	if (!pages)
>  		return NULL;
> 
> --
> 2.34.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ