Page MenuHomeFreeBSD

VM_WAIT rework
ClosedPublic

Authored by kib on Feb 15 2018, 6:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 17 2024, 5:20 AM
Unknown Object (File)
Feb 17 2024, 5:03 AM
Unknown Object (File)
Feb 17 2024, 4:43 AM
Unknown Object (File)
Feb 16 2024, 11:57 PM
Unknown Object (File)
Dec 27 2023, 6:34 AM
Unknown Object (File)
Dec 23 2023, 1:45 PM
Unknown Object (File)
Dec 20 2023, 3:03 AM
Unknown Object (File)
Nov 28 2023, 9:59 PM

Details

Summary

This is a first step. For now, vm_wait_doms() is added taking the domainset_t argument to specify which domains with min conditions should be pumped up. vm_wait_for_obj() is a convenience wrapper which waits according to the object or thread policy.

More to come, this is mostly a syntactic sugar as a base for further changes envisioned by Jeff.

Test Plan

Peter, could you, please, test this change ? Ideally, there should be no difference in the functionality.

Diff Detail

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

Event Timeline

jeff added inline comments.
sys/vm/vm_page.c
2788 ↗(On Diff #39342)

Should just be vm_wait_doms() with a single domain in the set.

2813 ↗(On Diff #39342)

Minor quibble; I prefer to name things for the primary structure they are passed. This seems like vm_domainset_wait() to me. vm_wait_for_obj looks like vm_object_wait(). I won't object to these names but consider what you think seems most consistent with the remainder of the code.

2839–2840 ↗(On Diff #39342)

I believe SUBSET does what you want and will be marginally faster.

#define BIT_SUBSET(_s, p, c) __extension__ ({                           \
        __size_t __i;                                                   \
        for (__i = 0; __i < __bitset_words((_s)); __i++)                \
                if (((c)->__bits[__i] &                                 \
                    (p)->__bits[__i]) !=                                \
                    (c)->__bits[__i])                                   \
                        break;                                          \
        __i == __bitset_words((_s));                                    \
})
2850 ↗(On Diff #39342)

Could just be vm_wait_for_obj(NULL)

kib marked 2 inline comments as done.Feb 15 2018, 6:44 PM
sys/vm/vm_page.c
2788 ↗(On Diff #39342)

Do you mean that vm_pageproc_waiters should go away, and vm_wait_doms() in case of pagedaemon context, should set vmd_pageout_pages_needed for each domain in wdoms mask ? I do not see how would this interact with the race described in the comment (1 tick wait).

2813 ↗(On Diff #39342)

I tried to find arguments supporting your suggestion, but I admit that I do not like vm_object_wait(). This name suggests that the wait is performed for some object' condition. Instead, the wait is for the pages availability, and object is only used as a compact form of passing some pack of arguments. The namespace for the page free wait is vm_wait*,

If vm_wait_for_obj() is too ugly, I have absolutely no attachment to this name and will change it, but IMO vm_object_ prefix there is misleading.

kib edited the summary of this revision. (Show Details)
kib added reviewers: jeff, alc, markj.

Use DOMAIN_SUBSET, improve vm_wait_for_obj() generality.

sys/vm/vm_page.c
2788 ↗(On Diff #39342)

I think the pagedaemon_wait() could go away in favor of vm_wait_doms()

The pageproc clause could stay. Some control variables could be eliminated as a result.

2813 ↗(On Diff #39342)

Perhaps just leave a single vm_wait(vm_object_t obj) function?

I think that conveys the message.

Switch to vm_wait(vm_object_t);.
Rewrite vm_wait_domain() using vm_wait_wdoms().
Remove pagedaemon_wait().

sys/vm/vm_page.c
2856–2857 ↗(On Diff #39402)

Without the object lock held dr_policy could be changed. We should fetch the policy pointer once to be sure we don't evaluate it multiple times. The structure itself is immutable but the pointer is not.

sys/vm/vm_pageout.c
2026–2028 ↗(On Diff #39402)

Are these two members used anymore?

Ensure that pointers are dereferenced only once, add a comment about it.
Remove no longer useful control vars.

sys/vm/vm_page.c
2856–2857 ↗(On Diff #39402)

I see, hopefully I corrected this.

sys/vm/vm_pageout.c
1763 ↗(On Diff #39449)

I do not think there is any use of this wakeup. If killing the task freed any memory, normal free mechanisms should provide enough events for waiters.

OTOH, I have significantly reworked OOM and swapout controls, changes were made after real reports of the deadlocks which were not solved by existing OOM heuristic. I will update the patch after the wait mechanism rework is finished.

2026–2028 ↗(On Diff #39402)

They are, but not in the useful way. I removed them and several places that wake up no longer waited for channels.

jeff added inline comments.
sys/vm/vm_pageout.c
1763 ↗(On Diff #39449)

I agree that this should be eliminated.

1852 ↗(On Diff #39449)

This is also eliminated in my pid control patch.

This revision is now accepted and ready to land.Feb 18 2018, 1:44 AM
kib added a subscriber: pho.

Drop domain free mutex.

Reported by: pho

This revision now requires review to proceed.Feb 18 2018, 11:58 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 26 2018, 8:01 AM
Closed by commit rS329636: vm_wait() rework. (authored by kib). · Explain Why
This revision was automatically updated to reflect the committed changes.