Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1290815 > unrolled thread
| Started by | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| First post | 2015-12-14 04:30 +0100 |
| Last post | 2015-12-14 07:00 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps "Wangnan (F)" <wangnan0@huawei.com> - 2015-12-14 04:30 +0100
Re: [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2015-12-14 05:30 +0100
Re: [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps "Wangnan (F)" <wangnan0@huawei.com> - 2015-12-14 05:50 +0100
Re: [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2015-12-14 07:00 +0100
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-12-14 04:30 +0100 |
| Subject | Re: [PATCH v4 09/16] perf tools: Enable indices setting syntax for BPF maps |
| Message-ID | <qFrZM-we-11@gated-at.bofh.it> |
On 2015/12/12 2:21, Alexei Starovoitov wrote: > On Fri, Dec 11, 2015 at 08:39:35PM +0800, pi3orama wrote: >>> static u64 (*bpf_ktime_get_ns)(void) = >>> (void *)5; >>> static int (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = >>> (void *)6; >>> static int (*bpf_get_smp_processor_id)(void) = >>> (void *)8; >>> static int (*bpf_perf_event_output)(void *, struct bpf_map_def *, int, >>> void *, unsigned long) = >>> (void *)23; >>> >>> Where can I get this magical mistery table? Could this be hidden away in >>> some .h file automagically included in bpf scriptlets so that n00bies >>> like me don't have to be wtf'ing? >>> >> They are function numbers defined in bpf.h and bpf-common.h, but they are Linux >> headers. Directly include them causes many error for llvm. Also, the function >> prototypes are BPF specific and can't included in Linux source. We should have >> a place holds those indices and prototypes together. > wait, what kind of errors? > they are in uapi, so gets installed into /usr/include eventually > and I haven't seen any erros either with gcc or clang. > Sorry. I saw error because I use #include <linux/bpf.h> It is okay if I use #include <uapi/linux/bpf.h> Thank you. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Date | 2015-12-14 05:30 +0100 |
| Message-ID | <qFsVP-17V-5@gated-at.bofh.it> |
| In reply to | #1290815 |
On Mon, Dec 14, 2015 at 11:27:36AM +0800, Wangnan (F) wrote: > > > On 2015/12/12 2:21, Alexei Starovoitov wrote: > >On Fri, Dec 11, 2015 at 08:39:35PM +0800, pi3orama wrote: > >>>static u64 (*bpf_ktime_get_ns)(void) = > >>> (void *)5; > >>>static int (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = > >>> (void *)6; > >>>static int (*bpf_get_smp_processor_id)(void) = > >>> (void *)8; > >>>static int (*bpf_perf_event_output)(void *, struct bpf_map_def *, int, > >>>void *, unsigned long) = > >>> (void *)23; > >>> > >>>Where can I get this magical mistery table? Could this be hidden away in > >>>some .h file automagically included in bpf scriptlets so that n00bies > >>>like me don't have to be wtf'ing? > >>> > >>They are function numbers defined in bpf.h and bpf-common.h, but they are Linux > >>headers. Directly include them causes many error for llvm. Also, the function > >>prototypes are BPF specific and can't included in Linux source. We should have > >>a place holds those indices and prototypes together. > >wait, what kind of errors? > >they are in uapi, so gets installed into /usr/include eventually > >and I haven't seen any erros either with gcc or clang. > > > Sorry. I saw error because I use > > #include <linux/bpf.h> > > It is okay if I use > > #include <uapi/linux/bpf.h> then let's use that instead of copy-paste. thanks -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-12-14 05:50 +0100 |
| Message-ID | <qFtfc-1fM-9@gated-at.bofh.it> |
| In reply to | #1290834 |
On 2015/12/14 12:28, Alexei Starovoitov wrote:
> On Mon, Dec 14, 2015 at 11:27:36AM +0800, Wangnan (F) wrote:
>>
>> On 2015/12/12 2:21, Alexei Starovoitov wrote:
>>> On Fri, Dec 11, 2015 at 08:39:35PM +0800, pi3orama wrote:
>>>>> static u64 (*bpf_ktime_get_ns)(void) =
>>>>> (void *)5;
>>>>> static int (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
>>>>> (void *)6;
>>>>> static int (*bpf_get_smp_processor_id)(void) =
>>>>> (void *)8;
>>>>> static int (*bpf_perf_event_output)(void *, struct bpf_map_def *, int,
>>>>> void *, unsigned long) =
>>>>> (void *)23;
>>>>>
>>>>> Where can I get this magical mistery table? Could this be hidden away in
>>>>> some .h file automagically included in bpf scriptlets so that n00bies
>>>>> like me don't have to be wtf'ing?
>>>>>
>>>> They are function numbers defined in bpf.h and bpf-common.h, but they are Linux
>>>> headers. Directly include them causes many error for llvm. Also, the function
>>>> prototypes are BPF specific and can't included in Linux source. We should have
>>>> a place holds those indices and prototypes together.
>>> wait, what kind of errors?
>>> they are in uapi, so gets installed into /usr/include eventually
>>> and I haven't seen any erros either with gcc or clang.
>>>
>> Sorry. I saw error because I use
>>
>> #include <linux/bpf.h>
>>
>> It is okay if I use
>>
>> #include <uapi/linux/bpf.h>
> then let's use that instead of copy-paste. thanks
And what do you think about the BPF function prototype? Should we put them
into kernel headers? What about::
diff --git a/include/uapi/linux/bpf_functions.h
b/include/uapi/linux/bpf_functions.h
new file mode 100644
index 0000000..3a562d4
--- /dev/null
+++ b/include/uapi/linux/bpf_functions.h
@@ -0,0 +1,2 @@
+DEFINE_BPF_FUNC(void *, map_lookup_elem, void *, void *)
+DEFINE_BPF_FUNC(int, map_update_elem, void *, void *, void *, int)
[SNIP]
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 9ea2d22..2f2f05f 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -133,143 +133,23 @@ union bpf_attr {
};
} __attribute__((aligned(8)));
+#define DEFINE_BPF_FUNC(rettype, name, arglist...) BPF_FUNC_##name
+
+enum bpf_func_id {
+BPF_FUNC_unspec,
+#include "bpf_functions.h"
+__BPF_FUNC_MAX_ID,
+};
+
+#ifdef __BPF_SOURCE__
+#undef DEFINE_BPF_FUNC
+#define DEFINE_BPF_FUNC(rettype, name, arglist...) static rettype
(*name)(arglist) = (void *)BPF_FUNC_##name
+#include "bpf_functions.h"
+#endif
/* integer value in 'imm' field of BPF_CALL instruction selects which
helper
* function eBPF program intends to call
*/
enum bpf_func_id {
- BPF_FUNC_unspec,
[SNIP]
And when compiling BPF source file we add a __BPF_SOURCE__ directive?
Thank you.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Date | 2015-12-14 07:00 +0100 |
| Message-ID | <qFukW-1Wg-7@gated-at.bofh.it> |
| In reply to | #1290845 |
On Mon, Dec 14, 2015 at 12:39:40PM +0800, Wangnan (F) wrote:
>
> And what do you think about the BPF function prototype? Should we put them
> into kernel headers? What about::
> +#define DEFINE_BPF_FUNC(rettype, name, arglist...) static rettype
> (*name)(arglist) = (void *)BPF_FUNC_##name
tldr: let's keep it as a part of user headers until better
solution found.
frankly
static void *(*bpf_map_lookup_elem)(void *map, void *key) =
(void *) BPF_FUNC_map_lookup_elem;
was llvm hack that I thought will be fixed quickly.
That was the easiest way to make C/llvm/bpf_loader to agree on
passing 'bpf_call #num' insn into the kernel.
It works, but it works only with -O2 and higher.
At lower optimization levels llvm generates load of constant
into register and indirect call by register, so that's not suitable
as clean api. bcc with clang::rewriter can solve it, but we don't
want to always depend on that, so currently it's a status quo.
Don't mess with what ain't broken.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web