Re: [PATCH v2] memcg: allow exiting tasks to write back data to swap

From: Rik van Riel
Date: Tue Jan 14 2025 - 12:12:15 EST


On Tue, 2025-01-14 at 18:00 +0100, Michal Hocko wrote:
> On Tue 14-01-25 11:51:18, Rik van Riel wrote:
> > On Tue, 2025-01-14 at 17:46 +0100, Michal Hocko wrote:
> > > On Tue 14-01-25 11:09:55, Johannes Weiner wrote:
> > >
> > > > charge_memcg
> > > > mem_cgroup_swapin_charge_folio
> > > > __read_swap_cache_async
> > > > swapin_readahead
> > > > do_swap_page
> > > > handle_mm_fault
> > > > do_user_addr_fault
> > > > exc_page_fault
> > > > asm_exc_page_fault
> > > > __get_user
> > >
> > > All the way here and return the failure to futex_cleanup which
> > > doesn't
> > > retry __get_user on the failure AFAICS (exit_robust_list). But I
> > > might
> > > be missing something, it's been quite some time since I've looked
> > > into
> > > futex code.
> >
> > Can you explain how -ENOMEM would get propagated down
> > past the page fault handler?
> >
> > This isn't get_user_pages(), which can just pass
> > -ENOMEM on to the caller.
> >
> > If there is code to pass -ENOMEM on past the page
> > fault exception handler, I have not been able to
> > find it. How does this work?
>
> This might be me misunderstading get_user machinery but doesn't it
> return a failure on PF handler returing ENOMEM?

I believe __get_user simply does a memcpy, and ends
up in the page fault handler.

It does not access userspace explicitly like we do
with functions like get_user_pages.

--
All Rights Reversed.