From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Borna Cafuk <borna.cafuk@sartura.hr>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, Luka Perkov <luka.perkov@sartura.hr>,
kpsingh@google.com
Subject: Re: HASH_OF_MAPS inner map allocation from BPF
Date: Mon, 07 Sep 2020 15:32:57 +0200 [thread overview]
Message-ID: <878sdlpv92.fsf@toke.dk> (raw)
In-Reply-To: <CAGeTCaWSSBJye72NCQW4N=XtsFx-rv-EEgTowTT3VEtus=pFtA@mail.gmail.com>
Borna Cafuk <borna.cafuk@sartura.hr> writes:
> On Sat, Sep 5, 2020 at 12:47 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
>>
>> On Fri, Sep 4, 2020 at 7:57 AM Borna Cafuk <borna.cafuk@sartura.hr> wrote:
>> >
>> > Hello everyone,
>> >
>> > Judging by [0], the inner maps in BPF_MAP_TYPE_HASH_OF_MAPS can only be created
>> > from the userspace. This seems quite limiting in regard to what can be done
>> > with them.
>> >
>> > Are there any plans to allow for creating the inner maps from BPF programs?
>> >
>> > [0] https://stackoverflow.com/a/63391528
>>
>> Did you ask that question or your use case is different?
>> Creating a new map for map_in_map from bpf prog can be implemented.
>> bpf_map_update_elem() is doing memory allocation for map elements.
>> In such a case calling this helper on map_in_map can, in theory, create a new
>> inner map and insert it into the outer map.
>
> No, it wasn't me who asked that question, but it seemed close enough to
> my issue. My use case calls for modifying the syscount example from BCC[1].
>
> 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
next prev parent reply other threads:[~2020-09-07 17:24 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 [this message]
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
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=878sdlpv92.fsf@toke.dk \
--to=toke@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=borna.cafuk@sartura.hr \
--cc=bpf@vger.kernel.org \
--cc=kpsingh@google.com \
--cc=luka.perkov@sartura.hr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox