From: David Vernet <void@manifault.com>
To: lsf-pc@lists.linux-foundation.org
Cc: bpf@vger.kernel.org
Subject: Mapping local-storage maps into user space
Date: Thu, 26 Jan 2023 13:11:17 -0600 [thread overview]
Message-ID: <Y9LQVU2uz9SzYARP@maniforge> (raw)
Hi everyone,
Another proposal from me for LSF/MM/BPF, and the last one for the time
being. I'd like to discuss enabling local-storage maps (e.g.
BPF_MAP_TYPE_TASK_STORAGE and BPF_MAP_TYPE_CGRP_STORAGE) to be r/o
mapped directly into user space. This would allow for quick lookups of
per-object state from user space, similar to how we allow it for
BPF_MAP_TYPE_ARRAY, without having to do something like either of the
following:
- Allocating a statically sized BPF_MAP_TYPE_ARRAY which is >= the # of
possible local-storage elements, which is likely wasteful in terms of
memory, and which isn't easy to iterate over.
- Use something like https://docs.kernel.org/bpf/bpf_iterators.html to
iterate over tasks or cgroups, and collect information for each which
is then dumped to user space. This would probably work, but it's not
terribly performant in that it requires copying memory, trapping into
the kernel, and full iteration even when it's only necessary to look
up e.g. a single element.
Designing and implementing this would be pretty non-trivial. We'd have
to probably do a few things:
1. Write an allocator that dynamically allocates statically sized
local-storage entries for local-storage maps, and populates them into
pages which are mapped into user space.
2. Come up with some idr-like mechanism for mapping a local-storage
object to an index into the mapping. For example, mapping a task with
global pid 12345 to BPF_MAP_TYPE_TASK_STORAGE index 5, and providing
ergonomic and safe ways to update these entries in the kernel and
communicate them to user space.
3. Related to point 1 above, come up with some way to dynamically extend
the user space mapping as more local-storage elements are added. We
could potentially reserve a statically sized VA range and map all
unused VA pages to the zero page, or instead possibly just leave them
unmapped until they're actually needed.
There are a lot of open questions, but I think it could be very useful
if we can make it work. Let me know what you all think.
Thanks,
David
next reply other threads:[~2023-01-26 19:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 19:11 David Vernet [this message]
2023-01-27 0:42 ` Mapping local-storage maps into user space Hao Luo
2023-02-07 18:25 ` David Vernet
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=Y9LQVU2uz9SzYARP@maniforge \
--to=void@manifault.com \
--cc=bpf@vger.kernel.org \
--cc=lsf-pc@lists.linux-foundation.org \
/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