From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D560FC33CB2 for ; Tue, 28 Jan 2020 11:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC8AC24686 for ; Tue, 28 Jan 2020 11:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580211894; bh=E7sSxi9rEy9lj8TVZnfhNZG9e0AVuStsXP4sldUxT4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=SRIWKzBvOY/s4QjVoGyGnyO5tekVsbsMveFeTc5G7iieIN9RhDUUH7KNZP6TYu8BU BFWpRLQHYPDaaEfKgJDPe3FJI592sMzrkLS8uZsQiOyUqb7iCvUpv6YwRiWG7wrBPj FA+E21ClJ9w2+shUhhrZSlHQsrLD/w5IwgeIoSqE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726143AbgA1Loy (ORCPT ); Tue, 28 Jan 2020 06:44:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:38778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgA1Lox (ORCPT ); Tue, 28 Jan 2020 06:44:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0283224684; Tue, 28 Jan 2020 11:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580211892; bh=E7sSxi9rEy9lj8TVZnfhNZG9e0AVuStsXP4sldUxT4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ijsPN1f6iteMPvBro/SwB7dEVl3seXEWeB2zfYTOVkE1nDJtOwJjS23a1CkDbQ3ZO A7wtuCSmPJO2W0fJ08rbudp+K20sw0w0JIFUMtWNGYg+1Xqzk/zZb45aRAwF0GIxgO KHKecvvnQLkBroKWsOysi+JR6xpIBT/6ApGqxrio= Date: Tue, 28 Jan 2020 12:44:50 +0100 From: Greg Kroah-Hartman To: Naresh Kamboju Cc: Sasha Levin , Andy Shevchenko , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , linux-raid@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Andrew Morton , Yury Norov , open list , mika.westerberg@linux.intel.com, Joe Perches , linux- stable , lkft-triage@lists.linaro.org Subject: Re: [PATCH v4 3/5] bitmap: Add bitmap_alloc(), bitmap_zalloc() and bitmap_free() Message-ID: <20200128114450.GA2672297@kroah.com> References: <20180630201750.2588-1-andriy.shevchenko@linux.intel.com> <20180630201750.2588-4-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 28, 2020 at 05:08:27PM +0530, Naresh Kamboju wrote: > On Sun, 1 Jul 2018 at 01:49, Andy Shevchenko > wrote: > > > > A lot of code become ugly because of open coding allocations for bitmaps. > > > > Introduce three helpers to allow users be more clear of intention > > and keep their code neat. > > > > Note, due to multiple circular dependencies we may not provide > > the helpers as inliners. For now we keep them exported and, perhaps, > > at some point in the future we will sort out header inclusion and > > inheritance. > > > > Signed-off-by: Andy Shevchenko > > --- > > include/linux/bitmap.h | 8 ++++++++ > > lib/bitmap.c | 19 +++++++++++++++++++ > > 2 files changed, 27 insertions(+) > > > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > > index 1ee46f492267..acf5e8df3504 100644 > > --- a/include/linux/bitmap.h > > +++ b/include/linux/bitmap.h > > @@ -104,6 +104,14 @@ > > * contain all bit positions from 0 to 'bits' - 1. > > */ > > > > +/* > > + * Allocation and deallocation of bitmap. > > + * Provided in lib/bitmap.c to avoid circular dependency. > > + */ > > +extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags); > > +extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); > > +extern void bitmap_free(const unsigned long *bitmap); > > + > > /* > > * lib/bitmap.c provides these functions: > > */ > > diff --git a/lib/bitmap.c b/lib/bitmap.c > > index 33e95cd359a2..09acf2fd6a35 100644 > > --- a/lib/bitmap.c > > +++ b/lib/bitmap.c > > @@ -13,6 +13,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -1125,6 +1126,24 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n > > EXPORT_SYMBOL(bitmap_copy_le); > > #endif > > > > +unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags) > > +{ > > + return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long), flags); > > +} > > +EXPORT_SYMBOL(bitmap_alloc); > > + > > +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags) > > +{ > > + return bitmap_alloc(nbits, flags | __GFP_ZERO); > > +} > > +EXPORT_SYMBOL(bitmap_zalloc); > > + > > +void bitmap_free(const unsigned long *bitmap) > > +{ > > + kfree(bitmap); > > +} > > +EXPORT_SYMBOL(bitmap_free); > > + > > #if BITS_PER_LONG == 64 > > /** > > * bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap > > stable-rc 4.14 build failed due to these build error, Yeah, sorry, I noticed this right before I had to leave for a few hours. I'll go fix this up now... greg k-h