> On Nov 9, 2019, at 12:06 AM, Andrii Nakryiko <andriin@xxxxxx> wrote: > > Add ability to memory-map contents of BPF array map. This is extremely useful > for working with BPF global data from userspace programs. It allows to avoid > typical bpf_map_{lookup,update}_elem operations, improving both performance > and usability. [...] > > Generated code for memory-mapped array: > > ; p = bpf_map_lookup_elem(&data_map, &zero); > 22: (18) r1 = map[id:27] > 24: (07) r1 += 400 /* array->data offset */ > 25: (79) r1 = *(u64 *)(r1 +0) /* extra dereference */ > 26: (61) r0 = *(u32 *)(r2 +0) > 27: (35) if r0 >= 0x3 goto pc+3 > 28: (67) r0 <<= 3 > 29: (0f) r0 += r1 > 30: (05) goto pc+1 > 31: (b7) r0 = 0 > > Cc: Rik van Riel <riel@xxxxxxxxxxx> > Cc: Johannes Weiner <hannes@xxxxxxxxxxx> > Signed-off-by: Andrii Nakryiko <andriin@xxxxxx> Acked-by: Song Liu <songliubraving@xxxxxx>