Re: [PATCH v7 1/2] mm: introduce process_mrelease system call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 5, 2021 at 11:40 PM Michal Hocko <mhocko@xxxxxxxx> wrote:
>
[...]
> I think you really want something like this:
>
>         if (flags)
>                 return -EINVAL;
>
>         pid = pidfd_get_pid(fd, &f_flags);
>         if (IS_ERR(pid))
>                 return PTR_ERR(pid);
>         task = get_pid_task(pid, PIDTYPE_PID);
>         if (!task) {
>                 ret = -ESRCH;
>                 goto put_pid;
>         }
>
>         /*
>          * Make sure to chose a thread which still has a reference to mm
>          * during the group exit
>          */
>         p = find_lock_task_mm(task);
>         if (!p) {
>                 ret = -ESRCH;
>                 goto put_task;
>         }
>
>         mm = task->mm;

mm = p->mm;

>         mmgrab(mm);
>         reap = true;
>         /* If the work has been done already, just exit with success */
>         if (test_bit(MMF_OOM_SKIP, &mm->flags)) {
>                 reap = false;
>         } else if (!task_will_free_mem(p)) {
>                 reap = false;
>                 ret = -EINVAL;
>         }
>         task_unlock(p);
>
>         if (!reap)
>                 goto dropmm;;
>
>         /* Do the work*/
>
>
> dropmm:
>         mmdrop(mm);
> put_task:
>         put_task(task);
> put_pid:
>         put_pid(pid);
>
>         return ret;
>
> --
> Michal Hocko
> SUSE Labs




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux