Hi Fabian,

It should be done with userfaultfd. I have a WIP branch at https://gitlab.winehq.org/zhiyi/wine/-/tree/bug-23670-implement-write-copy-with-userfaultfd.
The writecopy part is working. However, the performance impact is a concern. Some games call VirtualQuery() tens of thousands of times and any slowdown
makes these games stutter. Also, Paul mentioned that we should implement making shared pages private and make it work alongside PAGE_WRITECOPY so that
it's both correct feature wise and performance wise. It needs more work.

As for why not using signals to track page faults for implementing WRITECOPY. There are a few issues with that approach. First, it's too slow. Second, signals
may be blocked.

Best Regards,
Zhiyi


On 9/29/24 01:55, Fabian Maurer wrote:
Hello,

I noticed that the ntdll WRITECOPY changes got mostly dropped from staging in
commit https://github.com/wine-staging/wine-staging/commit/
16dce521242b3f4a52cd2c8799ce6fe464fac83c

The current state even after multiple iterations, the whole
WRITECOPY implemenet needs differently.  Upstream will need to
do this.
As I understand it, the implementation marks WRITECOPY pages as read-only on
the unix side, handling the access violation and marking it as read-write
afterwards. (Correct me if I'm wrong)

What is wrong with the underlying concept, how should it be implemented
properly?

Regards,
Fabian Maurer