On Mon 01-07-19 22:04:22, Tetsuo Handa wrote: > On 2019/07/01 20:17, Michal Hocko wrote: > > On Sat 29-06-19 20:24:34, Tetsuo Handa wrote: > >> Since mpol_put_task_policy() in do_exit() sets mempolicy = NULL, > >> mempolicy_nodemask_intersects() considers exited threads (e.g. a process > >> with dying leader and live threads) as eligible. But it is possible that > >> all of live threads are still ineligible. > >> > >> Since has_intersects_mems_allowed() returns true as soon as one of threads > >> is considered eligible, mempolicy_nodemask_intersects() needs to consider > >> exited threads as ineligible. Since exit_mm() in do_exit() sets mm = NULL > >> before mpol_put_task_policy() sets mempolicy = NULL, we can exclude exited > >> threads by checking whether mm is NULL. > > > > Ok, this makes sense. For this change > > Acked-by: Michal Hocko <mhocko@xxxxxxxx> > > > > But I realized that this patch was too optimistic. We need to wait for mm-less > threads until MMF_OOM_SKIP is set if the process was already an OOM victim. If the process is an oom victim then _all_ threads are so as well because that is the address space property. And we already do check that before reaching oom_badness IIRC. So what is the actual problem you are trying to solve here? > If > we fail to allow the process to reach MMF_OOM_SKIP test, the process will be > ignored by the OOM killer as soon as all threads pass mm = NULL at exit_mm(), for > has_intersects_mems_allowed() returns false unless MPOL_{BIND,INTERLEAVE} is used. > > Well, the problem is that exited threads prematurely set mempolicy = NULL. > Since bitmap memory for cpuset_mems_allowed_intersects() path is freed when > __put_task_struct() is called, mempolicy memory for mempolicy_nodemask_intersects() > path should be freed as well when __put_task_struct() is called? I am sorry but I have hard time understanding what is the actual user visible problem here. -- Michal Hocko SUSE Labs