From: pi3orama <pi3orama@163.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>,
jolsa@redhat.com, brendan.d.gregg@gmail.com,
linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Alexei Starovoitov <ast@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Li Zefan <lizefan@huawei.com>
Subject: Re: [RFC PATCH 05/13] bpf tools: Save engine type in bpf_program
Date: Thu, 21 Apr 2016 03:29:43 +0800 [thread overview]
Message-ID: <B1F03B56-E1AF-4269-BC52-FE5ACB820751@163.com> (raw)
In-Reply-To: <20160420192315.GU3677@kernel.org>
发自我的 iPhone
> 在 2016年4月21日,上午3:23,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
>
> Em Wed, Apr 20, 2016 at 06:01:45PM +0000, Wang Nan escreveu:
>>
[SNIP]
>>
>> + if (prog->engine == ENGINE_UNKNOWN)
>> + prog->engine = ENGINE_KBPF;
>> + if (prog->engine != ENGINE_KBPF)
>
> else if (prog->engine != ENGINE_KBPF)
>
> Nitpicking a bit :-)
>
We set it to ENGINE_KBPF in previous "if",
so can't use "else".
Do this because I want the engine is KBPF
if not explicitly set to UNPF.
Thank you.
>> + return -EINVAL;
>> +
>> if (prog->instances.nr < 0 || !prog->instances.array) {
>> if (prog->preprocessor) {
>> pr_warning("Internal error: can't load program '%s'\n",
>> @@ -1318,6 +1330,34 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n)
>> return fd;
>> }
>>
>> +#ifdef HAVE_UBPF_SUPPORT
>> +int bpf_program__set_ubpf(struct bpf_program *prog)
>> +{
>> + if (prog->engine != ENGINE_UNKNOWN) {
>> + pr_warning("Can't set program %s to ubpf\n",
>> + prog->section_name);
>> + return -EINVAL;
>> + }
>> + prog->engine = ENGINE_UBPF;
>> + return 0;
>> +}
>> +
>> +bool bpf_program__is_ubpf(struct bpf_program *prog)
>> +{
>> + return prog->engine == ENGINE_UBPF;
>> +}
>> +#else
>> +int bpf_program__set_ubpf(struct bpf_program *prog __maybe_unused)
>> +{
>> + return -LIBBPF_ERRNO__NOUBPF;
>> +}
>> +
>> +bool bpf_program__is_ubpf(struct bpf_program *prog __maybe_unused)
>> +{
>> + return false;
>> +}
>> +#endif
>> +
>> int bpf_map__get_fd(struct bpf_map *map)
>> {
>> if (!map)
>> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
>> index a51594c..f6965ce 100644
>> --- a/tools/lib/bpf/libbpf.h
>> +++ b/tools/lib/bpf/libbpf.h
>> @@ -26,6 +26,7 @@ enum libbpf_errno {
>> LIBBPF_ERRNO__VERIFY, /* Kernel verifier blocks program loading */
>> LIBBPF_ERRNO__PROG2BIG, /* Program too big */
>> LIBBPF_ERRNO__KVER, /* Incorrect kernel version */
>> + LIBBPF_ERRNO__NOUBPF, /* UBPF support is not compiled */
>> __LIBBPF_ERRNO__END,
>> };
>>
>> @@ -86,6 +87,9 @@ int bpf_program__get_private(struct bpf_program *prog,
>>
>> const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
>>
>> +int bpf_program__set_ubpf(struct bpf_program *prog);
>> +bool bpf_program__is_ubpf(struct bpf_program *prog);
>> +
>> int bpf_program__fd(struct bpf_program *prog);
>>
>> struct bpf_insn;
>> --
>> 1.8.3.4
next prev parent reply other threads:[~2016-04-20 19:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-20 18:01 [RFC PATCH 00/13] perf tools: Support uBPF script Wang Nan
2016-04-20 18:01 ` [RFC PATCH 01/13] bpf tools: Add map related BPF helper Wang Nan
2016-04-20 18:01 ` [RFC PATCH 02/13] tools: Add ubpf feature test Wang Nan
2016-04-20 19:11 ` Arnaldo Carvalho de Melo
2016-04-20 18:01 ` [RFC PATCH 03/13] bpf tools: Add ubpf include and makefile options Wang Nan
2016-04-20 18:01 ` [RFC PATCH 04/13] bpf tools: Replace fd array to union array Wang Nan
2016-04-20 19:20 ` Arnaldo Carvalho de Melo
2016-04-20 18:01 ` [RFC PATCH 05/13] bpf tools: Save engine type in bpf_program Wang Nan
2016-04-20 19:23 ` Arnaldo Carvalho de Melo
2016-04-20 19:29 ` pi3orama [this message]
2016-04-20 18:01 ` [RFC PATCH 06/13] bpf tools: Introduce ubpf_vm to program instance union Wang Nan
2016-04-20 19:30 ` Arnaldo Carvalho de Melo
2016-04-20 18:01 ` [RFC PATCH 07/13] bpf tools: Load ubpf program Wang Nan
2016-04-20 19:34 ` Arnaldo Carvalho de Melo
2016-04-20 18:01 ` [RFC PATCH 08/13] bpf tools: Add API for fetching ubpf_vm Wang Nan
2016-04-20 18:01 ` [RFC PATCH 09/13] bpf tools: Register extern functions for ubpf programs Wang Nan
2016-04-20 18:01 ` [RFC PATCH 10/13] perf tools: Register basic UBPF helpers Wang Nan
2016-04-20 18:01 ` [RFC PATCH 11/13] perf bpf: Accept ubpf programs Wang Nan
2016-04-20 18:01 ` [RFC PATCH 12/13] perf record: Add UBPF hooks at beginning and end of perf record Wang Nan
2016-04-20 18:01 ` [RFC PATCH 13/13] perf tests: Add UBPF test case Wang Nan
2016-04-20 22:06 ` [RFC PATCH 00/13] perf tools: Support uBPF script Alexei Starovoitov
2016-04-21 8:17 ` Wangnan (F)
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=B1F03B56-E1AF-4269-BC52-FE5ACB820751@163.com \
--to=pi3orama@163.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=brendan.d.gregg@gmail.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.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
all inboxes | Powered by JetHome®