Page MenuHomeFreeBSD

vm_object_coalesce(): check that coalescing does not revive stale pages
ClosedPublic

Authored by kib on Dec 14 2025, 9:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 18, 4:05 PM
Unknown Object (File)
Sun, Jan 18, 12:36 PM
Unknown Object (File)
Sun, Jan 18, 11:28 AM
Unknown Object (File)
Sun, Jan 18, 11:15 AM
Unknown Object (File)
Fri, Jan 16, 2:53 PM
Unknown Object (File)
Fri, Jan 16, 6:57 AM
Unknown Object (File)
Thu, Jan 15, 6:07 PM
Unknown Object (File)
Wed, Jan 14, 4:06 PM
Subscribers

Details

Summary

Also:

swap_pager_seek_data(): improve assertions

swap_pager_seek_data(): move the clipping at the object size to consumers

Check that the passed object is indeed anonymous.
Accept any kind of the object lock ownership, not only for read.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/vm/swap_pager.c
2464

This function is called from tmpfs though, so won't this assertion fail? Should we check for OBJ_SWAP instead?

kib marked an inline comment as done.

swap_pager_seek_data(): check for the swap object, this is what the function assumes

sys/vm/vm_object.c
2251

Should we also verify that there are no valid, resident pages in this range? That might catch cases where we have resident pages at indices above prev_object->size.

2256

prev_size is a page count. Note that we do prev_size >>= PAGE_SHIFT; near the beginning of the function.

And isn't pstart just the same as next_pindex?

kib marked 2 inline comments as done.Dec 16 2025, 5:35 AM
kib added inline comments.
sys/vm/vm_object.c
2251

Indeed. I removed the clipping of the result from swap_pager_seek_data().

kib marked an inline comment as done.
kib edited the summary of this revision. (Show Details)

Remove pstart.
Remove clipping from swap_pager_seek_data(), so that PG_ZERO check can see all pages in the object.

sys/vm/vm_object.c
2256
sys/vm/vm_object.c
2258

pend could also be eliminated without any loss of clarity.

kib marked 2 inline comments as done.

Fix pend (and eliminate).

alc added inline comments.
sys/vm/vm_object.c
2251
This revision is now accepted and ready to land.Dec 16 2025, 6:20 PM
kib marked an inline comment as done.

Correct the article in comment.

This revision now requires review to proceed.Dec 16 2025, 6:31 PM
This revision is now accepted and ready to land.Dec 16 2025, 7:29 PM