Page MenuHomeFreeBSD

Simplify vm_pageout_init_domain() and add a "big picture" comment.
ClosedPublic

Authored by markj on Nov 15 2019, 11:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 26 2024, 2:09 PM
Unknown Object (File)
Oct 26 2024, 2:09 PM
Unknown Object (File)
Oct 26 2024, 2:09 PM
Unknown Object (File)
Oct 26 2024, 2:09 PM
Unknown Object (File)
Oct 26 2024, 1:48 PM
Unknown Object (File)
Sep 27 2024, 12:25 PM
Unknown Object (File)
Sep 26 2024, 1:17 AM
Unknown Object (File)
Sep 16 2024, 8:57 PM
Subscribers

Details

Summary

Stop subtracting 1024/200 from vmd_page_count/200. I cannot see how
such precise accounting can make a difference on modern systems.

Add some explanation of what the page daemon does and how it handles
memory shortages. I think this will serve as a useful reference as we
continue to make changes to the system.

Diff Detail

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

Event Timeline

I can't comment on the accuracy of any of this, but I can channel my 9th grade English teacher, Mrs. Weaver. There's some more passive voice in there (is awakened? by who?), but you're probably more interested in technical feedback.

sys/vm/vm_pagequeue.h
102 ↗(On Diff #64412)

Passive voice. A page daemon manages each vm_domain structure ....

133 ↗(On Diff #64412)

parens around the expression would improve readability. Either that, or commas.

141 ↗(On Diff #64412)

Passive voice. Who awakens it?

154 ↗(On Diff #64412)

are thus eventually migrated -> thus eventually migrate

157 ↗(On Diff #64412)

will periodically launder -> periodically launders

161 ↗(On Diff #64412)

will attempt -> attempts

sys/vm/vm_pagequeue.h
102 ↗(On Diff #64412)

'a page daemon thread'

103 ↗(On Diff #64412)

... is available, by free some inactive pages and demoting active to inactive, as needed.
To decide how many pages to proceed, it makes use of the ...

168 ↗(On Diff #64412)

I think that 'typically' can be removed, pmaps kernel page table pages allocators are the only users of VM_ALLOC_INTERRUPT in the current code.

169 ↗(On Diff #64412)

'some cases' sounds somewhat optimistic there

171 ↗(On Diff #64412)

I do not think that the statement 'most kernel memory allocations' for VM_ALLOC_SYSTEM is true. In fact it is reverse, most mallocs result in VM_ALLOC_NORMAL page requests, from my understanding. Indeed, internal UMA things or buffer cache, or mallocs with M_USE_RESERVE are about _SYSTEM.

184 ↗(On Diff #64412)

if the allocating thread cannot fail the allocation, it calls vm_wait()

202 ↗(On Diff #64412)

s/creation/population/ ?

213 ↗(On Diff #64412)

page daemon thread

sys/vm/vm_pageout.c
2123–2124 ↗(On Diff #64412)

I would guess that a 4MB system would not even boot right now. So whoever wants to use one will have to do some hacking. On the other hand, keeping a MIN(calc, 4) is not much burden.

sys/vm/vm_pagequeue.h
109 ↗(On Diff #64412)

I might like a bulleted list at one more level of indent for every target with a bulleted list of what it governs, what event handlers may be called, threads woken, that sort of thing.

The text below should be only for more complicated relationships that don't fit within the bullets and may be used by new people to familiarize themselves. I suspect all of us would get more value by scanning a briefer list.

sys/vm/vm_pagequeue.h
109 ↗(On Diff #64412)

Are you suggesting both paring down the text below and summarizing it here, or just the latter?

markj marked 12 inline comments as done.Nov 19 2019, 1:37 AM

I can't comment on the accuracy of any of this, but I can channel my 9th grade English teacher, Mrs. Weaver. There's some more passive voice in there (is awakened? by who?), but you're probably more interested in technical feedback.

I blame French immersion for my bad writing habits.

I tried to fix all uses of the passive voice but would appreciate any further suggestions to make the text clearer.

sys/vm/vm_pagequeue.h
169 ↗(On Diff #64412)

There are indeed some cases where it is handled, or at least we try to do so. For instance if a large mapping in the direct map is demoted, we need to allocate a leaf PTP, and callers of pmap_demote_*() must handle failure.

171 ↗(On Diff #64412)

malloc() always uses _SYSTEM or _INTERRUPT: malloc2vm_flags() contains:

pflags = (malloc_flags & M_USE_RESERVE) != 0 ? VM_ALLOC_INTERRUPT :                                                                                                   
    VM_ALLOC_SYSTEM;

This was somewhat surprising to me, I also thought it used _NORMAL.

Hopefully address all of the feedback.

This revision is now accepted and ready to land.Nov 19 2019, 5:13 PM