linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lars Ellenberg <lars.ellenberg@linbit.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	drbd-user@lists.linbit.com
Subject: Re: [DRBD-user] [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()
Date: Tue, 10 Nov 2015 14:34:00 +0100	[thread overview]
Message-ID: <20151110133400.GZ14472@soda.linbit> (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.

For the DRBD part:

>  drivers/block/drbd/drbd_bitmap.c                   | 26 +++++------------
>  drivers/block/drbd/drbd_int.h                      |  3 --

> diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
> index 9462d27..2daaafb 100644
> --- a/drivers/block/drbd/drbd_bitmap.c
> +++ b/drivers/block/drbd/drbd_bitmap.c
> @@ -364,12 +364,9 @@ static void bm_free_pages(struct page **pages, unsigned long number)
>  	}
>  }
>  
> -static void bm_vk_free(void *ptr, int v)
> +static inline void bm_vk_free(void *ptr)

Maybe drop this inline completely ...

>  {
> -	if (v)
> -		vfree(ptr);
> -	else
> -		kfree(ptr);
> +	kvfree(ptr);
>  }

... and just call kvfree() directly below?

> -				bm_vk_free(new_pages, vmalloced);
> +				bm_vk_free(new_pages);

  +				kvfree(new_pages);
  ...


Other than that: looks good and harmless enough.
Thanks,

	Lars

--
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-10 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 11:56 Tetsuo Handa
2015-11-09 12:11 ` Jan Kara
2015-11-09 16:26   ` David Miller
2015-11-09 16:07 ` Russell King - ARM Linux
2015-11-09 20:41 ` Dilger, Andreas
2015-11-09 21:48 ` Rafael J. Wysocki
2015-11-09 23:25   ` Luck, Tony
2015-11-10 13:34 ` Lars Ellenberg [this message]
2015-11-19  0:23 ` David Rientjes

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=20151110133400.GZ14472@soda.linbit \
    --to=lars.ellenberg@linbit.com \
    --cc=drbd-user@lists.linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox