Messages in this thread | | | From | Song Liu <> | Subject | Re: [PATCH bpf-next v7 06/34] bpf: prepare for memcg-based memory accounting for bpf maps | Date | Fri, 20 Nov 2020 01:05:40 +0000 |
| |
> On Nov 19, 2020, at 9:37 AM, Roman Gushchin <guro@fb.com> wrote: > > In the absolute majority of cases if a process is making a kernel > allocation, it's memory cgroup is getting charged. > > Bpf maps can be updated from an interrupt context and in such > case there is no process which can be charged. It makes the memory > accounting of bpf maps non-trivial. > > Fortunately, after commit 4127c6504f25 ("mm: kmem: enable kernel > memcg accounting from interrupt contexts") and b87d8cefe43c > ("mm, memcg: rework remote charging API to support nesting") > it's finally possible. > > To do it, a pointer to the memory cgroup of the process, which created > the map, is saved, and this cgroup can be charged for all allocations > made from an interrupt context. This commit introduces 2 helpers: > bpf_map_kmalloc_node() and bpf_map_alloc_percpu(). They can be used in > the bpf code for accounted memory allocations, both in the process and > interrupt contexts. In the interrupt context they're using the saved > memory cgroup, otherwise the current cgroup is getting charged. > > Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
[...]
| |