diff options
| author | Ingo Molnar <mingo@kernel.org> | 2016-12-02 10:08:03 +0100 | 
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-12-02 10:08:03 +0100 | 
| commit | e7af7b15121ca08c31a0ab9df71a41b4c53365b4 (patch) | |
| tree | 3c4ee7bd52c8cc41642efee0b5549b573d69268a /tools/lib/bpf/bpf.c | |
| parent | 3782746a08f6b0a8e385058b6748a5a0f166f3a7 (diff) | |
| parent | 0fcb1da4aba6e6c7b32de5e0948b740b31ad822d (diff) | |
Merge tag 'perf-core-for-mingo-20161201' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
New features:
 - Support AArch64 in the 'annotate' code, native/local and
   cross-arch/remote (Kim Phillips)
 - Allow considering just events in a given time interval, via the
   '--time start.s.ms,end.s.ms' command line, added to 'perf kmem',
   'perf report', 'perf sched timehist' and 'perf script' (David Ahern)
 - Add option to stop printing a callchain at one of a given group of
   symbol names (David Ahern)
 - Handle CPU migration events in 'perf sched timehist' (David Ahern)
 - Track memory freed in 'perf kmem stat' (David Ahern)
Infrastructure:
 - Add initial support (and perf test entry) for tooling hooks, starting with
   'record_start' and 'record_end', that will have as its initial user the
   eBPF infrastructure, where perf_ prefixed functions will be JITed and
   run when such hooks are called (Wang Nan)
 - Remove redundant "test" and similar strings from 'perf test' descriptions
   (Arnaldo Carvalho de Melo)
 - Implement assorted libbpf improvements (Wang Nan)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/lib/bpf/bpf.c')
| -rw-r--r-- | tools/lib/bpf/bpf.c | 56 | 
1 files changed, 56 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 4212ed62235b..8143536b462a 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -110,3 +110,59 @@ int bpf_map_update_elem(int fd, void *key, void *value,  	return sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));  } + +int bpf_map_lookup_elem(int fd, void *key, void *value) +{ +	union bpf_attr attr; + +	bzero(&attr, sizeof(attr)); +	attr.map_fd = fd; +	attr.key = ptr_to_u64(key); +	attr.value = ptr_to_u64(value); + +	return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_delete_elem(int fd, void *key) +{ +	union bpf_attr attr; + +	bzero(&attr, sizeof(attr)); +	attr.map_fd = fd; +	attr.key = ptr_to_u64(key); + +	return sys_bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr)); +} + +int bpf_map_get_next_key(int fd, void *key, void *next_key) +{ +	union bpf_attr attr; + +	bzero(&attr, sizeof(attr)); +	attr.map_fd = fd; +	attr.key = ptr_to_u64(key); +	attr.next_key = ptr_to_u64(next_key); + +	return sys_bpf(BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr)); +} + +int bpf_obj_pin(int fd, const char *pathname) +{ +	union bpf_attr attr; + +	bzero(&attr, sizeof(attr)); +	attr.pathname = ptr_to_u64((void *)pathname); +	attr.bpf_fd = fd; + +	return sys_bpf(BPF_OBJ_PIN, &attr, sizeof(attr)); +} + +int bpf_obj_get(const char *pathname) +{ +	union bpf_attr attr; + +	bzero(&attr, sizeof(attr)); +	attr.pathname = ptr_to_u64((void *)pathname); + +	return sys_bpf(BPF_OBJ_GET, &attr, sizeof(attr)); +}  | 
