android_packages_modules_Co.../bpf
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Maciej Żenczykowski 12f752aae9 bpf/progs/netd: make 'blocked_ports_map' mmapable
Perhaps not the best example, but virtually free considering
a bitmap of 64K bits is 8KiB no matter what.

Kernel will allocate:
  1 page for internal metadata (rounded up to a full page)
  N pages rounded up from array size, which is:
      number of elements (65536 bits / 64 bits per u64) = 1024
    * element size (u64 rounded up to a multiple of 8) = 8
    = 8192

This rounding up is unique to *mmapable* arrays.

thus on 4KiB page size: 12 KiB - waste is at most a few (<4) KiB
and on 16KiB page size: 32 KiB - which isn't great, but well that's 16KiB...
(presumably 16KiB is being used on devices with a lot of ram,
 where performance matters more than a little ram waste)

Note: AFAICT a kernel bpf program R/W map cannot be mapped R/O
into userspace, as the permissions on the page mapping would conflict.

(and obviously you cannot map R/W if you have only R/O access)

I'm not sure if this is architecture specific,
or simply an implementation limitation, but it is what I observed.

I think it's likely a missing kernel feature (even on 6.12)...

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I609ae61e17917ff441cac10a9b29af3fcacb53c5
2025-08-07 15:54:01 -07:00
..
dns_helper bpf/progs/netd: remove DATA_SAVER_ENABLED_MAP_SIZE constant 2025-07-15 12:20:24 -07:00
headers Split bpf_helpers.h and bpf_map_def.h from bpf_headers 2025-06-13 13:07:43 +09:00
loader bpf: support for mmapable bpf map array (5.10+) 2025-08-07 15:53:42 -07:00
netd mdnsd_netbpfload: reduce spam on failure 2025-04-08 12:45:49 -07:00
progs bpf/progs/netd: make 'blocked_ports_map' mmapable 2025-08-07 15:54:01 -07:00
syscall_wrappers NetBpfLoad: workaround for Xiaomi kernel uapi bug 2025-06-10 02:43:28 -07:00
tests/mts NetBpfLoad: create/populate/pin kernel bugs bpf array 2025-06-17 01:49:23 -07:00