All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Andreas Dilger <andreas.dilger@intel.com>,
	linux-acpi@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	codalist@coda.cs.cmu.edu, Oleg Drokin <oleg.drokin@intel.com>,
	linux-mm@kvack.org, linux-mtd@lists.infradead.org,
	Jan Kara <jack@suse.com>,
	linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org,
	drbd-user@lists.linbit.com
Subject: Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()
Date: Mon, 9 Nov 2015 16:07:26 +0000	[thread overview]
Message-ID: <20151109160726.GB8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

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 <penguin-kernel@I-love.SAKURA.ne.jp>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Cc: Russell King <linux@arm.linux.org.uk> # arm

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

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.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
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 <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	codalist@TELEMANN.coda.cs.cmu.edu, linux-mtd@lists.infradead.org,
	Jan Kara <jack@suse.com>,
	linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()
Date: Mon, 9 Nov 2015 16:07:26 +0000	[thread overview]
Message-ID: <20151109160726.GB8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

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 <penguin-kernel@I-love.SAKURA.ne.jp>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Cc: Russell King <linux@arm.linux.org.uk> # arm

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

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.

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
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 <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	codalist@coda.cs.cmu.edu, linux-mtd@lists.infradead.org,
	Jan Kara <jack@suse.com>,
	linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()
Date: Mon, 9 Nov 2015 16:07:26 +0000	[thread overview]
Message-ID: <20151109160726.GB8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

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 <penguin-kernel@I-love.SAKURA.ne.jp>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Cc: Russell King <linux@arm.linux.org.uk> # arm

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

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.

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
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 <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	codalist@coda.cs.cmu.edu, linux-mtd@lists.infradead.org,
	Jan Kara <jack@suse.com>,
	linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()
Date: Mon, 9 Nov 2015 16:07:26 +0000	[thread overview]
Message-ID: <20151109160726.GB8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

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 <penguin-kernel@I-love.SAKURA.ne.jp>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Cc: Russell King <linux@arm.linux.org.uk> # arm

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2015-11-09 16:07 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 11:56 [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree() Tetsuo Handa
2015-11-09 11:56 ` Tetsuo Handa
2015-11-09 11:56 ` Tetsuo Handa
2015-11-09 11:56 ` Tetsuo Handa
2015-11-09 12:11 ` Jan Kara
2015-11-09 12:11   ` Jan Kara
2015-11-09 12:11   ` Jan Kara
2015-11-09 16:26   ` David Miller
2015-11-09 16:26     ` David Miller
2015-11-09 16:26     ` David Miller
2015-11-09 16:07 ` Russell King - ARM Linux [this message]
2015-11-09 16:07   ` Russell King - ARM Linux
2015-11-09 16:07   ` Russell King - ARM Linux
2015-11-09 16:07   ` Russell King - ARM Linux
2015-11-09 20:41 ` Dilger, Andreas
2015-11-09 20:41   ` Dilger, Andreas
2015-11-09 20:41   ` Dilger, Andreas
2015-11-09 21:48 ` Rafael J. Wysocki
2015-11-09 21:48   ` Rafael J. Wysocki
2015-11-09 21:48   ` Rafael J. Wysocki
2015-11-09 23:25   ` Luck, Tony
2015-11-09 23:25     ` Luck, Tony
2015-11-10 13:34 ` [DRBD-user] " Lars Ellenberg
2015-11-10 13:34   ` Lars Ellenberg
2015-11-19  0:23 ` David Rientjes
2015-11-19  0:23   ` David Rientjes
2015-11-19  0:23   ` David Rientjes
  -- strict thread matches above, loose matches on Subject: below --
2015-11-07 11:44 Tetsuo Handa
2015-11-07 11:44 ` Tetsuo Handa
2015-11-07 18:12 ` Joe Perches
2015-11-07 18:12   ` Joe Perches
2015-11-07 20:05 ` Andy Shevchenko
2015-11-07 20:05   ` Andy Shevchenko
2015-11-07 20:13   ` Andy Shevchenko
2015-11-07 20:13     ` Andy Shevchenko
2015-11-08  5:04     ` Tetsuo Handa
2015-11-08  5:04       ` Tetsuo Handa
2015-11-08  5:30       ` Sergey Senozhatsky
2015-11-08  5:30         ` Sergey Senozhatsky
2015-11-08 20:11       ` Andy Shevchenko
2015-11-08 20:11         ` Andy Shevchenko
2015-11-09 10:48 ` Michal Hocko
2015-11-09 10:48   ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151109160726.GB8644@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=andreas.dilger@intel.com \
    --cc=codalist@coda.cs.cmu.edu \
    --cc=drbd-user@lists.linbit.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jack@suse.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.