Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf mmap: Declare type for cpu mask of arbitrary length

Declare a dedicated struct map_cpu_mask type for cpu masks of arbitrary
length.

The mask is available thru bits pointer and the mask length is kept in
nbits field. MMAP_CPU_MASK_BYTES() macro returns mask storage size in
bytes.

The mmap_cpu_mask__scnprintf() function can be used to log text
representation of the mask.

Committer notes:

To print the 'nbits' struct member we must use %zd, since it is a
size_t, this fixes the build in some toolchains/arches.

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/0fd2454f-477f-d15a-f4ee-79bcbd2585ff@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Alexey Budankov and committed by
Arnaldo Carvalho de Melo
9c080c02 8812ad41

+23
+12
tools/perf/util/mmap.c
··· 23 23 #include "mmap.h" 24 24 #include "../perf.h" 25 25 #include <internal/lib.h> /* page_size */ 26 + #include <linux/bitmap.h> 27 + 28 + #define MASK_SIZE 1023 29 + void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag) 30 + { 31 + char buf[MASK_SIZE + 1]; 32 + size_t len; 33 + 34 + len = bitmap_scnprintf(mask->bits, mask->nbits, buf, MASK_SIZE); 35 + buf[len] = '\0'; 36 + pr_debug("%p: %s mask[%zd]: %s\n", mask, tag, mask->nbits, buf); 37 + } 26 38 27 39 size_t mmap__mmap_len(struct mmap *map) 28 40 {
+11
tools/perf/util/mmap.h
··· 15 15 #include "event.h" 16 16 17 17 struct aiocb; 18 + 19 + struct mmap_cpu_mask { 20 + unsigned long *bits; 21 + size_t nbits; 22 + }; 23 + 24 + #define MMAP_CPU_MASK_BYTES(m) \ 25 + (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long)) 26 + 18 27 /** 19 28 * struct mmap - perf's ring buffer mmap details 20 29 * ··· 60 51 int push(struct mmap *map, void *to, void *buf, size_t size)); 61 52 62 53 size_t mmap__mmap_len(struct mmap *map); 54 + 55 + void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag); 63 56 64 57 #endif /*__PERF_MMAP_H */