On 4/16/20 12:02 PM, Dave Hansen wrote: > On 4/16/20 9:34 AM, Claudio Imbrenda wrote: >>> Ahh, so this is *just* intended to precede I/O done on the page, when >>> a non-host entity is touching the memory? >> yep > OK, so we've got to do an action that precedes *all* I/O to a page. > That's not too bad. > > I still don't understand how this could work generally, though There > are lots of places where I/O is done to a page without either going > through __test_set_page_writeback() or gup() with FOLL_PIN set. > > sendfile() is probably the best example of this: > > fd = open("/normal/ext4/file", O_RDONLY); > sendfile(socket_fd, fd, &off, count); > > There's no gup in sight since the file doesn't have an address and it's > not being written to so there's no writeback. > > How does sendfile work? Did you manage to see if sendfile works (or any other operation that DMAs file-backed data without being preceded by a gup)? I suspect it's actually not that hard to fix. As long as you have a dma_ops for the devices in question either via dev->dma_ops or you add an s390 get_arch_vm_ops(), you can fix *all* the DMA sites, sendfile() included. BTW, device drivers do need to know how to use the DMA mapping API. If s390 has drivers that need to be updated, I think that's vastly preferable to incomplete hooks in core mm code.