On Thu, 1 Aug 2024 14:30:52 +0800 zhiguojiang <justinjiang@xxxxxxxx> wrote: > > Dumb question: why can't this be done in userspace? The exiting > > process does fork/exit and lets the child do all this asynchronous freeing? > The logic optimization for kernel releasing swap entries cannot be > implemented in userspace. The multiple exiting processes here own > their independent mm, rather than parent and child processes share the > same mm. Therefore, when the kernel executes multiple exiting process > simultaneously, they will definitely occupy multiple CPU core resources > to complete it. What I'm asking is why not change those userspace processes so that they fork off a child process which shares the MM (shared mm_struct) and then the original process exits, leaving the asynchronously-running child to clean up the MM resources.