Page MenuHomeFreeBSD

swap_pager: swapoff detecting object death
ClosedPublic

Authored by dougm on Oct 11 2024, 4:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jan 11, 1:04 AM
Unknown Object (File)
Fri, Jan 10, 5:29 PM
Unknown Object (File)
Tue, Jan 7, 7:54 AM
Unknown Object (File)
Fri, Jan 3, 4:13 AM
Unknown Object (File)
Fri, Dec 27, 4:28 AM
Unknown Object (File)
Dec 15 2024, 3:11 AM
Unknown Object (File)
Dec 8 2024, 4:02 AM
Unknown Object (File)
Dec 4 2024, 1:56 AM
Subscribers

Details

Summary

In swap_pager_swapoff_object, the object is initially not dead, and can only become dead while the object lock is not held. Move the test for object-death so that it is right after the early loop-break that happens after lock re-acquisition, and before the iterator is re-initialized, which fails an assertion when the object is dead, rather than swap.

Addresses a problem produced in testing by @pho and diagnosed by @kib.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Oct 11 2024, 4:39 PM
dougm created this revision.
sys/vm/swap_pager.c
1920–1928

This also handled the possibility that the object was dead on entry. Are you sure that is not the case? If it is not, then it should be asserted at the start.

sys/vm/swap_pager.c
1920–1928

Here is the path to the only call to swap_pager_swapoff_object:

		/*
		 * Dead objects are eventually terminated on their own.
		 */
		if ((object->flags & OBJ_DEAD) != 0)
			goto next_obj;

		/*
		 * Sync with fences placed after pctrie
		 * initialization.  We must not access pctrie below
		 * unless we checked that our object is swap and not
		 * dead.
		 */
		atomic_thread_fence_acq();
		if ((object->flags & OBJ_SWAP) == 0)
			goto next_obj;

		swap_pager_swapoff_object(sp, object);

So, unless the object could become dead while atomic_thread_fence_acq() is happening, there's no problem.

This revision is now accepted and ready to land.Oct 11 2024, 5:23 PM
This revision was automatically updated to reflect the committed changes.