Page MenuHomeFreeBSD

Lock avoiding pageout wakeup algorithm
ClosedPublic

Authored by jeff on Mar 7 2018, 10:29 PM.

Details

Summary

This closes a few races in low memory conditions while avoiding locks by using the same threshold based notification algorithm I employed in the buffer cache. The algorithm uses atomics for free_count adjustment and then only threads which cross important thresholds attempt to check for waiters and wakeup. It can devolve into the same contention if you constantly bounce around the thresholds but this doesn't seem to be a problem in practice.

I improved the annotation and description of the locking protocol so hopefully this is fairly obvious from the code. I moved the pageout sleep/wakeup protection into its own locks to continue to shrink the scope of the free lock. I have a follow on patch that does the same for the allocation side but it is significantly larger.

Diff Detail

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

Event Timeline

It's somewhat hard to read the diff without context. If you're uploading a raw patch, could you generate the patch with -U9999 or so?

vm/vm_page.c
2715 ↗(On Diff #40053)

Style: the first letter should be capitalized and there should be a newline before the comment.

2724 ↗(On Diff #40053)

Semicolon instead of a period.

vm/vm_pageout.c
1795 ↗(On Diff #40053)

Typo in "we".

1823 ↗(On Diff #40053)

"spurious"

1986 ↗(On Diff #40053)

We have "curproc" has shorthand for curthread->td_proc.

vm/vm_pagequeue.h
273 ↗(On Diff #40053)

Shouldn't we assert that the domain lock is held here? I would also assert that adj <= vmd_free_count.

vm/vm_page.c
143 ↗(On Diff #40053)

I think it is better to move the comment one line below.

736 ↗(On Diff #40053)

int cast is excessive.

jeff added inline comments.
vm/vm_pagequeue.h
273 ↗(On Diff #40053)

The domain lock is no longer required here. Right now it's only required between domain_available and freecount_dec. I have another patch that merges them into domain_allocate and does so with atomics.

This revision is now accepted and ready to land.Mar 13 2018, 5:41 PM
This revision was automatically updated to reflect the committed changes.
jeff marked an inline comment as done.