On Tue, Sep 27, 2022 at 05:27:45PM +0000, Nadav Amit wrote: > On Sep 27, 2022, at 9:29 AM, Chih-En Lin <shiyn.lin@xxxxxxxxx> wrote: > > > Add a new sysctl vm.cow_pte to set MMF_COW_PTE_READY flag for enabling > > copy-on-write (COW) to the PTE page table during the next time of fork. > > > > Since it has a time gap between using the sysctl to enable the COW PTE > > and doing the fork, we use two states to determine the task that wants > > to do COW PTE or already doing it. > > I don’t get why it is needed in general and certainly why sysctl controls > this behavior. > > IIUC, it sounds that you want prctl and not sysctl for such control. But > clearly you think that this control is needed because there is a tradeoff. > Please explain the tradeoff and how users are expected to make a decision > whether to turn the flag or not. > If applying COW to the page table, it will has a significantly change to kernel, this is why I think it uses the sysctl at first. But, prctl might be better a choice. For the tradeoff. Since, in some cases (like executing the command in the terminal), enabling COW to page table only will increase the overhead due to the page fault (break COW). It doesn't have any benefit from the COW mechanism. So, we let the users decide which process will enable COW page table. The expected user usually will be the process that requires a lot of memory and want to create a new process for an isolated environment. (e.g., fuzzer, container, etc) So, expand COW to page table may improves the startup time and memory usage (on-demand allocate memory). Thanks, Chih-En Lin