# Re: \[PATCH v1 06/11\] mm: support GUP-triggered unsharing via FAULT\_FLAG\_UNSHARE (!hugetlb)

- From: Nadav Amit \<hidden\>
- Date: 2021-12-17 23:53:25 
- List: linux-doc
- Page: https://ratatoskr.run/linux-doc/2021/12/1612951
- Thread: https://ratatoskr.run/linux-mm/2021/12/1612167/t.md

```text

> On Dec 17, 2021, at 3:29 PM, David Hildenbrand [ref] wrote:
> 
> On 17.12.21 23:58, Linus Torvalds wrote:
>> 
>> And you can't even do the optimistic case without taking the lock,
>> because in your world, a COW that optimistically copies in the case of
>> a race condition is fundamentally *wrong* and buggy. Because in your
>> world-view, GUP and COW are very different and have different rules,
>> but you need things to be *exact*, and they aren’t.

I understand the discussion mainly revolves correctness, which is
obviously the most important property, but I would like to mention
that having transient get_page() calls causing unnecessary COWs can
cause hard-to-analyze and hard-to-avoid performance degradation. COW
means a page copy, a TLB flush and potentially a TLB shootdown, which
is the most painful, specifically on VMs.

So I think that any solution should be able to limit the cases/number
of unnecessary COW operations to be minimal.

```
