Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1453380 > unrolled thread

[PATCH 1/7] tools lib: Add bitmap_alloc function

Started byJiri Olsa <jolsa@kernel.org>
First post2016-08-01 20:20 +0200
Last post2016-08-04 11:20 +0200
Articles 7 — 5 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/7] tools lib: Add bitmap_alloc function Jiri Olsa <jolsa@kernel.org> - 2016-08-01 20:20 +0200
    Re: [PATCH 1/7] tools lib: Add bitmap_alloc function David Ahern <dsahern@gmail.com> - 2016-08-01 22:00 +0200
      Re: [PATCH 1/7] tools lib: Add bitmap_alloc function Jiri Olsa <jolsa@redhat.com> - 2016-08-02 11:40 +0200
        [PATCHv2 1/7] tools lib: Add bitmap_alloc function Jiri Olsa <jolsa@redhat.com> - 2016-08-02 13:50 +0200
          Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function Jiri Olsa <jolsa@redhat.com> - 2016-08-02 15:20 +0200
          Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-08-02 16:20 +0200
          [tip:perf/urgent] tools lib: Add bitmap_alloc function tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-08-04 11:20 +0200

#1453380 — [PATCH 1/7] tools lib: Add bitmap_alloc function

FromJiri Olsa <jolsa@kernel.org>
Date2016-08-01 20:20 +0200
Subject[PATCH 1/7] tools lib: Add bitmap_alloc function
Message-ID<s1pYK-1pc-9@gated-at.bofh.it>
Adding bitmap_alloc function to dynamically allocate bitmap.

Link: http://lkml.kernel.org/n/tip-ictn3ke5ewrzwyn8webfeai9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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..66ddd992e690 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -3,6 +3,7 @@
 
 #include <string.h>
 #include <linux/bitops.h>
+#include <stdlib.h>
 
 #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 malloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long));
+}
+
 #endif /* _PERF_BITOPS_H */
-- 
2.4.11

[toc] | [next] | [standalone]


#1453429

FromDavid Ahern <dsahern@gmail.com>
Date2016-08-01 22:00 +0200
Message-ID<s1rxv-2ia-1@gated-at.bofh.it>
In reply to#1453380
On 8/1/16 12:02 PM, Jiri Olsa wrote:
> @@ -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 malloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long));
> +}
> +
>  #endif /* _PERF_BITOPS_H */

calloc? Can't imagine any user wanting an uninitialized bitmap.

[toc] | [prev] | [next] | [standalone]


#1453703

FromJiri Olsa <jolsa@redhat.com>
Date2016-08-02 11:40 +0200
Message-ID<s1El3-2B6-13@gated-at.bofh.it>
In reply to#1453429
On Mon, Aug 01, 2016 at 12:45:18PM -0600, David Ahern wrote:
> On 8/1/16 12:02 PM, Jiri Olsa wrote:
> > @@ -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 malloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long));
> > +}
> > +
> >  #endif /* _PERF_BITOPS_H */
> 
> calloc? Can't imagine any user wanting an uninitialized bitmap.

hum, right.. all my code used bitmap_zero,
but zalloc would be better choice in here

thanks,
jirka

[toc] | [prev] | [next] | [standalone]


#1453913 — [PATCHv2 1/7] tools lib: Add bitmap_alloc function

FromJiri Olsa <jolsa@redhat.com>
Date2016-08-02 13:50 +0200
Subject[PATCHv2 1/7] tools lib: Add bitmap_alloc function
Message-ID<s1GmT-3Sw-79@gated-at.bofh.it>
In reply to#1453703
On Tue, Aug 02, 2016 at 11:33:59AM +0200, Jiri Olsa wrote:
> On Mon, Aug 01, 2016 at 12:45:18PM -0600, David Ahern wrote:
> > On 8/1/16 12:02 PM, Jiri Olsa wrote:
> > > @@ -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 malloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long));
> > > +}
> > > +
> > >  #endif /* _PERF_BITOPS_H */
> > 
> > calloc? Can't imagine any user wanting an uninitialized bitmap.
> 
> hum, right.. all my code used bitmap_zero,
> but zalloc would be better choice in here

v2 attached, thanks

jirka


---
Adding bitmap_alloc function to dynamically allocate bitmap.

Link: http://lkml.kernel.org/n/tip-ictn3ke5ewrzwyn8webfeai9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 <string.h>
 #include <linux/bitops.h>
+#include <stdlib.h>
 
 #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

[toc] | [prev] | [next] | [standalone]


#1454329 — Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function

FromJiri Olsa <jolsa@redhat.com>
Date2016-08-02 15:20 +0200
SubjectRe: [PATCHv2 1/7] tools lib: Add bitmap_alloc function
Message-ID<s1HM0-4Xn-95@gated-at.bofh.it>
In reply to#1453913
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 <jolsa@kernel.org>
> > ---
> >  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 <string.h>
> >  #include <linux/bitops.h>
> > +#include <stdlib.h>
> >  
> >  #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

[toc] | [prev] | [next] | [standalone]


#1454513 — Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-08-02 16:20 +0200
SubjectRe: [PATCHv2 1/7] tools lib: Add bitmap_alloc function
Message-ID<s1HM0-4Xn-97@gated-at.bofh.it>
In reply to#1453913
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?

[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 <jolsa@kernel.org>
> ---
>  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 <string.h>
>  #include <linux/bitops.h>
> +#include <stdlib.h>
>  
>  #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

[toc] | [prev] | [next] | [standalone]


#1456230 — [tip:perf/urgent] tools lib: Add bitmap_alloc function

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-08-04 11:20 +0200
Subject[tip:perf/urgent] tools lib: Add bitmap_alloc function
Message-ID<s2mYN-6W6-3@gated-at.bofh.it>
In reply to#1453913
Commit-ID:  98c032967a299ee4bf14ef19eded02b65df32e6f
Gitweb:     http://git.kernel.org/tip/98c032967a299ee4bf14ef19eded02b65df32e6f
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 2 Aug 2016 13:33:02 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 2 Aug 2016 16:33:26 -0300

tools lib: Add bitmap_alloc function

Adding bitmap_alloc function to dynamically allocate bitmap.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20160802113302.GA7479@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 28f5493..60c44b6 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -3,6 +3,7 @@
 
 #include <string.h>
 #include <linux/bitops.h>
+#include <stdlib.h>
 
 #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 */

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web