Page MenuHomeFreeBSD

Centralize the logic in vfs_vmio_unwire() and sendfile_free_page().
ClosedPublic

Authored by markj on Jul 18 2019, 6:53 PM.
Tags
None
Referenced Files
F86148224: D20986.id59969.diff
Sun, Jun 16, 3:51 AM
Unknown Object (File)
Mon, Jun 3, 12:20 PM
Unknown Object (File)
Wed, May 29, 12:31 AM
Unknown Object (File)
May 14 2024, 10:50 AM
Unknown Object (File)
May 5 2024, 10:07 AM
Unknown Object (File)
May 4 2024, 12:32 PM
Unknown Object (File)
Apr 28 2024, 8:29 AM
Unknown Object (File)
Apr 25 2024, 5:06 PM
Subscribers

Details

Summary

These functions are similar and I would like to have their functionality
live in generic VM functions so that the details of vm_page
synchronization can be encapsulated in vm_page.c.

The change adds vm_page_release() and vm_page_release_locked(). They
both unwire the page and optionally attempt to free the page.
vm_page_release_locked() requires the object lock. The main difference
is that vfs_vmio_unwire() may attempt to free a mapped page, while
sendfile_free_page() does not. This change thus modifies the handling
of direct I/O and B_NOREUSE to avoid freeing a mapped page.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 25463
Build 24083: arc lint + arc unit

Event Timeline

sys/vm/vm_page.c
171

Is this unrelated ?

3790

What prevents other thread from busying the page after we tested for !xbusy but before TRYWLOCK() succeeded ?

sys/vm/vm_page.c
171

No, I renamed the old (static) vm_page_release() to vm_page_zone_release(), and renamed vm_page_import() as well for consistency.

3790

Nothing, but there is a vm_page_busied(m) check after we acquire the object lock. This is identical to the logic in sendfile_free_page(). I accidentally removed a comment explaining that the first check is racy, I will restore it.

sys/vm/vm_page.c
3790

Then why the first (racy) check is not vm_page_busied() ?

Don't attempt to free the page if it is busy at all.

kib added inline comments.
sys/vm/vm_page.c
171

I think it is useful to commit this part separately, and definitely merge it to 12.

This revision is now accepted and ready to land.Jul 18 2019, 9:14 PM
This revision now requires review to proceed.Jul 20 2019, 8:33 PM
sys/vm/vm_page.c
3780

assert that m->object is not locked.

3819

Consider defining these seven lines as a function of m and flags, and using it here and below.

markj marked 2 inline comments as done.
  • Use a common subrouting for releasing to the page queues.
  • Assert that the object is unlocked in vm_page_release().
sys/vm/vm_page.c
3780

Note that m->object may be NULL. I added the conditional assertion under the page lock, since the page lock is required in order to modify the object field.

This revision is now accepted and ready to land.Jul 23 2019, 7:42 AM
sys/vm/vm_page.c
3782

"managed" -> "unmanaged"

3823

"managed" -> "unmanaged"

This revision now requires review to proceed.Jul 27 2019, 11:51 PM
This revision is now accepted and ready to land.Jul 28 2019, 9:37 PM