All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Quentin Monnet <quentin.monnet@netronome.com>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Song Liu <songliubraving@fb.com>,
	Stanislav Fomichev <sdf@google.com>, Yonghong Song <yhs@fb.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 1/1] bpftool: Allow referring to maps by its name
Date: Fri, 15 Mar 2019 16:48:00 -0300	[thread overview]
Message-ID: <20190315194800.GA22548@kernel.org> (raw)
In-Reply-To: <9f6fefe5-0b9f-6257-4e84-19759dd72ab4@netronome.com>

Em Fri, Mar 15, 2019 at 07:41:35PM +0000, Quentin Monnet escreveu:
> 2019-03-15 12:16 UTC-0700 ~ Jakub Kicinski <jakub.kicinski@netronome.com>
> > 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 ~]#

- Arnaldo

  reply	other threads:[~2019-03-15 19:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 18:41 [PATCH 1/1] bpftool: Allow referring to maps by its name Arnaldo Carvalho de Melo
2019-03-15 19:16 ` Jakub Kicinski
2019-03-15 19:41   ` Quentin Monnet
2019-03-15 19:48     ` Arnaldo Carvalho de Melo [this message]
2019-03-15 20:25       ` Jakub Kicinski
2019-03-15 19:51   ` Arnaldo Carvalho de Melo
2019-03-15 20:18     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190315194800.GA22548@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=namhyung@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=quentin.monnet@netronome.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.