Page MenuHomeFreeBSD

vmspace: Convert to refcount(9)
ClosedPublic

Authored by markj on Nov 2 2020, 5:58 PM.
Tags
None
Referenced Files
F82067782: D27057.diff
Thu, Apr 25, 5:16 AM
Unknown Object (File)
Dec 20 2023, 7:08 AM
Unknown Object (File)
Dec 11 2023, 12:41 PM
Unknown Object (File)
Nov 23 2023, 6:18 PM
Unknown Object (File)
Aug 11 2023, 6:46 PM
Unknown Object (File)
Jul 29 2023, 8:32 PM
Unknown Object (File)
Jul 9 2023, 9:41 AM
Unknown Object (File)
May 7 2023, 7:56 PM
Subscribers

Details

Summary

This is mostly mechanical except for vmspace_exit(). There, I used the
new refcount_release_if_last() to avoid switching to vmspace0 unless
other processes are sharing the vmspace. In that case, upon switching
to vmspace0 we can unconditionally release the reference.

Remove the volatile qualifier from vm_refcnt now that accesses are
protected using refcount(9) KPIs.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34568
Build 31661: arc lint + arc unit

Event Timeline

markj requested review of this revision.Nov 2 2020, 5:58 PM
sys/vm/vm_glue.c
553

Should this be refcount_load > 1 ?

sys/vm/vm_map.c
350

s/dummy/kernel/

markj marked 2 inline comments as done.

Address feedback.

This revision is now accepted and ready to land.Nov 2 2020, 11:51 PM
alc added inline comments.
sys/vm/vm_map.c
365–366

There is nothing wrong with the patch here. I just want to make an observation.

Setting aside the exact KASSERT()s in some of the pmap implementations, we really don't need the pmap to be active on the underlying processor. We really only need that the pmap not be active on any other processor, because some of the pmap implementations intentionally perform non-atomic read-and-clear operations to minimize the cost of checking the dirty bit and clearing the PTE.

I wonder how often we pointlessly activate the pmap here.

400–403

I would suggest merging this "if" statement with the one above it.

Tested on ARM and ARM64

markj marked an inline comment as done.Nov 4 2020, 4:26 PM
markj added inline comments.
sys/vm/vm_map.c
365–366

By "pointlessly activate the pmap" do you mean switching to vmspace0's pmap and back again? I believe it should be fairly rare since it requires a process to exit while using a shared vmspace.

I ran a kernel build with the following dtrace script running in the background: dtrace -n 'fbt::vmspace_exit:entry {@[args[0]->td_proc->p_vmspace->vm_refcnt] = count();}' and got:

61                1
 1            53328

i.e., in all but one case the vmspace had one reference at the time the function was called. The sole exception was a case where p->p_vm == &vmspace0. I'm not sure how that arises.

This revision was automatically updated to reflect the committed changes.
sys/vm/vm_map.c
365–366

I'm not sure how that arises.

It is from exiting NFS client async I/O threads.