Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbbKIQHw (ORCPT ); Mon, 9 Nov 2015 11:07:52 -0500 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:43478 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751822AbbKIQHr (ORCPT ); Mon, 9 Nov 2015 11:07:47 -0500 Date: Mon, 9 Nov 2015 16:07:26 +0000 From: Russell King - ARM Linux To: Tetsuo Handa Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-acpi@vger.kernel.org, drbd-user@lists.linbit.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Oleg Drokin , Andreas Dilger , codalist@TELEMANN.coda.cs.cmu.edu, linux-mtd@lists.infradead.org, Jan Kara , linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree() Message-ID: <20151109160726.GB8644@n2100.arm.linux.org.uk> References: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2020 Lines: 66 On Mon, Nov 09, 2015 at 08:56:10PM +0900, Tetsuo Handa wrote: > There are many locations that do > > if (memory_was_allocated_by_vmalloc) > vfree(ptr); > else > kfree(ptr); > > but kvfree() can handle both kmalloc()ed memory and vmalloc()ed memory > using is_vmalloc_addr(). Unless callers have special reasons, we can > replace this branch with kvfree(). Please check and reply if you found > problems. > > Signed-off-by: Tetsuo Handa > Acked-by: Michal Hocko > Cc: Russell King # arm Acked-by: Russell King In so far as this ARM specific change looks reasonable. Thanks. > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c > index e62400e..492bf3e 100644 > --- a/arch/arm/mm/dma-mapping.c > +++ b/arch/arm/mm/dma-mapping.c > @@ -1200,10 +1200,7 @@ error: > while (i--) > if (pages[i]) > __free_pages(pages[i], 0); > - if (array_size <= PAGE_SIZE) > - kfree(pages); > - else > - vfree(pages); > + kvfree(pages); > return NULL; > } > > @@ -1211,7 +1208,6 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, > size_t size, struct dma_attrs *attrs) > { > int count = size >> PAGE_SHIFT; > - int array_size = count * sizeof(struct page *); > int i; > > if (dma_get_attr(DMA_ATTR_FORCE_CONTIGUOUS, attrs)) { > @@ -1222,10 +1218,7 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, > __free_pages(pages[i], 0); > } > > - if (array_size <= PAGE_SIZE) > - kfree(pages); > - else > - vfree(pages); > + kvfree(pages); > return 0; > } > -- FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/