Page MenuHomeFreeBSD

In vm_map_copy_swap_object the object lock is not needed to protect charge/ucred because they are protected by the map lock.
ClosedPublic

Authored by jeff on Dec 10 2019, 6:49 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 8, 11:56 PM
Unknown Object (File)
Tue, Dec 17, 7:24 AM
Unknown Object (File)
Nov 5 2024, 11:57 AM
Unknown Object (File)
Oct 22 2024, 12:20 PM
Unknown Object (File)
Oct 2 2024, 12:50 PM
Unknown Object (File)
Oct 1 2024, 5:03 AM
Unknown Object (File)
Sep 30 2024, 11:35 PM
Unknown Object (File)
Sep 16 2024, 3:41 PM
Subscribers

Details

Summary

I believe that the map lock actually protects these two object fields. It would be nice to document the object fields with a lock key like we do elsewhere. If people agree that this synchronization is sufficient I can document this particular case.

This shows up on tmpfs buildkernel. We do have swap but we don't need the anonymous object book keeping.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jeff added reviewers: alc, doug_freebsd.con.com, kib, markj.
jeff set the repository for this revision to rS FreeBSD src repository - subversion.

I believe that the lack of swap accounting to the vnode owner is a bug in tmpfs.

I think that the change would work for now, until the tmpfs bug is fixed, but please put an XXX comment there.

In D22747#497793, @kib wrote:

I believe that the lack of swap accounting to the vnode owner is a bug in tmpfs.

I think that the change would work for now, until the tmpfs bug is fixed, but please put an XXX comment there.

If you look all of the cred/charge accounting still happens. It just doesn't happen under the object lock. I do not think the object lock is necessary here. All modifications are done under the map lock until the final drop of the object releases the space. At that point it is guaranteed single threaded.

This revision is now accepted and ready to land.Dec 10 2019, 9:51 PM
markj added inline comments.
sys/vm/vm_map.c
3888 ↗(On Diff #65450)

It would be nice to have a flavour of vm_object_reference() that asserts that the ref_count is at least 1, as it must be in this case. We could use xadd instead of cmpxchg there too.