Thread (5 messages) flat view 5 messages, 3 authors, 2021-07-12

Re: [PATCH 1/1] mm: introduce process_reap system call

From: Suren Baghdasaryan <surenb@google.com>
Date: 2021-07-08 06:06:12
Also in: linux-mm, lkml

On Wed, Jul 7, 2021 at 10:41 PM Florian Weimer [off-list ref] wrote:
* Suren Baghdasaryan:
quoted
On Wed, Jul 7, 2021 at 2:47 AM Florian Weimer [off-list ref] wrote:
quoted
* Suren Baghdasaryan:
quoted
The API is as follows,

          int process_reap(int pidfd, unsigned int flags);

        DESCRIPTION
          The process_reap() system call is used to free the memory of a
          dying process.

          The pidfd selects the process referred to by the PID file
          descriptor.
          (See pidofd_open(2) for further information)

          The flags argument is reserved for future use; currently, this
          argument must be specified as 0.

        RETURN VALUE
          On success, process_reap() returns 0. On error, -1 is returned
          and errno is set to indicate the error.
I think the manual page should mention what it means for a process to be
“dying”, and how to move a process to this state.
Thanks for the suggestion, Florian! Would replacing "dying process"
with "process which was sent a SIGKILL signal" be sufficient?
That explains very clearly the requirement, but it raises the question
why this isn't an si_code flag for rt_sigqueueinfo, reusing the existing
system call.
I think you are suggesting to use sigqueue() to deliver the signal and
perform the reaping when a special value accompanies it. This would be
somewhat similar to my early suggestion to use a flag in
pidfd_send_signal() (see:
https://lore.kernel.org/patchwork/patch/1060407) to implement memory
reaping which has another advantage of operation on PIDFDs instead of
PIDs which can be recycled.
kill()/pidfd_send_signal()/sigqueue() are supposed to deliver the
signal and return without blocking. Changing that behavior was
considered unacceptable in these discussions. On the other hand using
some kthread to do the reaping asynchronously has its disadvantages:
userspace can't control the priority and cpu affinity of the thread
doing the reaping and this work is not charged towards the caller. In
the end a separate blocking syscall was deemed appropriate for this
operation. More details can be found in the links I posted in the
description of the patch.
Thanks,
Florian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help