Re: [PATCH 14/19] mm: Introduce a cgroup for pinned memory
From: Tejun Heo
Date: Tue Feb 21 2023 - 11:51:55 EST
Hello,
On Thu, Feb 16, 2023 at 08:45:38AM -0400, Jason Gunthorpe wrote:
> On Thu, Feb 16, 2023 at 09:04:03AM +0100, Michal Hocko wrote:
>
> > > In most cases the ownship traces back to a file descriptor. When the
> > > file is closed the pin goes away.
> >
> > This assumes a specific use of {un}pin_user_page*, right? IIUC the
> > cgroup charging is meant to be used from vm_account but that doesn't
> > really tell anything about the lifetime nor the ownership. Maybe this is
> > just a matter of documentation update...
>
> Yes documentation.
>
> > > > The interface itself doesn't talk about
> > > > anything like that and so it seems perfectly fine to unpin from a
> > > > completely different context then pinning.
> > >
> > > Yes, concievably the close of the FD can be in a totally different
> > > process with a different cgroup.
> >
> > Wouldn't you get an unbalanced charges then? How can admin recover that
> > situation?
>
> No, the approach in this patch series captures the cgroup that was
> charged and stores it in the FD until uncharge.
>
> This is the same as we do today for rlimit. The user/process that is
> charged is captured and the uncharge always applies to user/process
> that was charged, not the user/process that happens to be associated
> with the uncharging context.
>
> cgroup just add another option so it is user/process/cgroup that can
> hold the charge.
>
> It is conceptually similar to how each struct page has the memcg that
> its allocation was charged to - we just record this in the FD not the
> page.
I don't have a lot of context here but it looks like the problem here is
that the newly proposed controller is introducing an ownership discrepancy.
If a memory which is pinned by a cgroup is to be charged to the owner of the
fd, the memory which isn't pinned should be charged to the memcg of the same
cgroup, right? It makes little sense to me to separate the owner of the
memory page and the pinner of it. They should be one and the same.
Alistair, can you please elaborate how these pages are allocated, charged
and used?
Thanks.
--
tejun