dovetail vs. ipipe: COW-breaking in copy_pte_range
Hi Philippe,
a merge conflict in 5.4-stable requires me to look into [1]. It states:
Quoted 4 lines
Revisit: Further COW breaking in
copy_user_page()andcopy_pte_range()may be useless once__ipipe_disable_ondemand_mappings()has run for a co-kernel task, since all of its mappings have been populated, and unCOWed if applicable.
And if I look into the dovetail baseline commit, this logic is indeed gone. Did you revisit this and came to the conclusion that it can safely be dropped? Or did it take other changes in dovetail to make it obsolete? Would help to resolve [2] if we could simply drop it...
Thanks,
Jan
[1]
https://gitlab.denx.de/Xenomai/ipipe-noarch/-/commit/caa1b5261d0d27d0801ab9d41dfe39d648583a37
[2]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.4.y&id=2c25b951117857d43fdac01fe7bd3894514e6ecf
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 9 lines · Jan Kiszka
Hi Philippe,
a merge conflict in 5.4-stable requires me to look into [1]. It states:
Quoted 4 lines
Revisit: Further COW breaking in
copy_user_page()andcopy_pte_range()may be useless once__ipipe_disable_ondemand_mappings()has run for a co-kernel task, since all of its mappings have been populated, and unCOWed if applicable.
Quoted 5 lines
And if I look into the dovetail baseline commit, this logic is indeed gone. Did you revisit this and came to the conclusion that it can safely be dropped? Or did it take other changes in dovetail to make it obsolete? Would help to resolve [2] if we could simply drop it...
I dropped it from Dovetail because mlock already breaks COW for private mappings, shared ones cannot be COWed, so I don't see any reason to enforce this again.
Signature · 1 line
Philippe.
Quoted 18 lines · Philippe Gerum
Quoted 9 lines · Jan Kiszka
Hi Philippe,
a merge conflict in 5.4-stable requires me to look into [1]. It states:
Quoted 4 lines
Revisit: Further COW breaking in
copy_user_page()andcopy_pte_range()may be useless once__ipipe_disable_ondemand_mappings()has run for a co-kernel task, since all of its mappings have been populated, and unCOWed if applicable.Quoted 5 lines
And if I look into the dovetail baseline commit, this logic is indeed gone. Did you revisit this and came to the conclusion that it can safely be dropped? Or did it take other changes in dovetail to make it obsolete? Would help to resolve [2] if we could simply drop it...
Quoted 4 lines
I dropped it from Dovetail because mlock already breaks COW for private mappings, shared ones cannot be COWed, so I don't see any reason to enforce this again.
Were we always overly cautious with this in I-pipe, or did anything change along the kernels or nucleuses? I'm asking as I will have to write some good removal commit log for 4.19 as the merge conflict will bite us there as well.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 24 lines · Jan Kiszka
Quoted 18 lines · Philippe Gerum
Quoted 9 lines · Jan Kiszka
Hi Philippe,
a merge conflict in 5.4-stable requires me to look into [1]. It states:
Quoted 4 lines
Revisit: Further COW breaking in
copy_user_page()andcopy_pte_range()may be useless once__ipipe_disable_ondemand_mappings()has run for a co-kernel task, since all of its mappings have been populated, and unCOWed if applicable.Quoted 5 lines
And if I look into the dovetail baseline commit, this logic is indeed gone. Did you revisit this and came to the conclusion that it can safely be dropped? Or did it take other changes in dovetail to make it obsolete? Would help to resolve [2] if we could simply drop it...
Quoted 4 lines
I dropped it from Dovetail because mlock already breaks COW for private mappings, shared ones cannot be COWed, so I don't see any reason to enforce this again.
Quoted 5 lines
Were we always overly cautious with this in I-pipe, or did anything change along the kernels or nucleuses? I'm asking as I will have to write some good removal commit log for 4.19 as the merge conflict will bite us there as well.
We may expect mlock() to:
1- commit the data from any backing store to RAM
2- break COW if present
3- populate the PTEs
The hack from copy_pte_range() dates back to 2006 or so. IIRC, the reason was to ensure that any mapping duplicated from a parent process which has pinned its memory via an earlier call to __ipipe_disable_ondemand_mappings() would be immediately un-COWed upon fork() in the child process. On second thoughts, this is useless since the child process either:
- if it has to, explicitly attaches to the real-time core, which ends up calling mlock(), therefore causing these mappings to be un-COWed if need be. IOW, there is no inheritance of the Cobalt context at fork. Maybe at some point in time there was the assumption that such context might be shared between both processes somehow, which has been ruled out later on.
- the child process does not attach to the real-time core, in which case COW is a non-issue.
The reason to still have __ipipe_disable_ondemand_mappings() or force_commit_memory() is to make sure (3) actually happens for all regular pages the caller may use, which may not always be the case with mlock() (we need all these pages to be actually faulted in so that a minor fault is emulated via handle_mm_fault() right away). However, (1) and (2) are fully covered by mlock() already.
Executive summary: using belt and suspenders may be ok for peace of mind, but still slightly overkill on a diving suit.
Signature · 1 line
Philippe.
Quoted 63 lines · Philippe Gerum
Quoted 24 lines · Jan Kiszka
Quoted 18 lines · Philippe Gerum
Quoted 9 lines · Jan Kiszka
Hi Philippe,
a merge conflict in 5.4-stable requires me to look into [1]. It states:
Quoted 4 lines
Revisit: Further COW breaking in
copy_user_page()andcopy_pte_range()may be useless once__ipipe_disable_ondemand_mappings()has run for a co-kernel task, since all of its mappings have been populated, and unCOWed if applicable.Quoted 5 lines
And if I look into the dovetail baseline commit, this logic is indeed gone. Did you revisit this and came to the conclusion that it can safely be dropped? Or did it take other changes in dovetail to make it obsolete? Would help to resolve [2] if we could simply drop it...
Quoted 4 lines
I dropped it from Dovetail because mlock already breaks COW for private mappings, shared ones cannot be COWed, so I don't see any reason to enforce this again.
Quoted 5 lines
Were we always overly cautious with this in I-pipe, or did anything change along the kernels or nucleuses? I'm asking as I will have to write some good removal commit log for 4.19 as the merge conflict will bite us there as well.
We may expect
mlock()to:1- commit the data from any backing store to RAM
2- break COW if present
3- populate the PTEsThe hack from
copy_pte_range()dates back to 2006 or so. IIRC, the reason was to ensure that any mapping duplicated from a parent process which has pinned its memory via an earlier call to__ipipe_disable_ondemand_mappings()would be immediately un-COWed uponfork()in the child process. On second thoughts, this is useless since the child process either:- if it has to, explicitly attaches to the real-time core, which ends up calling
mlock(), therefore causing these mappings to be un-COWed if need be. IOW, there is no inheritance of the Cobalt context at fork. Maybe at some point in time there was the assumption that such context might be shared between both processes somehow, which has been ruled out later on.- the child process does not attach to the real-time core, in which case COW is a non-issue.
The reason to still have
__ipipe_disable_ondemand_mappings()orforce_commit_memory()is to make sure (3) actually happens for all regular pages the caller may use, which may not always be the case withmlock()(we need all these pages to be actually faulted in so that a minor fault is emulated viahandle_mm_fault()right away). However, (1) and (2) are fully covered bymlock()already.
Quoted 3 lines
Executive summary: using belt and suspenders may be ok for peace of mind, but still slightly overkill on a diving suit.
Makes perfect sense, thanks a lot. Will use that for a 4.19 commit and drop it from 5.4 from the beginning.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux