On Thu, Jul 07, 2022 at 03:41:11PM -0700, Alexei Starovoitov wrote: > On Tue, Jul 5, 2022 at 9:24 PM Roman Gushchin <roman.gushchin@xxxxxxxxx> wrote: > > > > Anyway, here is the patch for reparenting bpf maps: > > https://github.com/rgushchin/linux/commit/f57df8bb35770507a4624fe52216b6c14f39c50c > > > > I gonna post it to bpf@ after some testing. > > Please do. It looks good. > It needs #ifdef CONFIG_MEMCG_KMEM > because get_obj_cgroup_from_current() is undefined otherwise. > Ideally just adding a static inline to a .h ? Actually all call sites are already under CONFIG_MEMCG_KMEM. > > and > if (map->objcg) > memcg = get_mem_cgroup_from_objcg(map->objcg); > > or !NULL check inside get_mem_cgroup_from_objcg() > which would be better. Yes, you're right, as now we need to handle it specially. In the near future it won't be necessary. There are patches in mm-unstable which make objcg API useful outside of CONFIG_MEMCG_KMEM. In particular it means that objcg will be created for the root_mem_cgroup. So map->objcg can always point at a valid objcg and we will be able to drop this check. Will post an updated version shortly. Thanks!