On 24 Apr 22:09, David Hildenbrand wrote: > > > Let me try to see if we can get this done cleaner. > > > > > > One ugly part (in general here) is the custom page replacement in the > > > registration part. > > > > > > We are guaranteed to have a MAP_PRIVATE mapping. Instead of replacing > > > pages > > > ourselves (which we likely shouldn't do ...) ... maybe we could use > > > FAULT_FLAG_UNSHARE faults such that we will get an anonymous folio > > > populated. (like KSM does nowadays) > > > > > > Punching FOLL_PIN|FOLL_LONGTERM into GUP would achieve the same thing, but > > > using FOLL_WRITE would not work on many file systems. So maybe we have to > > > trigger an unsharing fault ourselves. > > ^ realizing that we already use FOLL_FORCE, so we can just use FOLL_WRITE to > break COW.
It was never clear to me why uprobes was not doing FOLL_WRITE in the first place, I must say. One issue here is that FOLL_FORCE|FOLL_WRITE is not implemented for hugetlb mappings. However this was also on my TODO and I have a draft patch that implements it. > > > > > > > That would do the page replacement for us and we "should" be able to > > > lookup > > > an anonymous folio that we can then just modify, like ptrace would. > > > > > > But then, there is also unregistration part, with weird conditional page > > > replacement. Zapping the anon page if the content matches the content of > > > the > > > original page is one thing. But why are we placing an existing anonymous > > > page by a new anonymous page when the content from the original page > > > differs > > > (but matches the one from the just copied page?)? > > > > > > I'll have to further think about that one. It's all a bit nasty. > > > > Sounds good to me. I am willing to help with the code when you have a > > plan or testing as you see fit. Let me know. > > I'm hacking on a redesign that removes the manual COW breaking logic and > *might* make it easier to integrate hugetlb. (very likely, but until I have > the redesign running I cannot promise anything :) ) > > I'll let you know once I have something ready so you could integrate the > hugetlb portion. Sounds good. -- Guillaume Morin <guilla...@morinfr.org>