1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Fix the domain iterator to not try the first-touch / fixed domain

more than once when doing round-robin.

This lead to a panic because the iterator was trying the same domain
twice and not trying one of the other domains.

Reported by: pho
Tested by: pho
This commit is contained in:
Adrian Chadd 2016-01-10 17:53:43 +00:00
parent a18c313e4a
commit 54de56f3b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=293640

View File

@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_domain.h>
static __inline int
vm_domain_rr_selectdomain(void)
vm_domain_rr_selectdomain(int skip_domain)
{
#if MAXMEMDOM > 1
struct thread *td;
@ -71,6 +71,16 @@ vm_domain_rr_selectdomain(void)
td->td_dom_rr_idx++;
td->td_dom_rr_idx %= vm_ndomains;
/*
* If skip_domain is provided then skip over that
* domain. This is intended for round robin variants
* which first try a fixed domain.
*/
if ((skip_domain > -1) && (td->td_dom_rr_idx == skip_domain)) {
td->td_dom_rr_idx++;
td->td_dom_rr_idx %= vm_ndomains;
}
return (td->td_dom_rr_idx);
#else
return (0);
@ -339,12 +349,12 @@ vm_domain_iterator_run(struct vm_domain_iterator *vi, int *domain)
if (vi->n == vm_ndomains)
*domain = vi->domain;
else
*domain = vm_domain_rr_selectdomain();
*domain = vm_domain_rr_selectdomain(vi->domain);
vi->n--;
break;
case VM_POLICY_ROUND_ROBIN:
default:
*domain = vm_domain_rr_selectdomain();
*domain = vm_domain_rr_selectdomain(-1);
vi->n--;
break;
}