From: tip-bot for Joe Stringer <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: wangnan0@huawei.com, ast@fb.com, linux-kernel@vger.kernel.org,
hpa@zytor.com, daniel@iogearbox.net, tglx@linutronix.de,
acme@redhat.com, joe@ovn.org, mingo@kernel.org
Subject: [tip:perf/core] tools lib bpf: Add bpf_map__pin()
Date: Wed, 1 Feb 2017 06:40:45 -0800 [thread overview]
Message-ID: <tip-b6989f35e80bf830f8dc97b74128d619faef0273@git.kernel.org> (raw)
In-Reply-To: <20170126212001.14103-3-joe@ovn.org>
Commit-ID: b6989f35e80bf830f8dc97b74128d619faef0273
Gitweb: http://git.kernel.org/tip/b6989f35e80bf830f8dc97b74128d619faef0273
Author: Joe Stringer <joe@ovn.org>
AuthorDate: Thu, 26 Jan 2017 13:19:57 -0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 31 Jan 2017 16:20:06 -0300
tools lib bpf: Add bpf_map__pin()
Add a new API to pin a BPF map to the filesystem. The user can specify
the path full path within a BPF filesystem to pin the map.
Signed-off-by: Joe Stringer <joe@ovn.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/20170126212001.14103-3-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/bpf/libbpf.c | 22 ++++++++++++++++++++++
tools/lib/bpf/libbpf.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index c4465b2fd..6a8c8bee 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1357,6 +1357,28 @@ int bpf_program__pin(struct bpf_program *prog, const char *path)
return 0;
}
+int bpf_map__pin(struct bpf_map *map, const char *path)
+{
+ int err;
+
+ err = check_path(path);
+ if (err)
+ return err;
+
+ if (map == NULL) {
+ pr_warning("invalid map pointer\n");
+ return -EINVAL;
+ }
+
+ if (bpf_obj_pin(map->fd, path)) {
+ pr_warning("failed to pin map: %s\n", strerror(errno));
+ return -errno;
+ }
+
+ pr_debug("pinned map '%s'\n", path);
+ return 0;
+}
+
void bpf_object__close(struct bpf_object *obj)
{
size_t i;
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 9f8aa63..2addf9d 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -236,6 +236,7 @@ typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
int bpf_map__set_priv(struct bpf_map *map, void *priv,
bpf_map_clear_priv_t clear_priv);
void *bpf_map__priv(struct bpf_map *map);
+int bpf_map__pin(struct bpf_map *map, const char *path);
long libbpf_get_error(const void *ptr);
next prev parent reply other threads:[~2017-02-01 14:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 21:19 [PATCHv3 perf/core 0/6] Libbpf object pinning Joe Stringer
2017-01-26 21:19 ` [PATCHv3 perf/core 1/6] tools lib bpf: Add BPF program pinning APIs Joe Stringer
2017-01-30 20:25 ` Arnaldo Carvalho de Melo
2017-01-30 20:28 ` Arnaldo Carvalho de Melo
2017-01-30 21:16 ` Joe Stringer
2017-01-31 0:58 ` Arnaldo Carvalho de Melo
2017-01-31 16:08 ` Arnaldo Carvalho de Melo
2017-01-31 16:13 ` Arnaldo Carvalho de Melo
2017-01-31 16:42 ` Arnaldo Carvalho de Melo
2017-02-01 14:40 ` [tip:perf/core] " tip-bot for Joe Stringer
2017-01-26 21:19 ` [PATCHv3 perf/core 2/6] tools lib bpf: Add bpf_map__pin() Joe Stringer
2017-02-01 14:40 ` tip-bot for Joe Stringer [this message]
2017-01-26 21:19 ` [PATCHv3 perf/core 3/6] tools lib bpf: Add bpf_object__pin() Joe Stringer
2017-02-01 14:41 ` [tip:perf/core] " tip-bot for Joe Stringer
2017-01-26 21:19 ` [PATCHv3 perf/core 4/6] tools perf util: Make rm_rf(path) argument const Joe Stringer
2017-02-01 14:41 ` [tip:perf/core] " tip-bot for Joe Stringer
2017-01-26 21:20 ` [PATCHv3 perf/core 5/6] tools lib api fs: Add bpf_fs filesystem detector Joe Stringer
2017-02-01 14:42 ` [tip:perf/core] " tip-bot for Joe Stringer
2017-01-26 21:20 ` [PATCHv3 perf/core 6/6] perf test: Add libbpf pinning test Joe Stringer
2017-02-01 14:42 ` [tip:perf/core] " tip-bot for Joe Stringer
2017-01-30 20:37 ` [PATCHv3 perf/core 0/6] Libbpf object pinning Arnaldo Carvalho de Melo
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-b6989f35e80bf830f8dc97b74128d619faef0273@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=hpa@zytor.com \
--cc=joe@ovn.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@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;
as well as URLs for NNTP newsgroup(s).