Page MenuHomeFreeBSD

Lock avoiding pageout wakeup algorithm
ClosedPublic

Authored by jeff on Mar 7 2018, 10:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 5:22 AM
Unknown Object (File)
Sep 6 2023, 9:26 AM
Unknown Object (File)
Sep 6 2023, 9:22 AM
Unknown Object (File)
Sep 6 2023, 9:19 AM
Unknown Object (File)
Sep 1 2023, 7:56 AM
Unknown Object (File)
Jun 25 2023, 4:30 AM
Unknown Object (File)
Jun 25 2023, 4:30 AM
Unknown Object (File)
Jun 25 2023, 4:28 AM
Subscribers

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 Skipped
Unit
Tests Skipped

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

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

2724

Semicolon instead of a period.

vm/vm_pageout.c
1795

Typo in "we".

1823

"spurious"

1986

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

vm/vm_pagequeue.h
273

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

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

736

int cast is excessive.

jeff added inline comments.
vm/vm_pagequeue.h
273

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.