From: tip-bot for He Kuang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hekuang@huawei.com, linux-kernel@vger.kernel.org,
masami.hiramatsu.pt@hitachi.com, ast@kernel.org,
lizefan@huawei.com, wangnan0@huawei.com, namhyung@kernel.org,
acme@redhat.com, tglx@linutronix.de, mingo@kernel.org,
hpa@zytor.com
Subject: [tip:perf/core] bpf tools: Add helper function for updating bpf maps elements
Date: Thu, 26 Nov 2015 23:47:21 -0800 [thread overview]
Message-ID: <tip-43798bf37215fe242e592fd4605d804e2da0781b@git.kernel.org> (raw)
In-Reply-To: <1448372181-151723-4-git-send-email-wangnan0@huawei.com>
Commit-ID: 43798bf37215fe242e592fd4605d804e2da0781b
Gitweb: http://git.kernel.org/tip/43798bf37215fe242e592fd4605d804e2da0781b
Author: He Kuang <hekuang@huawei.com>
AuthorDate: Tue, 24 Nov 2015 13:36:08 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 26 Nov 2015 17:21:24 -0300
bpf tools: Add helper function for updating bpf maps elements
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 a633105..5bdc6ea 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 854b736..a764655 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
next prev parent reply other threads:[~2015-11-27 7:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 13:36 [PATCH 00/16] perf tools: BPF related update Wang Nan
2015-11-24 13:36 ` [PATCH 01/16] tools build: Clean CFLAGS and LDFLAGS for fixdep Wang Nan
2015-11-26 8:21 ` [tip:perf/core] " tip-bot for Wang Nan
2015-11-24 13:36 ` [PATCH 02/16] tools lib bpf: Don't feature check when cleaning Wang Nan
2015-11-26 8:22 ` [tip:perf/core] tools lib bpf: Don' t do a " tip-bot for Wang Nan
2015-11-24 13:36 ` [PATCH 03/16] bpf tools: Add helper function for updating bpf maps elements Wang Nan
2015-11-27 7:47 ` tip-bot for He Kuang [this message]
2015-11-24 13:36 ` [PATCH 04/16] bpf tools: Collect map definition in bpf_object Wang Nan
2015-11-26 20:56 ` Arnaldo Carvalho de Melo
2015-11-27 6:16 ` Wangnan (F)
2015-11-27 6:21 ` Wangnan (F)
2015-11-24 13:36 ` [PATCH 05/16] bpf tools: Extract and collect map names from BPF object file Wang Nan
2015-11-24 13:36 ` [PATCH 06/16] perf tools: Rename bpf config to program config Wang Nan
2015-11-24 13:36 ` [PATCH 07/16] perf tools: Add API to config maps in bpf object Wang Nan
2015-11-27 7:32 ` Wangnan (F)
2015-11-24 13:36 ` [PATCH 08/16] perf tools: Enable BPF object configure syntax Wang Nan
2015-11-24 13:36 ` [PATCH 09/16] perf record: Apply config to BPF objects before recording Wang Nan
2015-11-24 13:36 ` [PATCH 10/16] perf tools: Support perf event alias name Wang Nan
2015-11-24 13:36 ` [PATCH 11/16] perf tools: Enable passing event to BPF object Wang Nan
2015-11-24 13:36 ` [PATCH 12/16] perf tools: Support setting different slots in a BPF map separately Wang Nan
2015-11-27 7:31 ` Wangnan (F)
2015-11-24 13:36 ` [PATCH 13/16] perf tools: Enable indices setting syntax for BPF maps Wang Nan
2015-11-24 13:36 ` [PATCH 14/16] perf tools: Introduce bpf-output event Wang Nan
2015-11-24 13:36 ` [PATCH 15/16] perf data: Add u32_hex data type Wang Nan
2015-11-24 13:36 ` [PATCH 16/16] perf data: Support converting data from bpf_perf_event_output() Wang Nan
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=tip-43798bf37215fe242e592fd4605d804e2da0781b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=hekuang@huawei.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--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