Skip to contentSkip to conversation

page_mkwrite vs pte dirty race in fb_defio

DISCUSSION Nick Piggin 2 participants 4 messages May 25, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

I couldn't find where this patch (49bbd815fd8) was discussed, so I'll make my own thread. Adding a few lists to cc because it might be of interest to driver and filesystem writers.

The old ->page_mkwrite calling convention was causing problems exactly because of this race, and we solved it by allowing page_mkwrite to return with the page locked, and the lock will be held until the pte is marked dirty. See commit b827e496c893de0c0f142abfaeb8730a2fd6b37f.

I hope that should provide a more elegant solution to your problem. I would really like you to take a look at that, because we already have filesystem code (NFS) relying on it, and more code we have relying on this synchronization, the more chance we would find a subtle problem with it (also it should be just nicer).

Thanks,
Nick

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

Hi,

Quoted 6 lines · Nick Piggin

Hi,

I couldn't find where this patch (49bbd815fd8) was discussed, so I'll make my own thread. Adding a few lists to cc because it might be of interest to driver and filesystem writers.

The original thread can be found here:
http://marc.info/?l=linux-fbdev&m7369791432181

Quoted 5 lines

The old ->page_mkwrite calling convention was causing problems exactly because of this race, and we solved it by allowing page_mkwrite to return with the page locked, and the lock will be held until the pte is marked dirty. See commit b827e496c893de0c0f142abfaeb8730a2fd6b37f.

Ah, didn't know about that. Thanks for the pointer.

Quoted 6 lines

I hope that should provide a more elegant solution to your problem. I would really like you to take a look at that, because we already have filesystem code (NFS) relying on it, and more code we have relying on this synchronization, the more chance we would find a subtle problem with it (also it should be just nicer).

So if I undestand it correctly, using the "new" calling convention I should just lock the page on fb_deferred_io_mkwrite() and return VM_FAULT_LOCKED to fix the described race for fb_defio.

Quoted 3 lines

Thanks,
Nick

Thanks,
Albert

#2 lore raw
Quoted 5 lines · Albert Herranz

Hi,

Quoted 2 lines · Nick Piggin

Hi,

Quoted 7 lines
Quoted 4 lines

I couldn't find where this patch (49bbd815fd8) was discussed, so I'll make my own thread. Adding a few lists to cc because it might be of interest to driver and filesystem writers.

The original thread can be found here:
http://marc.info/?l=linux-fbdev&m7369791432181

Thanks.

Quoted 8 lines
Quoted 5 lines

The old ->page_mkwrite calling convention was causing problems exactly because of this race, and we solved it by allowing page_mkwrite to return with the page locked, and the lock will be held until the pte is marked dirty. See commit b827e496c893de0c0f142abfaeb8730a2fd6b37f.

Ah, didn't know about that. Thanks for the pointer.

Quoted 8 lines
Quoted 6 lines

I hope that should provide a more elegant solution to your problem. I would really like you to take a look at that, because we already have filesystem code (NFS) relying on it, and more code we have relying on this synchronization, the more chance we would find a subtle problem with it (also it should be just nicer).

So if I undestand it correctly, using the "new" calling convention I should just lock the page on fb_deferred_io_mkwrite() and return VM_FAULT_LOCKED to fix the described race for fb_defio.

As far as I can see from quick reading of the fb_defio code, yes that should solve it (provided you lock the page inside the mutex, of course).

#3 lore raw
Quoted 6 lines · Nick Piggin
Quoted 6 lines
Quoted 5 lines

I hope that should provide a more elegant solution to your problem. I would really like you to take a look at that, because we already have filesystem code (NFS) relying on it, and more code we have relying on this synchronization, the more chance we would find a subtle problem with it (also it should be just nicer).

Quoted 6 lines
Quoted 1 line

So if I undestand it correctly, using the "new" calling convention I should just lock the page on fb_deferred_io_mkwrite() and return VM_FAULT_LOCKED to fix the described race for fb_defio.

As far as I can see from quick reading of the fb_defio code, yes that should solve it (provided you lock the page inside the mutex, of course).

Ok, thanks. I'm posting a new version as RFT.

Cheers,
Albert