Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb)

From
Jason Gunthorpe <jgg@nvidia.com>
Date
2021-12-17 20:47:12
Also in
linux-kselftest, linux-mm, lkml
Reply to
Linus Torvalds, 2021-12-17
On Fri, Dec 17, 2021 at 12:36:43PM -0800, Linus Torvalds wrote:
quoted
5. Take a R/O pin (RDMA, VFIO, ...)
-> refcount > 1

6. memset(mem, 0xff, pagesize);
-> Write fault -> COW
I do not believe this is actually a bug.

You asked for a R/O pin, and you got one.

Then somebody else modified that page, and you got exactly what you
asked for - a COW event. The original R/O pin has the original page
that it asked for, and can read it just fine.
To remind all, the GUP users, like RDMA, VFIO use
FOLL_FORCE|FOLL_WRITE to get a 'r/o pin' specifically because of the
COW breaking the coherence. In these case 'r/o pin' does not mean
"snapshot the data", but its only a promise not to write to the pages
and still desires coherence with the memory map.

Eg in RDMA we know of apps asking for a R/O pin of something in .bss
then filling that something with data finally doing the actual
DMA. Breaking COW after pin breaks those apps.

The above #5 can occur for O_DIRECT read and in that case the
'snapshot the data' is perfectly fine as racing the COW with the
O_DIRECT read just resolves the race toward the read() direction.

IIRC there is some other scenario that motivated this patch?

Jason
Thread (137 messages) 137 messages, 11 authors, last reply 2022-01-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help