Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LIBPERF_INTERNAL_MMAP_H
0003 #define __LIBPERF_INTERNAL_MMAP_H
0004 
0005 #include <linux/compiler.h>
0006 #include <linux/refcount.h>
0007 #include <linux/types.h>
0008 #include <stdbool.h>
0009 #include <internal/cpumap.h>
0010 
0011 /* perf sample has 16 bits size limit */
0012 #define PERF_SAMPLE_MAX_SIZE (1 << 16)
0013 
0014 struct perf_mmap;
0015 struct perf_counts_values;
0016 
0017 typedef void (*libperf_unmap_cb_t)(struct perf_mmap *map);
0018 
0019 /**
0020  * struct perf_mmap - perf's ring buffer mmap details
0021  *
0022  * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
0023  */
0024 struct perf_mmap {
0025     void            *base;
0026     int          mask;
0027     int          fd;
0028     struct perf_cpu      cpu;
0029     refcount_t       refcnt;
0030     u64          prev;
0031     u64          start;
0032     u64          end;
0033     bool             overwrite;
0034     u64          flush;
0035     libperf_unmap_cb_t   unmap_cb;
0036     char             event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
0037     struct perf_mmap    *next;
0038 };
0039 
0040 struct perf_mmap_param {
0041     int prot;
0042     int mask;
0043 };
0044 
0045 size_t perf_mmap__mmap_len(struct perf_mmap *map);
0046 
0047 void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev,
0048              bool overwrite, libperf_unmap_cb_t unmap_cb);
0049 int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp,
0050             int fd, struct perf_cpu cpu);
0051 void perf_mmap__munmap(struct perf_mmap *map);
0052 void perf_mmap__get(struct perf_mmap *map);
0053 void perf_mmap__put(struct perf_mmap *map);
0054 
0055 u64 perf_mmap__read_head(struct perf_mmap *map);
0056 
0057 int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count);
0058 
0059 #endif /* __LIBPERF_INTERNAL_MMAP_H */