diff options
author | Mark Johnston <markj@FreeBSD.org> | 2021-04-14 16:56:39 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2021-04-14 17:03:33 +0000 |
commit | 29bb6c19f044274cc6693f0c2463ca22106cd3ab (patch) | |
tree | 9a1db1b2c6576e6fd0452ca104e1ff88793edfe6 /sys | |
parent | b1ab802ce4908b6af93e3a3b4328377003735357 (diff) | |
download | src-29bb6c19f044274cc6693f0c2463ca22106cd3ab.tar.gz src-29bb6c19f044274cc6693f0c2463ca22106cd3ab.zip |
domainset: Define additional global policies
Add global definitions for first-touch and interleave policies. The
former may be useful for UMA, which implements a similar policy without
using domainset iterators.
No functional change intended.
Reviewed by: mav
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29104
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_cpuset.c | 38 | ||||
-rw-r--r-- | sys/sys/domainset.h | 4 |
2 files changed, 28 insertions, 14 deletions
diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 19ad3fd20955..119df57c7b02 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -119,7 +119,9 @@ __FBSDID("$FreeBSD$"); */ LIST_HEAD(domainlist, domainset); +struct domainset __read_mostly domainset_firsttouch; struct domainset __read_mostly domainset_fixed[MAXMEMDOM]; +struct domainset __read_mostly domainset_interleave; struct domainset __read_mostly domainset_prefer[MAXMEMDOM]; struct domainset __read_mostly domainset_roundrobin; @@ -130,7 +132,7 @@ static struct setlist cpuset_ids; static struct domainlist cpuset_domains; static struct unrhdr *cpuset_unr; static struct cpuset *cpuset_zero, *cpuset_default, *cpuset_kernel; -static struct domainset domainset0, domainset2; +static struct domainset *domainset0, *domainset2; /* Return the size of cpuset_t at the kernel level */ SYSCTL_INT(_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD | CTLFLAG_CAPRD, @@ -568,7 +570,7 @@ domainset_create(const struct domainset *domain) if (domain->ds_policy == DOMAINSET_POLICY_PREFER && !DOMAINSET_ISSET(domain->ds_prefer, &domain->ds_mask)) return (NULL); - if (!DOMAINSET_SUBSET(&domainset0.ds_mask, &domain->ds_mask)) + if (!DOMAINSET_SUBSET(&domainset0->ds_mask, &domain->ds_mask)) return (NULL); ndomain = uma_zalloc(domainset_zone, M_WAITOK | M_ZERO); domainset_copy(domain, ndomain); @@ -1532,6 +1534,18 @@ domainset_init(void) struct domainset *dset; int i; + dset = &domainset_firsttouch; + DOMAINSET_COPY(&all_domains, &dset->ds_mask); + dset->ds_policy = DOMAINSET_POLICY_FIRSTTOUCH; + dset->ds_prefer = -1; + _domainset_create(dset, NULL); + + dset = &domainset_interleave; + DOMAINSET_COPY(&all_domains, &dset->ds_mask); + dset->ds_policy = DOMAINSET_POLICY_INTERLEAVE; + dset->ds_prefer = -1; + _domainset_create(dset, NULL); + dset = &domainset_roundrobin; DOMAINSET_COPY(&all_domains, &dset->ds_mask); dset->ds_policy = DOMAINSET_POLICY_ROUNDROBIN; @@ -1554,7 +1568,7 @@ domainset_init(void) } /* - * Create the domainset for cpuset 0, 1 and cpuset 2. + * Define the domainsets for cpuset 0, 1 and cpuset 2. */ void domainset_zero(void) @@ -1563,15 +1577,11 @@ domainset_zero(void) mtx_init(&cpuset_lock, "cpuset", NULL, MTX_SPIN | MTX_RECURSE); - dset = &domainset0; - DOMAINSET_COPY(&all_domains, &dset->ds_mask); - dset->ds_policy = DOMAINSET_POLICY_FIRSTTOUCH; - dset->ds_prefer = -1; - curthread->td_domain.dr_policy = _domainset_create(dset, NULL); + domainset0 = &domainset_firsttouch; + curthread->td_domain.dr_policy = domainset0; - domainset_copy(dset, &domainset2); - domainset2.ds_policy = DOMAINSET_POLICY_INTERLEAVE; - kernel_object->domain.dr_policy = _domainset_create(&domainset2, NULL); + domainset2 = &domainset_interleave; + kernel_object->domain.dr_policy = domainset2; /* Remove empty domains from the global policies. */ LIST_FOREACH_SAFE(dset, &cpuset_domains, ds_link, tmp) @@ -1613,7 +1623,7 @@ cpuset_thread0(void) LIST_INSERT_HEAD(&cpuset_ids, set, cs_link); refcount_init(&set->cs_ref, 1); set->cs_flags = CPU_SET_ROOT | CPU_SET_RDONLY; - set->cs_domain = &domainset0; + set->cs_domain = domainset0; cpuset_zero = set; cpuset_root = &set->cs_mask; @@ -1630,7 +1640,7 @@ cpuset_thread0(void) set = uma_zalloc(cpuset_zone, M_WAITOK | M_ZERO); error = cpuset_init(set, cpuset_zero, NULL, NULL, 2); KASSERT(error == 0, ("Error creating kernel set: %d\n", error)); - set->cs_domain = &domainset2; + set->cs_domain = domainset2; cpuset_kernel = set; /* @@ -2315,7 +2325,7 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which, * across all domains. */ if (domainset_empty_vm(&domain)) - domainset_copy(&domainset2, &domain); + domainset_copy(domainset2, &domain); switch (level) { case CPU_LEVEL_ROOT: diff --git a/sys/sys/domainset.h b/sys/sys/domainset.h index 7b1180012f4c..2113196d8d26 100644 --- a/sys/sys/domainset.h +++ b/sys/sys/domainset.h @@ -95,6 +95,10 @@ struct domainset { domainid_t ds_order[MAXMEMDOM]; /* nth domain table. */ }; +extern struct domainset domainset_firsttouch; +#define DOMAINSET_FT() (&domainset_firsttouch) +extern struct domainset domainset_interleave; +#define DOMAINSET_IL() (&domainset_interleave) extern struct domainset domainset_fixed[MAXMEMDOM], domainset_prefer[MAXMEMDOM]; #define DOMAINSET_FIXED(domain) (&domainset_fixed[(domain)]) #define DOMAINSET_PREF(domain) (&domainset_prefer[(domain)]) |