Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbbKJNjY (ORCPT ); Tue, 10 Nov 2015 08:39:24 -0500 Received: from zimbra13.linbit.com ([212.69.166.240]:53871 "EHLO zimbra13.linbit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113AbbKJNjW (ORCPT ); Tue, 10 Nov 2015 08:39:22 -0500 X-Greylist: delayed 318 seconds by postgrey-1.27 at vger.kernel.org; Tue, 10 Nov 2015 08:39:22 EST Date: Tue, 10 Nov 2015 14:34:00 +0100 From: Lars Ellenberg To: Tetsuo Handa 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() Message-ID: <20151110133400.GZ14472@soda.linbit> Mail-Followup-To: Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, drbd-user@lists.linbit.com 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.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1553 Lines: 58 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 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/