How to know whether a copy-on-write page is an actual copy?

前端 未结 6 751
感情败类
感情败类 2020-12-29 13:49

When I create a copy-on-write mapping (a MAP_PRIVATE) using mmap, then some pages of this mapping will be copied as soon as I write to specific addresses. At a certain point

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 14:35

    I don't recall such API being exported. Why do you want to do such a thing (What is the root of the problem you're solving?)

    You might want to take a look at /proc/[pid]/smaps (which provides a somewhat detailed statistic of pages used/copied/stored).

    Again, why would you want to do that? If you're sure this approach is the only one (usually, virtual memory is used and forgot about), you might want to consider writing a kernel module that handles such functionality.

提交回复
热议问题