Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2514868rwb; Fri, 20 Jan 2023 04:04:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXtZvP5iKp+6pOnrjUfZZ/wCjkXS9ZsQRte3hmaLHDyW2RlqXR7mUfqEsAcnIBKQObg9DB+A X-Received: by 2002:a05:6a21:2d88:b0:b8:7b63:252a with SMTP id ty8-20020a056a212d8800b000b87b63252amr12968388pzb.51.1674216298086; Fri, 20 Jan 2023 04:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674216298; cv=none; d=google.com; s=arc-20160816; b=XKcqcY+3zs/d9L+cGMI7QVzyVJeppGuiOSJ6L7P1I9BGkkLM7uJXOkjeghMLIEJq4h QYMeVyOB2oaAxqsVThgbQYx/PqcK3BD24Rznt+zYPaRD8SCj5b3zw2zrcY/CRcSTNYiA KEb/qwPkTjDtPd12MVIXApt7PZ+zpLyIk6ubP2NOh82LHOV26AvsdiFjcL4ieafUMbN7 bGEYoxvqYUPxnxxyBh+o9BIukKiVQtpId1uCt8RK5XklGHqIx4J8bSfSO5MkoaFQqced gQQEqog3NMD/OI25U2jWY6C5yYy00arkwmUofuAz5YmsNaEAeKK3LirvqWzMiShEUm/h StIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=a8tbkTV99JIoFlOtzhiBa2Q7p3lLxoFHrJNa//Ho6XQ=; b=kFHfxdZK5anYfcC+zkqSA+yWZnCttZiDQut08zGYR1J8xSGJu4eAdgRsLcZsYNJYOS zaLJIMsyytd6jlNPZKN1+QPZbUanqvIDO1X0dzuxeIjyrGiQa3yp/1F/9BRL4uEY7gaJ o+XPnXtdhJEf2kWOCDP/zzXhHr9FAss/7uIerFK3fPRNFkBUjhEgBWHogizti07RK7/6 vsu+De6WOOrCYsQ3/j/EuwD/IWH2ZS0p3iJVQnlJ+EHlFQzVK6CM2xBwckyey7KCOJFw 8rfY2/ReDy0CKNl/jXMVw/2NCLIwX++xoMs/RZkGmX/J33rGSutyG6GPU/6ZUUrJStc0 dHuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=NgAvIueQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g71-20020a636b4a000000b004791c673bdcsi40172551pgc.347.2023.01.20.04.04.51; Fri, 20 Jan 2023 04:04:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=NgAvIueQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbjATLbB (ORCPT + 49 others); Fri, 20 Jan 2023 06:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjATLbA (ORCPT ); Fri, 20 Jan 2023 06:31:00 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2500BE1 for ; Fri, 20 Jan 2023 03:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1674214238; bh=vKZok24P16vtSzwa8cCtF5cwkVtZXRDsJICRswyzSEM=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=NgAvIueQaxWFi/eEfvZQuLX8AZpeY9VQ/kGdATpHrW3OR5BzAkvm91FvATt3/UhpQ v5szt3goD8/XlLdajCiAzEhR9fdJAOUkDbvfna+N+QGfmYNRvolYECg1Fe7OmkSKt6 H5+rQA0bXaqB12xDDexVP6Q1dn50Z3uacOpgNJUU= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Fri, 20 Jan 2023 12:30:38 +0100 (CET) X-EA-Auth: mPqKcBxI+Kz+wstkcVCPLOHOVKFYAuzXNKF5aMqU4/cGleBLphnibBQkRkssECZNdsYyGkpsyzZnJFzrKw4QA7JMtwYm99Ai Date: Fri, 20 Jan 2023 17:00:34 +0530 From: Deepak R Varma To: Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar Subject: Re: [PATCH] ARM/dma-mapping: use kvzalloc for fallback memory allocation need Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >