Re: [PATCH 1/1] bpftool: Allow referring to maps by its name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 15 Mar 2019 16:48:00 -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 15, 2019 at 07:41:35PM +0000, Quentin Monnet escreveu:
> > 2019-03-15 12:16 UTC-0700 ~ Jakub Kicinski <jakub.kicinski@xxxxxxxxxxxxx>  
> > > On Fri, 15 Mar 2019 15:41:41 -0300, Arnaldo Carvalho de Melo wrote:  
> > > > While developing 'perf trace' and looking at BPF maps it puts in place I
> > > > noticed that one needs to first use 'bpftool map' to lookup a map id to
> > > > then use 'bpftool map dump map id <map-id-looked-up>'.
> > > > 
> > > > This is needed because everytime we restart 'perf trace' the map IDs
> > > > gets changed so we need to do the ID lookup again.
> > > > 
> > > > To speed up this sequence, allow specifying just the map name, look up
> > > > its ID and then use the existing routines as if the user had provided
> > > > the map id.  
> > > 
> > > I can see how it could be useful for quick debug.  Names are not
> > > guaranteed to be unique, though, do you not care about potential
> > > duplicates?
> > >   
> > 
> > Jakub beat me to it by a few seconds :). I discussed possible workarounds on
> > that point with him though, so here are my two cents. I see two options:
> > first one would be to return the ids of, and then dump info about all maps
> > having that name. The second one would be to simply return an error if
> > duplicate names are found.
> > 
> > We agreed that returning an error if there are duplicates is probably the
> > best way to go, because dealing with several maps for anything else than
> > "bpftool map show" would be problematic (clearly, we don't want to update
> > all maps with a given name at once). Of course if you have other
> > suggestions, feel free to propose :).  
> 
> So, if there are dups, just tell that and print the ids, i.e. the
> following, for any 'bpf map' command that finds dups, except for this
> one:
> 
> [root@quaco ~]# bpftool map list pids_filtered
> 45: hash  name pids_filtered  flags 0x0
> 	key 4B  value 1B  max_entries 64  memlock 8192B
> 90: hash  name pids_filtered  flags 0x0
> 	key 4B  value 80B  max_entries 512  memlock do-the-mathB
> [root@quaco ~]#
> 
> I.e. if there are multiple 'pids_filtered' maps, the output for, say,
> 'dump' would be:
> 
> [root@quaco ~]# bpftool map dump pids_filtered
> There are multiple maps with this name, use 'bpftool map dump id NR' to disambiguate:
> -------------------------------------------------------------------------------------
> 45: hash  name pids_filtered  flags 0x0
> 	key 4B  value 1B  max_entries 64  memlock 8192B
> 90: hash  name pids_filtered  flags 0x0
> 	key 4B  value 80B  max_entries 512  memlock do-the-mathB
> [root@quaco ~]#

Yes, this looks good (modulo JSON output, which should probably be
just a single "error" value).

For simplicity I'd personally go for just always printing an error
if name is duplicated and not bother with listing the options.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux