All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borna Cafuk <borna.cafuk@sartura.hr>
To: KP Singh <kpsingh@google.com>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
	bpf <bpf@vger.kernel.org>, "Luka Perkov" <luka.perkov@sartura.hr>
Subject: Re: HASH_OF_MAPS inner map allocation from BPF
Date: Thu, 10 Sep 2020 12:11:00 +0200	[thread overview]
Message-ID: <CAGeTCaXOT0Nq=6m39Xn7NNP+Bz+iOdH8tR8ZKQ3jMibmgMtxew@mail.gmail.com> (raw)
In-Reply-To: <CAFLU3KteR+snvWpth3PBoQARTtpeBhEEVWH+a2bg0y=cxR81MQ@mail.gmail.com>

On Wed, Sep 9, 2020 at 12:36 PM KP Singh <kpsingh@google.com> wrote:
>
> On Wed, Sep 9, 2020 at 12:24 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> >
> > Borna Cafuk <borna.cafuk@sartura.hr> writes:
> >
> > > On Mon, Sep 7, 2020 at 3:33 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> > >>
> > >> Borna Cafuk <borna.cafuk@sartura.hr> writes:
> > >>
> > >> > On Sat, Sep 5, 2020 at 12:47 AM Alexei Starovoitov
> > >> > <alexei.starovoitov@gmail.com> wrote:
>
> [...]
>
> > >> >
> > >> > The idea is to have an outer map where the keys are PIDs, and inner maps where
> > >> > the keys are system call numbers. This would enable tracking the number of
> > >> > syscalls made by each process and the makeup of those calls for all processes
> > >> > simultaneously.
> > >> >
> > >> > [1] https://github.com/iovisor/bcc/blob/master/libbpf-tools/syscount.bpf.c
> > >>
> > >> Well, if you just want to count, map-in-map seems a bit overkill? You
> > >> could just do:
> > >>
> > >> struct {
> > >>   u32 pid;
> > >>   u32 syscall;
> > >> } map_key;
> > >>
> > >> and use that?
> > >>
> > >> -Toke
> > >>
> > >
> > > I have considered that, but maps in maps seem better for when I need to get the
> > > data about a single process's syscalls: It requires reading only one of the
> > > inner maps in its entirety. If I have a composite key like that, I don't see
> > > any way, other than:
> > >  * either iterating through all the possible keys for a process
> > >    (i.e. over all syscalls) and looking them up in the map, or
> > >  * iterating over all entries in the map and filtering them.
> > >
> > > Looking at it again, the first option does not seem _that_ bad,
> >
> > You could even use BPF_MAP_LOOKUP_BATCH to do this in one operation, I
> > suppose...
> >
> > > but just iterating over one (inner) map would be easier to fit into
> > > our use-case.
> >
> > ...but yeah, I see what you mean. Well, maybe BPF local storage per
> > process would also be a nice fit here?

Thank you for the insight.

>
> Yes, task local storage does seem like a good fit and is the next one I was
> thinking of implementing.
>
> - KP

I'm looking forward to the patches.

>
> >
> > -Toke
> >

      reply	other threads:[~2020-09-10 10:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 14:56 HASH_OF_MAPS inner map allocation from BPF Borna Cafuk
2020-09-04 22:47 ` Alexei Starovoitov
     [not found]   ` <CAFLU3KstRTXs3nwyE8uQY7q9k-sRr1yKCtOQX3gMq3nsxnwHXw@mail.gmail.com>
2020-09-05 14:57     ` KP Singh
2020-09-07 13:13   ` Borna Cafuk
2020-09-07 13:32     ` Toke Høiland-Jørgensen
2020-09-09  9:49       ` Borna Cafuk
2020-09-09 10:24         ` Toke Høiland-Jørgensen
2020-09-09 10:35           ` KP Singh
2020-09-10 10:11             ` Borna Cafuk [this message]

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='CAGeTCaXOT0Nq=6m39Xn7NNP+Bz+iOdH8tR8ZKQ3jMibmgMtxew@mail.gmail.com' \
    --to=borna.cafuk@sartura.hr \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=kpsingh@google.com \
    --cc=luka.perkov@sartura.hr \
    --cc=toke@redhat.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.