Page MenuHomeFreeBSD

Lock avoiding pageout wakeup algorithm

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



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

rS FreeBSD src repository - subversion
Lint Not Applicable
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?

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.

1795 ↗(On Diff #40053)

Typo in "we".

1823 ↗(On Diff #40053)


1986 ↗(On Diff #40053)

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

273 ↗(On Diff #40053)

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

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.
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.