Lines Matching full:map
19 void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev, in perf_mmap__init() argument
22 map->fd = -1; in perf_mmap__init()
23 map->overwrite = overwrite; in perf_mmap__init()
24 map->unmap_cb = unmap_cb; in perf_mmap__init()
25 refcount_set(&map->refcnt, 0); in perf_mmap__init()
27 prev->next = map; in perf_mmap__init()
30 size_t perf_mmap__mmap_len(struct perf_mmap *map) in perf_mmap__mmap_len() argument
32 return map->mask + 1 + page_size; in perf_mmap__mmap_len()
35 int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, in perf_mmap__mmap() argument
38 map->prev = 0; in perf_mmap__mmap()
39 map->mask = mp->mask; in perf_mmap__mmap()
40 map->base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot, in perf_mmap__mmap()
42 if (map->base == MAP_FAILED) { in perf_mmap__mmap()
43 map->base = NULL; in perf_mmap__mmap()
47 map->fd = fd; in perf_mmap__mmap()
48 map->cpu = cpu; in perf_mmap__mmap()
52 void perf_mmap__munmap(struct perf_mmap *map) in perf_mmap__munmap() argument
54 if (map && map->base != NULL) { in perf_mmap__munmap()
55 munmap(map->base, perf_mmap__mmap_len(map)); in perf_mmap__munmap()
56 map->base = NULL; in perf_mmap__munmap()
57 map->fd = -1; in perf_mmap__munmap()
58 refcount_set(&map->refcnt, 0); in perf_mmap__munmap()
60 if (map && map->unmap_cb) in perf_mmap__munmap()
61 map->unmap_cb(map); in perf_mmap__munmap()
64 void perf_mmap__get(struct perf_mmap *map) in perf_mmap__get() argument
66 refcount_inc(&map->refcnt); in perf_mmap__get()
69 void perf_mmap__put(struct perf_mmap *map) in perf_mmap__put() argument
71 BUG_ON(map->base && refcount_read(&map->refcnt) == 0); in perf_mmap__put()
73 if (refcount_dec_and_test(&map->refcnt)) in perf_mmap__put()
74 perf_mmap__munmap(map); in perf_mmap__put()
82 u64 perf_mmap__read_head(struct perf_mmap *map) in perf_mmap__read_head() argument
84 return ring_buffer_read_head(map->base); in perf_mmap__read_head()
87 static bool perf_mmap__empty(struct perf_mmap *map) in perf_mmap__empty() argument
89 struct perf_event_mmap_page *pc = map->base; in perf_mmap__empty()
91 return perf_mmap__read_head(map) == map->prev && !pc->aux_size; in perf_mmap__empty()
94 void perf_mmap__consume(struct perf_mmap *map) in perf_mmap__consume() argument
96 if (!map->overwrite) { in perf_mmap__consume()
97 u64 old = map->prev; in perf_mmap__consume()
99 perf_mmap__write_tail(map, old); in perf_mmap__consume()
102 if (refcount_read(&map->refcnt) == 1 && perf_mmap__empty(map)) in perf_mmap__consume()
103 perf_mmap__put(map); in perf_mmap__consume()
175 int perf_mmap__read_init(struct perf_mmap *map) in perf_mmap__read_init() argument
180 if (!refcount_read(&map->refcnt)) in perf_mmap__read_init()
183 return __perf_mmap__read_init(map); in perf_mmap__read_init()
189 * The last perf_mmap__read() will set tail to map->core.prev.
190 * Need to correct the map->core.prev to head which is the end of next read.
192 void perf_mmap__read_done(struct perf_mmap *map) in perf_mmap__read_done() argument
197 if (!refcount_read(&map->refcnt)) in perf_mmap__read_done()
200 map->prev = perf_mmap__read_head(map); in perf_mmap__read_done()
204 static union perf_event *perf_mmap__read(struct perf_mmap *map, in perf_mmap__read() argument
207 unsigned char *data = map->base + page_size; in perf_mmap__read()
214 event = (union perf_event *)&data[*startp & map->mask]; in perf_mmap__read()
224 if ((*startp & map->mask) + size != ((*startp + size) & map->mask)) { in perf_mmap__read()
227 void *dst = map->event_copy; in perf_mmap__read()
230 cpy = min(map->mask + 1 - (offset & map->mask), len); in perf_mmap__read()
231 memcpy(dst, &data[offset & map->mask], cpy); in perf_mmap__read()
237 event = (union perf_event *)map->event_copy; in perf_mmap__read()
258 union perf_event *perf_mmap__read_event(struct perf_mmap *map) in perf_mmap__read_event() argument
265 if (!refcount_read(&map->refcnt)) in perf_mmap__read_event()
269 if (!map->overwrite) in perf_mmap__read_event()
270 map->end = perf_mmap__read_head(map); in perf_mmap__read_event()
272 event = perf_mmap__read(map, &map->start, map->end); in perf_mmap__read_event()
274 if (!map->overwrite) in perf_mmap__read_event()
275 map->prev = map->start; in perf_mmap__read_event()
400 int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count) in perf_mmap__read_self() argument
402 struct perf_event_mmap_page *pc = map->base; in perf_mmap__read_self()