Page MenuHomeFreeBSD

vm_domainset: Refactor iterators, multiple fixes
Needs ReviewPublic

Authored by olce on Fri, Jul 11, 7:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 21, 9:33 AM
Unknown Object (File)
Sun, Jul 20, 9:20 AM
Unknown Object (File)
Sun, Jul 20, 8:37 AM
Unknown Object (File)
Sat, Jul 19, 7:53 PM
Unknown Object (File)
Fri, Jul 18, 5:55 PM
Unknown Object (File)
Sun, Jul 13, 2:22 PM
Unknown Object (File)
Sun, Jul 13, 2:22 PM
Unknown Object (File)
Sun, Jul 13, 2:21 PM

Details

Reviewers
markj
alc
kib
jeff
Summary

vm_domainset_iter_first() would not check if the initial domain selected
by the policy was effectively valid (i.e., allowed by the domainset and
not marked as ignored by vm_domainset_iter_ignore()). It would just try
to skip it if it had less pages than 'free_min', and would not take into
account the possibility of no domains being valid.

Factor out code that logically belongs to the iterator machinery and is
not tied to how allocations (or impossibility thereof) are to be
handled. This allows to remove duplicated code between
vm_domainset_iter_page() and vm_domainset_iter_policy(), and between
vm_domainset_iter_page_init() and _vm_domainset_iter_policy_init().
This also allows to remove the 'pages' parameter from
vm_domainset_iter_page_init().

This also makes the two-phase logic clearer, revealing an inconsistency
between setting 'di_minskip' to true in vm_domainset_iter_init()
(implying that, in the case of waiting allocations, further attempts
after the first sleep should just allocate for the first domain,
regardless of their situation with respect to their 'free_min') and
trying to skip the first domain if it has too few pages in
vm_domainset_iter_page_init() and _vm_domainset_iter_policy_init(). Fix
this inconsistency by resetting 'di_minskip' to 'true' in
vm_domainset_iter_first() instead so that, after each vm_wait_doms()
(waiting allocations that could not be satisfied immediately), we again
start with only the domains that have more than 'free_min' pages.

While here, fix the minor quirk that the round-robin policy would start
with the domain after the one pointed to by the initial value of
'di_iter' (this just affects the case of resetting '*di_iter', and would
not cause domain skips in other circumstances, i.e., for waiting
allocations that actually wait or at each subsequent new iterator
creation with same iteration index storage).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65347
Build 62230: arc lint + arc unit

Event Timeline

olce requested review of this revision.Fri, Jul 11, 7:00 AM
  • Fix 32-bit arm build
  • Remove local variable already_visited, it doesn't make the code flow clearer.

I was not too sure how to handle iterator initialization failure, and by default deferred that to callers. We should probably instead just panic in this case (empty set), but then I'll have to make sure that no empty domainset can ever be constructed (which a cursory read of kern_cpuset.c seems to indicate was intended). Thoughts?

Hello, thanks for your hard work in solving this.

I've been trying to apply this patch for testing your fixes, but much of the hunks for vm_domainset.c don't seem to apply anywhere in CURRENT.

These are the lines they fail to apply at:
error: patch failed: sys/vm/vm_domainset.c:103
error: patch failed: sys/vm/vm_domainset.c:116
error: patch failed: sys/vm/vm_domainset.c:156
error: patch failed: sys/vm/vm_domainset.c:184
error: patch failed: sys/vm/vm_domainset.c:238

I've been trying to apply this patch for testing your fixes, but much of the hunks for vm_domainset.c don't seem to apply anywhere in CURRENT.

These are the lines they fail to apply at:
(snip)

Hi, then please upgrade to a recent -CURRENT. I don't see such errors at all. Incidentally, going to do some minor updates of the revision, with base being an hours-ago main.

Or maybe you've applied local patches of your own?

  • Simplify back the logic that determines whether a currently examined domain can be returned (second phase, or has enough memory), also making the control flow clearer.
  • Replace the for (;;) loop whose body starts with if (...) break; with a while(!...). This is a leftover of a previous version that had some code before the if.

Hi, then please upgrade to a recent -CURRENT. I don't see such errors at all. Incidentally, going to do some minor updates of the revision, with base being an hours-ago main.

Or maybe you've applied local patches of your own?

It's because I didn't apply the required patches from D51249 and D51250.

From daily drive testing it seems to prevent mpv from freezing, but I've been noticing random video stuttering after playing a video for a while. And the only way to break out of the "stuttering" is to actuate a time seek in mpv.

From daily drive testing it seems to prevent mpv from freezing, but I've been noticing random video stuttering after playing a video for a while. And the only way to break out of the "stuttering" is to actuate a time seek in mpv.

Well, that's good news for the first part, and for the second one, I'm afraid that if you can stop the stuttering through a time seek, even on a machine with a long enough uptime and barely no memory unused, then the stuttering is most likely due to another problem.