From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966318AbcHBNQ3 (ORCPT ); Tue, 2 Aug 2016 09:16:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966156AbcHBNNk (ORCPT ); Tue, 2 Aug 2016 09:13:40 -0400 Date: Tue, 2 Aug 2016 15:03:29 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: David Ahern , Jiri Olsa , lkml , Ingo Molnar , Namhyung Kim , Peter Zijlstra Subject: Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function Message-ID: <20160802130329.GA16778@krava> References: <1470074555-24889-1-git-send-email-jolsa@kernel.org> <1470074555-24889-2-git-send-email-jolsa@kernel.org> <9701ea8b-b7d2-3110-f177-1ece7c0cb7b7@gmail.com> <20160802093359.GC2036@krava> <20160802113302.GA7479@krava> <20160802125616.GC26514@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160802125616.GC26514@kernel.org> User-Agent: Mutt/1.6.2 (2016-07-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 02 Aug 2016 13:03:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 02, 2016 at 09:56:16AM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Aug 02, 2016 at 01:33:02PM +0200, Jiri Olsa escreveu: > > --- > > Adding bitmap_alloc function to dynamically allocate bitmap. > > Why should we deviate from the kernel way of doing things, where, AFAIK, > there is no such bitmap_alloc() function? well, because I need it dynamically allocated and calling bitmap_alloc(nbits) seems more reasonable to me than calling the calloc below jirka > > [acme@jouet linux]$ find . -type f | xargs grep -w bitmap_alloc > [acme@jouet linux]$ > > - Arnaldo > > > Link: http://lkml.kernel.org/n/tip-ictn3ke5ewrzwyn8webfeai9@git.kernel.org > > Signed-off-by: Jiri Olsa > > --- > > tools/include/linux/bitmap.h | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h > > index 28f5493da491..60c44b615902 100644 > > --- a/tools/include/linux/bitmap.h > > +++ b/tools/include/linux/bitmap.h > > @@ -3,6 +3,7 @@ > > > > #include > > #include > > +#include > > > > #define DECLARE_BITMAP(name,bits) \ > > unsigned long name[BITS_TO_LONGS(bits)] > > @@ -65,4 +66,13 @@ static inline int test_and_set_bit(int nr, unsigned long *addr) > > return (old & mask) != 0; > > } > > > > +/** > > + * bitmap_alloc - Allocate bitmap > > + * @nr: Bit to set > > + */ > > +static inline unsigned long *bitmap_alloc(int nbits) > > +{ > > + return calloc(1, BITS_TO_LONGS(nbits) * sizeof(unsigned long)); > > +} > > + > > #endif /* _PERF_BITOPS_H */ > > -- > > 2.4.11