2 * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org>
5 * Copyright (c) 2008 Nokia Corporation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice unmodified, this list of conditions, and the following
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/sysproto.h>
39 #include <sys/kernel.h>
41 #include <sys/malloc.h>
42 #include <sys/mutex.h>
45 #include <sys/refcount.h>
46 #include <sys/sched.h>
48 #include <sys/syscallsubr.h>
49 #include <sys/cpuset.h>
51 #include <sys/refcount.h>
52 #include <sys/queue.h>
53 #include <sys/limits.h>
55 #include <sys/interrupt.h>
56 #include <sys/jail.h> /* Must come after sys/proc.h */
65 * cpusets provide a mechanism for creating and manipulating sets of
66 * processors for the purpose of constraining the scheduling of threads to
67 * specific processors.
69 * Each process belongs to an identified set, by default this is set 1. Each
70 * thread may further restrict the cpus it may run on to a subset of this
71 * named set. This creates an anonymous set which other threads and processes
72 * may not join by number.
74 * The named set is referred to herein as the 'base' set to avoid ambiguity.
75 * This set is usually a child of a 'root' set while the anonymous set may
76 * simply be referred to as a mask. In the syscall api these are referred to
77 * as the ROOT, CPUSET, and MASK levels where CPUSET is called 'base' here.
79 * Threads inherit their set from their creator whether it be anonymous or
80 * not. This means that anonymous sets are immutable because they may be
81 * shared. To modify an anonymous set a new set is created with the desired
82 * mask and the same parent as the existing anonymous set. This gives the
83 * illusion of each thread having a private mask.A
85 * Via the syscall apis a user may ask to retrieve or modify the root, base,
86 * or mask that is discovered via a pid, tid, or setid. Modifying a set
87 * modifies all numbered and anonymous child sets to comply with the new mask.
88 * Modifying a pid or tid's mask applies only to that tid but must still
89 * exist within the assigned parent set.
91 * A thread may not be assigned to a a group seperate from other threads in
92 * the process. This is to remove ambiguity when the setid is queried with
93 * a pid argument. There is no other technical limitation.
95 * This somewhat complex arrangement is intended to make it easy for
96 * applications to query available processors and bind their threads to
97 * specific processors while also allowing administrators to dynamically
98 * reprovision by changing sets which apply to groups of processes.
100 * A simple application should not concern itself with sets at all and
101 * rather apply masks to its own threads via CPU_WHICH_TID and a -1 id
102 * meaning 'curthread'. It may query availble cpus for that tid with a
103 * getaffinity call using (CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, ...).
105 static uma_zone_t cpuset_zone;
106 static struct mtx cpuset_lock;
107 static struct setlist cpuset_ids;
108 static struct unrhdr *cpuset_unr;
109 static struct cpuset *cpuset_zero;
111 cpuset_t *cpuset_root;
114 * Acquire a reference to a cpuset, all pointers must be tracked with refs.
117 cpuset_ref(struct cpuset *set)
120 refcount_acquire(&set->cs_ref);
125 * Walks up the tree from 'set' to find the root. Returns the root
128 static struct cpuset *
129 cpuset_refroot(struct cpuset *set)
132 for (; set->cs_parent != NULL; set = set->cs_parent)
133 if (set->cs_flags & CPU_SET_ROOT)
141 * Find the first non-anonymous set starting from 'set'. Returns this set
142 * referenced. May return the passed in set with an extra ref if it is
145 static struct cpuset *
146 cpuset_refbase(struct cpuset *set)
149 if (set->cs_id == CPUSET_INVALID)
150 set = set->cs_parent;
157 * Release a reference in a context where it is safe to allocte.
160 cpuset_rel(struct cpuset *set)
164 if (refcount_release(&set->cs_ref) == 0)
166 mtx_lock_spin(&cpuset_lock);
167 LIST_REMOVE(set, cs_siblings);
169 if (id != CPUSET_INVALID)
170 LIST_REMOVE(set, cs_link);
171 mtx_unlock_spin(&cpuset_lock);
172 cpuset_rel(set->cs_parent);
173 uma_zfree(cpuset_zone, set);
174 if (id != CPUSET_INVALID)
175 free_unr(cpuset_unr, id);
179 * Deferred release must be used when in a context that is not safe to
180 * allocate/free. This places any unreferenced sets on the list 'head'.
183 cpuset_rel_defer(struct setlist *head, struct cpuset *set)
186 if (refcount_release(&set->cs_ref) == 0)
188 mtx_lock_spin(&cpuset_lock);
189 LIST_REMOVE(set, cs_siblings);
190 if (set->cs_id != CPUSET_INVALID)
191 LIST_REMOVE(set, cs_link);
192 LIST_INSERT_HEAD(head, set, cs_link);
193 mtx_unlock_spin(&cpuset_lock);
197 * Complete a deferred release. Removes the set from the list provided to
201 cpuset_rel_complete(struct cpuset *set)
203 LIST_REMOVE(set, cs_link);
204 cpuset_rel(set->cs_parent);
205 uma_zfree(cpuset_zone, set);
209 * Find a set based on an id. Returns it with a ref.
211 static struct cpuset *
212 cpuset_lookup(cpusetid_t setid, struct thread *td)
216 if (setid == CPUSET_INVALID)
218 mtx_lock_spin(&cpuset_lock);
219 LIST_FOREACH(set, &cpuset_ids, cs_link)
220 if (set->cs_id == setid)
224 mtx_unlock_spin(&cpuset_lock);
226 KASSERT(td != NULL, ("[%s:%d] td is NULL", __func__, __LINE__));
227 if (set != NULL && jailed(td->td_ucred)) {
228 struct cpuset *rset, *jset;
231 rset = cpuset_refroot(set);
233 pr = td->td_ucred->cr_prison;
234 mtx_lock(&pr->pr_mtx);
235 cpuset_ref(pr->pr_cpuset);
236 jset = pr->pr_cpuset;
237 mtx_unlock(&pr->pr_mtx);
239 if (jset->cs_id != rset->cs_id) {
251 * Create a set in the space provided in 'set' with the provided parameters.
252 * The set is returned with a single ref. May return EDEADLK if the set
253 * will have no valid cpu based on restrictions from the parent.
256 _cpuset_create(struct cpuset *set, struct cpuset *parent, cpuset_t *mask,
260 if (!CPU_OVERLAP(&parent->cs_mask, mask))
262 CPU_COPY(mask, &set->cs_mask);
263 LIST_INIT(&set->cs_children);
264 refcount_init(&set->cs_ref, 1);
266 mtx_lock_spin(&cpuset_lock);
267 CPU_AND(mask, &parent->cs_mask);
269 set->cs_parent = cpuset_ref(parent);
270 LIST_INSERT_HEAD(&parent->cs_children, set, cs_siblings);
271 if (set->cs_id != CPUSET_INVALID)
272 LIST_INSERT_HEAD(&cpuset_ids, set, cs_link);
273 mtx_unlock_spin(&cpuset_lock);
279 * Create a new non-anonymous set with the requested parent and mask. May
280 * return failures if the mask is invalid or a new number can not be
284 cpuset_create(struct cpuset **setp, struct cpuset *parent, cpuset_t *mask)
290 id = alloc_unr(cpuset_unr);
293 *setp = set = uma_zalloc(cpuset_zone, M_WAITOK);
294 error = _cpuset_create(set, parent, mask, id);
297 free_unr(cpuset_unr, id);
298 uma_zfree(cpuset_zone, set);
304 * Recursively check for errors that would occur from applying mask to
305 * the tree of sets starting at 'set'. Checks for sets that would become
306 * empty as well as RDONLY flags.
309 cpuset_testupdate(struct cpuset *set, cpuset_t *mask)
315 mtx_assert(&cpuset_lock, MA_OWNED);
316 if (set->cs_flags & CPU_SET_RDONLY)
318 if (!CPU_OVERLAP(&set->cs_mask, mask))
320 CPU_COPY(&set->cs_mask, &newmask);
321 CPU_AND(&newmask, mask);
323 LIST_FOREACH(nset, &set->cs_children, cs_siblings)
324 if ((error = cpuset_testupdate(nset, &newmask)) != 0)
330 * Applies the mask 'mask' without checking for empty sets or permissions.
333 cpuset_update(struct cpuset *set, cpuset_t *mask)
337 mtx_assert(&cpuset_lock, MA_OWNED);
338 CPU_AND(&set->cs_mask, mask);
339 LIST_FOREACH(nset, &set->cs_children, cs_siblings)
340 cpuset_update(nset, &set->cs_mask);
346 * Modify the set 'set' to use a copy of the mask provided. Apply this new
347 * mask to restrict all children in the tree. Checks for validity before
348 * applying the changes.
351 cpuset_modify(struct cpuset *set, cpuset_t *mask)
356 error = priv_check(curthread, PRIV_SCHED_CPUSET);
360 * Verify that we have access to this set of
363 root = set->cs_parent;
364 if (root && !CPU_SUBSET(&root->cs_mask, mask))
366 mtx_lock_spin(&cpuset_lock);
367 error = cpuset_testupdate(set, mask);
370 cpuset_update(set, mask);
371 CPU_COPY(mask, &set->cs_mask);
373 mtx_unlock_spin(&cpuset_lock);
379 * Resolve the 'which' parameter of several cpuset apis.
381 * For WHICH_PID and WHICH_TID return a locked proc and valid proc/tid. Also
382 * checks for permission via p_cansched().
384 * For WHICH_SET returns a valid set with a new reference.
386 * -1 may be supplied for any argument to mean the current proc/thread or
387 * the base set of the current thread. May fail with ESRCH/EPERM.
390 cpuset_which(cpuwhich_t which, id_t id, struct proc **pp, struct thread **tdp,
391 struct cpuset **setp)
408 if ((p = pfind(id)) == NULL)
418 sx_slock(&allproc_lock);
419 FOREACH_PROC_IN_SYSTEM(p) {
422 FOREACH_THREAD_IN_PROC(p, td)
423 if (td->td_tid == id)
430 sx_sunlock(&allproc_lock);
434 case CPU_WHICH_CPUSET:
436 thread_lock(curthread);
437 set = cpuset_refbase(curthread->td_cpuset);
438 thread_unlock(curthread);
440 set = cpuset_lookup(id, curthread);
448 /* Find `set' for prison with given id. */
451 sx_slock(&allprison_lock);
452 pr = prison_find(id);
453 sx_sunlock(&allprison_lock);
456 if (jailed(curthread->td_ucred)) {
457 if (curthread->td_ucred->cr_prison == pr) {
458 cpuset_ref(pr->pr_cpuset);
462 cpuset_ref(pr->pr_cpuset);
465 mtx_unlock(&pr->pr_mtx);
475 error = p_cansched(curthread, p);
481 td = FIRST_THREAD_IN_PROC(p);
488 * Create an anonymous set with the provided mask in the space provided by
489 * 'fset'. If the passed in set is anonymous we use its parent otherwise
490 * the new set is a child of 'set'.
493 cpuset_shadow(struct cpuset *set, struct cpuset *fset, cpuset_t *mask)
495 struct cpuset *parent;
497 if (set->cs_id == CPUSET_INVALID)
498 parent = set->cs_parent;
501 if (!CPU_SUBSET(&parent->cs_mask, mask))
503 return (_cpuset_create(fset, parent, mask, CPUSET_INVALID));
507 * Handle two cases for replacing the base set or mask of an entire process.
509 * 1) Set is non-null and mask is null. This reparents all anonymous sets
510 * to the provided set and replaces all non-anonymous td_cpusets with the
512 * 2) Mask is non-null and set is null. This replaces or creates anonymous
513 * sets for every thread with the existing base as a parent.
515 * This is overly complicated because we can't allocate while holding a
516 * spinlock and spinlocks must be held while changing and examining thread
520 cpuset_setproc(pid_t pid, struct cpuset *set, cpuset_t *mask)
522 struct setlist freelist;
523 struct setlist droplist;
524 struct cpuset *tdset;
532 * The algorithm requires two passes due to locking considerations.
534 * 1) Lookup the process and acquire the locks in the required order.
535 * 2) If enough cpusets have not been allocated release the locks and
536 * allocate them. Loop.
538 LIST_INIT(&freelist);
539 LIST_INIT(&droplist);
542 error = cpuset_which(CPU_WHICH_PID, pid, &p, &td, &nset);
546 if (nfree >= p->p_numthreads)
548 threads = p->p_numthreads;
551 for (; nfree < threads; nfree++) {
552 nset = uma_zalloc(cpuset_zone, M_WAITOK);
553 LIST_INSERT_HEAD(&freelist, nset, cs_link);
556 PROC_LOCK_ASSERT(p, MA_OWNED);
557 PROC_SLOCK_ASSERT(p, MA_OWNED);
559 * Now that the appropriate locks are held and we have enough cpusets,
560 * make sure the operation will succeed before applying changes. The
561 * proc lock prevents td_cpuset from changing between calls.
564 FOREACH_THREAD_IN_PROC(p, td) {
566 tdset = td->td_cpuset;
568 * Verify that a new mask doesn't specify cpus outside of
569 * the set the thread is a member of.
572 if (tdset->cs_id == CPUSET_INVALID)
573 tdset = tdset->cs_parent;
574 if (!CPU_SUBSET(&tdset->cs_mask, mask))
577 * Verify that a new set won't leave an existing thread
578 * mask without a cpu to run on. It can, however, restrict
581 } else if (tdset->cs_id == CPUSET_INVALID) {
582 if (!CPU_OVERLAP(&set->cs_mask, &tdset->cs_mask))
590 * Replace each thread's cpuset while using deferred release. We
591 * must do this because the PROC_SLOCK has to be held while traversing
592 * the thread list and this limits the type of operations allowed.
594 FOREACH_THREAD_IN_PROC(p, td) {
597 * If we presently have an anonymous set or are applying a
598 * mask we must create an anonymous shadow set. That is
599 * either parented to our existing base or the supplied set.
601 * If we have a base set with no anonymous shadow we simply
602 * replace it outright.
604 tdset = td->td_cpuset;
605 if (tdset->cs_id == CPUSET_INVALID || mask) {
606 nset = LIST_FIRST(&freelist);
607 LIST_REMOVE(nset, cs_link);
609 error = cpuset_shadow(tdset, nset, mask);
611 error = _cpuset_create(nset, set,
612 &tdset->cs_mask, CPUSET_INVALID);
614 LIST_INSERT_HEAD(&freelist, nset, cs_link);
619 nset = cpuset_ref(set);
620 cpuset_rel_defer(&droplist, tdset);
621 td->td_cpuset = nset;
629 while ((nset = LIST_FIRST(&droplist)) != NULL)
630 cpuset_rel_complete(nset);
631 while ((nset = LIST_FIRST(&freelist)) != NULL) {
632 LIST_REMOVE(nset, cs_link);
633 uma_zfree(cpuset_zone, nset);
639 * Apply an anonymous mask to a single thread.
642 cpuset_setthread(lwpid_t id, cpuset_t *mask)
650 nset = uma_zalloc(cpuset_zone, M_WAITOK);
651 error = cpuset_which(CPU_WHICH_TID, id, &p, &td, &set);
656 error = cpuset_shadow(td->td_cpuset, nset, mask);
659 td->td_cpuset = nset;
669 uma_zfree(cpuset_zone, nset);
674 * Creates the cpuset for thread0. We make two sets:
676 * 0 - The root set which should represent all valid processors in the
677 * system. It is initially created with a mask of all processors
678 * because we don't know what processors are valid until cpuset_init()
679 * runs. This set is immutable.
680 * 1 - The default set which all processes are a member of until changed.
681 * This allows an administrator to move all threads off of given cpus to
682 * dedicate them to high priority tasks or save power etc.
690 cpuset_zone = uma_zcreate("cpuset", sizeof(struct cpuset), NULL, NULL,
691 NULL, NULL, UMA_ALIGN_PTR, 0);
692 mtx_init(&cpuset_lock, "cpuset", NULL, MTX_SPIN | MTX_RECURSE);
694 * Create the root system set for the whole machine. Doesn't use
695 * cpuset_create() due to NULL parent.
697 set = uma_zalloc(cpuset_zone, M_WAITOK | M_ZERO);
698 set->cs_mask.__bits[0] = -1;
699 LIST_INIT(&set->cs_children);
700 LIST_INSERT_HEAD(&cpuset_ids, set, cs_link);
702 set->cs_flags = CPU_SET_ROOT;
704 cpuset_root = &set->cs_mask;
706 * Now derive a default, modifiable set from that to give out.
708 set = uma_zalloc(cpuset_zone, M_WAITOK);
709 error = _cpuset_create(set, cpuset_zero, &cpuset_zero->cs_mask, 1);
710 KASSERT(error == 0, ("Error creating default set: %d\n", error));
712 * Initialize the unit allocator. 0 and 1 are allocated above.
714 cpuset_unr = new_unrhdr(2, INT_MAX, NULL);
720 * Create a cpuset, which would be cpuset_create() but
721 * mark the new 'set' as root.
723 * We are not going to reparent the td to it. Use cpuset_reparentproc() for that.
725 * In case of no error, returns the set in *setp locked with a reference.
728 cpuset_create_root(struct thread *td, struct cpuset **setp)
734 KASSERT(td != NULL, ("[%s:%d] invalid td", __func__, __LINE__));
735 KASSERT(setp != NULL, ("[%s:%d] invalid setp", __func__, __LINE__));
738 root = cpuset_refroot(td->td_cpuset);
741 error = cpuset_create(setp, td->td_cpuset, &root->cs_mask);
746 KASSERT(*setp != NULL, ("[%s:%d] cpuset_create returned invalid data",
747 __func__, __LINE__));
749 /* Mark the set as root. */
751 set->cs_flags |= CPU_SET_ROOT;
757 cpuset_setproc_update_set(struct proc *p, struct cpuset *set)
761 KASSERT(p != NULL, ("[%s:%d] invalid proc", __func__, __LINE__));
762 KASSERT(set != NULL, ("[%s:%d] invalid set", __func__, __LINE__));
765 error = cpuset_setproc(p->p_pid, set, NULL);
773 * This is called once the final set of system cpus is known. Modifies
774 * the root set and all children and mark the root readonly.
777 cpuset_init(void *arg)
783 mask.__bits[0] = all_cpus;
787 if (cpuset_modify(cpuset_zero, &mask))
788 panic("Can't set initial cpuset mask.\n");
789 cpuset_zero->cs_flags |= CPU_SET_RDONLY;
791 SYSINIT(cpuset, SI_SUB_SMP, SI_ORDER_ANY, cpuset_init, NULL);
793 #ifndef _SYS_SYSPROTO_H_
799 cpuset(struct thread *td, struct cpuset_args *uap)
806 root = cpuset_refroot(td->td_cpuset);
808 error = cpuset_create(&set, root, &root->cs_mask);
812 error = copyout(&set->cs_id, uap->setid, sizeof(set->cs_id));
814 error = cpuset_setproc(-1, set, NULL);
819 #ifndef _SYS_SYSPROTO_H_
820 struct cpuset_setid_args {
827 cpuset_setid(struct thread *td, struct cpuset_setid_args *uap)
833 * Presently we only support per-process sets.
835 if (uap->which != CPU_WHICH_PID)
837 set = cpuset_lookup(uap->setid, td);
840 error = cpuset_setproc(uap->id, set, NULL);
845 #ifndef _SYS_SYSPROTO_H_
846 struct cpuset_getid_args {
853 cpuset_getid(struct thread *td, struct cpuset_getid_args *uap)
862 if (uap->level == CPU_LEVEL_WHICH && uap->which != CPU_WHICH_CPUSET)
864 error = cpuset_which(uap->which, uap->id, &p, &ttd, &set);
867 switch (uap->which) {
871 set = cpuset_refbase(ttd->td_cpuset);
875 case CPU_WHICH_CPUSET:
879 switch (uap->level) {
881 nset = cpuset_refroot(set);
885 case CPU_LEVEL_CPUSET:
887 case CPU_LEVEL_WHICH:
893 error = copyout(&id, uap->setid, sizeof(id));
898 #ifndef _SYS_SYSPROTO_H_
899 struct cpuset_getaffinity_args {
908 cpuset_getaffinity(struct thread *td, struct cpuset_getaffinity_args *uap)
918 if (uap->cpusetsize < sizeof(cpuset_t) ||
919 uap->cpusetsize > CPU_MAXSIZE / NBBY)
921 size = uap->cpusetsize;
922 mask = malloc(size, M_TEMP, M_WAITOK | M_ZERO);
923 error = cpuset_which(uap->which, uap->id, &p, &ttd, &set);
926 switch (uap->level) {
928 case CPU_LEVEL_CPUSET:
929 switch (uap->which) {
933 set = cpuset_ref(ttd->td_cpuset);
936 case CPU_WHICH_CPUSET:
940 if (uap->level == CPU_LEVEL_ROOT)
941 nset = cpuset_refroot(set);
943 nset = cpuset_refbase(set);
944 CPU_COPY(&nset->cs_mask, mask);
947 case CPU_LEVEL_WHICH:
948 switch (uap->which) {
951 CPU_COPY(&ttd->td_cpuset->cs_mask, mask);
956 FOREACH_THREAD_IN_PROC(p, ttd) {
958 CPU_OR(mask, &ttd->td_cpuset->cs_mask);
963 case CPU_WHICH_CPUSET:
965 CPU_COPY(&set->cs_mask, mask);
978 error = copyout(mask, uap->mask, size);
984 #ifndef _SYS_SYSPROTO_H_
985 struct cpuset_setaffinity_args {
990 const cpuset_t *mask;
994 cpuset_setaffinity(struct thread *td, struct cpuset_setaffinity_args *uap)
1003 if (uap->cpusetsize < sizeof(cpuset_t) ||
1004 uap->cpusetsize > CPU_MAXSIZE / NBBY)
1006 mask = malloc(uap->cpusetsize, M_TEMP, M_WAITOK | M_ZERO);
1007 error = copyin(uap->mask, mask, uap->cpusetsize);
1011 * Verify that no high bits are set.
1013 if (uap->cpusetsize > sizeof(cpuset_t)) {
1017 end = cp = (char *)&mask->__bits;
1018 end += uap->cpusetsize;
1019 cp += sizeof(cpuset_t);
1027 switch (uap->level) {
1028 case CPU_LEVEL_ROOT:
1029 case CPU_LEVEL_CPUSET:
1030 error = cpuset_which(uap->which, uap->id, &p, &ttd, &set);
1033 switch (uap->which) {
1037 set = cpuset_ref(ttd->td_cpuset);
1041 case CPU_WHICH_CPUSET:
1042 case CPU_WHICH_JAIL:
1045 if (uap->level == CPU_LEVEL_ROOT)
1046 nset = cpuset_refroot(set);
1048 nset = cpuset_refbase(set);
1049 error = cpuset_modify(nset, mask);
1053 case CPU_LEVEL_WHICH:
1054 switch (uap->which) {
1056 error = cpuset_setthread(uap->id, mask);
1059 error = cpuset_setproc(uap->id, NULL, mask);
1061 case CPU_WHICH_CPUSET:
1062 case CPU_WHICH_JAIL:
1063 error = cpuset_which(uap->which, uap->id, &p,
1066 error = cpuset_modify(set, mask);
1085 DB_SHOW_COMMAND(cpusets, db_show_cpusets)
1090 LIST_FOREACH(set, &cpuset_ids, cs_link) {
1091 db_printf("set=%p id=%-6u ref=%-6d flags=0x%04x parent id=%d\n",
1092 set, set->cs_id, set->cs_ref, set->cs_flags,
1093 (set->cs_parent != NULL) ? set->cs_parent->cs_id : 0);
1094 db_printf(" mask=");
1095 for (once = 0, cpu = 0; cpu < CPU_SETSIZE; cpu++) {
1096 if (CPU_ISSET(cpu, &set->cs_mask)) {
1098 db_printf("%d", cpu);
1101 db_printf(",%d", cpu);