From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, He Kuang <hekuang@huawei.com>,
Alexei Starovoitov <ast@kernel.org>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>, Zefan Li <lizefan@huawei.com>,
pi3orama@163.com, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 13/13] bpf tools: Add helper function for updating bpf maps elements
Date: Thu, 26 Nov 2015 17:46:11 -0300 [thread overview]
Message-ID: <1448570771-5430-14-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1448570771-5430-1-git-send-email-acme@kernel.org>
From: He Kuang <hekuang@huawei.com>
Add bpf_map_update_elem() helper function which calls the sys_bpf
syscall to update elements in bpf maps. Upcoming patches will use it to
adjust data in map through the perf command line.
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1448372181-151723-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/bpf/bpf.c | 14 ++++++++++++++
tools/lib/bpf/bpf.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index a6331050ab79..5bdc6eab6852 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -83,3 +83,17 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
log_buf[0] = 0;
return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
}
+
+int bpf_map_update_elem(int fd, void *key, void *value,
+ u64 flags)
+{
+ union bpf_attr attr;
+
+ bzero(&attr, sizeof(attr));
+ attr.map_fd = fd;
+ attr.key = ptr_to_u64(key);
+ attr.value = ptr_to_u64(value);
+ attr.flags = flags;
+
+ return sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
+}
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 854b7361b784..a76465541292 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -20,4 +20,6 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
u32 kern_version, char *log_buf,
size_t log_buf_sz);
+int bpf_map_update_elem(int fd, void *key, void *value,
+ u64 flags);
#endif
--
2.1.0
next prev parent reply other threads:[~2015-11-26 20:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 20:45 [GIT PULL 00/13] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-11-26 20:45 ` [PATCH 01/13] perf callchain: Honor hide_unresolved Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 02/13] perf top: Fix freeze on --call-graph flat/folded Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 03/13] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 04/13] perf build: Fix traceevent plugins build race Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 05/13] perf machine: Adjust dso->long_name for offline module Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 06/13] perf tools: Correctly identify anon_hugepage when generating map (v2) Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 07/13] perf script: Pass perf_script into process_event Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 08/13] tools build: Use fixdep with OUTPUT path prefix Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 09/13] perf symbols: Refactor vmlinux_path__init() to ease path additions Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 10/13] perf symbols: Add the path to vmlinux.debug Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 11/13] perf stat: Clear sample_(type|period) for counting Arnaldo Carvalho de Melo
2015-11-26 20:46 ` [PATCH 12/13] perf evlist: Display WEIGHT sample type bit Arnaldo Carvalho de Melo
2015-11-26 20:46 ` Arnaldo Carvalho de Melo [this message]
2015-11-27 7:30 ` [GIT PULL 00/13] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448570771-5430-14-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=hekuang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).