Page MenuHomeFreeBSD

make v_wire_count PCPU
ClosedPublic

Authored by jeff on Feb 8 2018, 10:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 11:36 PM
Unknown Object (File)
Feb 14 2024, 9:20 PM
Unknown Object (File)
Dec 20 2023, 6:42 AM
Unknown Object (File)
Nov 7 2023, 11:46 AM
Unknown Object (File)
Oct 6 2023, 10:42 AM
Unknown Object (File)
Sep 22 2023, 8:50 PM
Unknown Object (File)
Sep 5 2023, 9:39 PM
Unknown Object (File)
Sep 5 2023, 9:38 PM

Details

Summary

This is the last VM counter that is not per-cpu or per-domain. This counter is read infrequently and written very frequently. It is only used to limit mlock() and it is checked very far from where it is adjusted so stale counters are not much of a concern.

Long term I believe mlock() pages should be counted separately. Conflating buffer cache and pte usage with user locked pages doesn't make sense. I looked at this but it was more complicated than I wanted to get into right away.

There are a couple of unusual atomics in pmap. I would like architecture owners to review these.

Diff Detail

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

Event Timeline

amd64/conf/GENERIC
102 ↗(On Diff #39070)

This will not be committed with the patch

vm/vm_meter.c
99 ↗(On Diff #39070)

This means there is a possibility that a few pages are lost on boot. I moved the sysinit so that very little code is run between vm startup and initializing the counter. I believe uma boot pages will actually mean no pages or almost no pages are allocated before this is set.

vm/vm_page.c
3336 ↗(On Diff #39070)

This should be -1

arm/arm/pmap-v6.c
2641 ↗(On Diff #39070)

I don't claim to understand why the release on the atomic was necessary but this barrier should be stronger.

As we discussed on IRC, I'd somewhat prefer a scheme where we maintain a global wire count and allow pcpu modifications to that value which get pushed up once they exceed some bound. But I think we'd like to further rework wired page accounting (to fix the issue of not being able to mlock() when many pages have been wired by the kernel), so I'm ok with doing this for now, as it's simpler. Maybe consider adding a wrapper macro for VM_CNT_ADD(v_wire_cnt, ...) so that we can change the mechanism later without having to touch all these files again.

arm/arm/pmap-v6.c
2641 ↗(On Diff #39070)

I believe it isn't. This comment is taken from the amd64 pmap.

The code to clear table entries in this pmap also includes a "data synchronization barrier" following the store, and my reading of atomic-v6.h suggests that the release store doesn't accomplish anything. I'd just get rid of the barrier and the comment, but it would be nice if someone familiar with ARM could confirm that that's ok.

sys/vmmeter.h
163 ↗(On Diff #39070)

Style: parens around return value. There should also be a newline after the prototype for vm_free_count().

This revision is now accepted and ready to land.Feb 12 2018, 8:50 PM

Also note that r329171 added a new reference to v_wire_count.

This revision was automatically updated to reflect the committed changes.