Hi, Alistair, On Wed, Sep 15, 2021 at 12:25:07PM +1000, Alistair Popple wrote: > On Thursday, 9 September 2021 2:36:28 AM AEST Peter Xu wrote: > > Firstly, the comment in zap_pte_range() is misleading because it checks against > > details rather than check_mappings, so it's against what the code did. > > > > Meanwhile, there's no explicit reason why passing in the details pointer should > > mean to skip all swap entries. New user of zap_details could very possibly > > miss this fact if they don't read deep until zap_pte_range() because there's no > > comment at zap_details talking about it at all, so swap entries could be > > erroneously skipped without being noticed. > > > > This partly reverts 3e8715fdc03e ("mm: drop zap_details::check_swap_entries"), > > but introduce ZAP_FLAG_SKIP_SWAP flag, which means the opposite of previous > > "details" parameter: the caller should explicitly set this to skip swap > > entries, otherwise swap entries will always be considered (which should still > > be the major case here). > > > > We may want to look into when exactly we need ZAP_FLAG_SKIP_SWAP and we should > > have it in a synchronous manner, e.g., currently even if ZAP_FLAG_SKIP_SWAP is > > set we'll still look into swap pmds no matter what. But that should be a > > separate effort of this patch. > > I didn't really follow what you mean by "synchronous" here, although the > explanation about pmds makes sense so it's probably just terminology. Yes, maybe I should use "aligned manner", or please suggest anything that sounds better; sorry for my awkward English. > > > The flag introduced in this patch will be a preparation for more bits defined > > in the future, e.g., for a new bit in flag to show whether to persist the > > upcoming uffd-wp bit in pgtable entries. > > That's kind of the problem. The patch itself looks correct to me however as > mentioned it is mostly reverting a previous cleanup and it's hard to tell why > that's justified without the subsequent patches. Perhaps it makes the usage of > zap_details a bit clearer, but a comment also would with less code. > > I know you want to try and shrink the uffd-wp series but I think this patch > might be easier to review if it was included as part of that series. I posted it because I think it's suitable to have it even without uffd-wp. I tried to explain it above on two things this patch wanted to fix: Firstly the comment is wrong; we've moved back and forth on changing the zap_details flags but the comment is not changing along the way and it's not matching the code right now. Secondly I do think we should have a flag showing explicit willingness to skip swap entries. Yes, uffd-wp is the planned new one, but my point is anyone who will introduce a new user of zap_details pointer could overlook this fact. The new flag helps us to make sure someone will at least read the flags and know what'll happen with it. For the 2nd reasoning, I also explicitly CCed Kirill too, so Kirill can provide any comment if he disagrees. For now, I still think we should keep having such a flag otherwise it could be error-prone. Could you buy-in above reasoning? Basically above is what I wanted to express in my commit message. I hope that can justify that this patch (even if extremly simple) can still be considered as acceptable upstream even without uffd-wp series. If you still insist on this patch not suitable for standalone merging and especially if some other reviewer would think the same, I can move it back to uffd-wp series for sure. Then I'll repost this series with 4 patches only. In all cases, thanks for looking at the series. -- Peter Xu