Home > other >  Which mechanism was first introduced in Linux Kernel: clear_refs or userfaultfd
Which mechanism was first introduced in Linux Kernel: clear_refs or userfaultfd

Time:10-31

I am wondering which of the above mechanisms was the first to be introduced in Linux. The 2 of them are dirty bit tracking mechanisms.

The first is done via the /proc/clear_refs fs as follows: once the user writes "4" to /proc/$pid/clear_refs the kernel unset the dirty bit of all the pages of the process and at the next attempt to access those pages, a page fault is triggered and the dirty bit is reset (by the kernel) and then the user can go through the /proc/pagemap to collect the pages that have been accessed.

The second allows the user to handle the page fault himself: the user first asks the kernel to protect a given region in memory allocated via mmap; after what any attempt to access a page in that region generates a page fault for which the handling is transferred to the user who may, for example, ask the kernel to allow the access or deny it. So by this way, one does no longer need to go through the pagemap to know which pages have been accessed or not.

CodePudding user response:

From man 5 proc:

/proc/[pid]/clear_refs (since Linux 2.6.22)

And from man 2 userfaultfd:

VERSIONS
       The userfaultfd() system call first appeared in Linux 4.3.

So looks like /proc/[pid]/clear_refs is a lot older than userfaultfd.

  • Related