On 08.09.25 17:35, Lorenzo Stoakes wrote:
On Mon, Sep 08, 2025 at 05:07:57PM +0200, David Hildenbrand wrote:
On 08.09.25 16:47, Lorenzo Stoakes wrote:
On Mon, Sep 08, 2025 at 11:20:11AM -0300, Jason Gunthorpe wrote:
On Mon, Sep 08, 2025 at 03:09:43PM +0100, Lorenzo Stoakes wrote:
Perhaps
!vma_desc_cowable()
Is what many drivers are really trying to assert.
Well no, because:
static inline bool is_cow_mapping(vm_flags_t flags)
{
return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
}
Read-only means !CoW.
What drivers want when they check SHARED is to prevent COW. It is COW
that causes problems for whatever the driver is doing, so calling the
helper cowable and making the test actually right for is a good thing.
COW of this VMA, and no possibilty to remap/mprotect/fork/etc it into
something that is COW in future.
But you can't do that if !VM_MAYWRITE.
I mean probably the driver's just wrong and should use is_cow_mapping() tbh.
Drivers have commonly various things with VM_SHARED to establish !COW,
but if that isn't actually right then lets fix it to be clear and
correct.
I think we need to be cautious of scope here :) I don't want to accidentally
break things this way.
OK I think a sensible way forward - How about I add desc_is_cowable() or
vma_desc_cowable() and only set this if I'm confident it's correct?
I'll note that the naming is bad.
Why?
Because the vma_desc is not cowable. The underlying mapping maybe is.
Right, but the vma_desc desribes a VMA being set up.
I mean is_cow_mapping(desc->vm_flags) isn't too egregious anyway, so maybe
just use that for that case?
Yes, I don't think we would need another wrapper.
--
Cheers
David / dhildenb