[PATCH v2] bpf: support new commands BPF_MAP_*_BATCH

Eugene Syromiatnikov esyr at redhat.com
Wed Mar 25 02:07:31 UTC 2020


On Mon, Mar 23, 2020 at 07:42:56AM +0100, Paul Chaignon wrote:
> On Sun, Mar 08, 2020 at 11:11:55PM +0100, Eugene Syromiatnikov wrote:
> > On Sun, Mar 08, 2020 at 06:33:54PM +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.
> 
> [...]
> 
> > > +	PRINT_FIELD_ADDR64(", ", attr, keys);
> > > +	PRINT_FIELD_ADDR64(", ", attr, values);
> > 
> > > +	PRINT_FIELD_U(", ", attr, count);
> > 
> > This is in/out field for BPF_MAP_*_BATCH, so it has to be printed
> > both on entering and exiting.
> 
> What's the best way to handle this?  It looks like for accept(2), you
> only print the last two arguments (addr and addrlen) on exiting.  Should
> I do the same here?  In that case, should I simply add an exception to
> SYS_FUNC(bpf)?

For structure fields, it is commonly printed as "..., field=INVAL => OUTVAL}"
or "{field=INVAL} => {field=OUTVAL}" in cases where multiple out fields
or when non-last field is printed (see V4L2 ioctl, struct sched_attr, clone3
for examples).  I think it's easier to stick to the latter format.



More information about the Strace-devel mailing list