You will see dbgln output like the following, note how each page has 2 page faults instead of 1:
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[0] at V0x0000000000010000
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[0] at V0x0000000000010000
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[1] at V0x0000000000011000
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[1] at V0x0000000000011000
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[2] at V0x0000000000012000
65.756 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[2] at V0x0000000000012000
65.760 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[3] at V0x0000000000013000
65.760 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[3] at V0x0000000000013000
65.760 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[4] at V0x0000000000014000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[4] at V0x0000000000014000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[5] at V0x0000000000015000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[5] at V0x0000000000015000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[6] at V0x0000000000016000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[6] at V0x0000000000016000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[7] at V0x0000000000017000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[7] at V0x0000000000017000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[8] at V0x0000000000018000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[8] at V0x0000000000018000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[9] at V0x0000000000019000
65.764 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[9] at V0x0000000000019000
65.772 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[10] at V0x000000000001a000
65.772 [#0 test-redundant-fault(47:47)]: PV(cow) fault in Region(0x0000002000fbc940)[10] at V0x000000000001a000
If you create an anonymous mmap, and then fork, any writes you make to that mmap will cause 2 page faults instead of 1.
How to reproduce: Apply the following diff, then run
test-redundant-fault
from the shelltest-redundant-fault
simply creates an anonymous mmap, forks, and then writes to each page of the mmapYou will see dbgln output like the following, note how each page has 2 page faults instead of 1: