[PATCH 4/4] bpf: support new commands BPF_MAP_*_BATCH

Paul Chaignon paul.chaignon at gmail.com
Sun Mar 8 17:42:51 UTC 2020


On Thu, Mar 05, 2020 at 03:08:46AM +0300, Dmitry V. Levin wrote:
> On Sun, Feb 23, 2020 at 11:13:36AM +0100, Paul Chaignon wrote:
> > * xlat/bpf_commands.in (BPF_MAP_LOOKUP_BATCH): New constant introduced
> > by Linux commit v5.6-rc1~151^2~46^2~23^2~7.
> > (BPF_MAP_LOOKUP_AND_DELETE_BATCH): New constant introduced by Linux
> > commit v5.6-rc1~151^2~46^2~23^2~4.
> > (BPF_MAP_UPDATE_BATCH, BPF_MAP_DELETE_BATCH): New constants introduced
> > by Linux commit v5.6-rc1~151^2~46^2~23^2~6.
> > * bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_BATCH),
> > BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_AND_DELETE_BATCH),
> > BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_BATCH),
> > BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_BATCH)): Decode the new commands.
> > * bpf_attr.h (BPF_MAP_LOOKUP_BATCH_struct,
> > BPF_MAP_LOOKUP_AND_DELETE_BATCH_struct, BPF_MAP_UPDATE_BATCH_struct,
> > BPF_MAP_DELETE_BATCH_struct): New structs introduced by Linux commit
> > v5.6-rc1~151^2~46^2~23^2~7.
> > * NEWS: Mention this.
> > * tests/bpf.c (BPF_MAP_LOOKUP_BATCH_checks): Tests for the new commands.
> > 
> > Signed-off-by: Paul Chaignon <paul.chaignon at gmail.com>

[...]

> > diff --git a/bpf_attr.h b/bpf_attr.h
> > index e4826ec0..db5cb6c9 100644
> > --- a/bpf_attr.h
> > +++ b/bpf_attr.h
> > @@ -360,4 +360,28 @@ struct bpf_prog_info_struct {
> >  	sizeof(struct bpf_prog_info_struct)
> >  # define expected_bpf_prog_info_struct_size 208
> >  
> > +struct BPF_MAP_LOOKUP_BATCH_struct /* batch */ {
> > +	uint64_t ATTRIBUTE_ALIGNED(8) in_batch;
> > +	uint64_t ATTRIBUTE_ALIGNED(8) out_batch;
> > +	uint64_t ATTRIBUTE_ALIGNED(8) keys;
> > +	uint64_t ATTRIBUTE_ALIGNED(8) values;
> > +	uint32_t count;
> > +	uint32_t map_fd;
> > +	uint64_t elem_flags;
> > +	uint64_t flags;
> > +};
> 
> There is a comment in the beginning of bpf_attr.h file:
> 
> /*
>  * The policy is that all fields of type uint64_t in this header file
>  * must have ATTRIBUTE_ALIGNED(8).
>  *
>  * This should not cause any contradictions with <linux/bpf.h>
>  * unless the latter is buggy.
>  *
>  * By word "buggy" I mean containing such changes as Linux kernel commit
>  * v4.16-rc1~123^2~109^2~5^2~4.
>  */

Thanks!  I sent an update patch.

Paul


More information about the Strace-devel mailing list