MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cpuset_modify

Function cpuset_modify

freebsd/kern/kern_cpuset.c:681–733  ·  view source on GitHub ↗

* Modify the set 'set' to use a copy of the mask provided. Apply this new * mask to restrict all children in the tree. Checks for validity before * applying the changes. */

Source from the content-addressed store, hash-verified

679 * applying the changes.
680 */
681static int
682cpuset_modify(struct cpuset *set, cpuset_t *mask)
683{
684 struct cpuset *root;
685 int error;
686
687 error = priv_check(curthread, PRIV_SCHED_CPUSET);
688 if (error)
689 return (error);
690 /*
691 * In case we are called from within the jail,
692 * we do not allow modifying the dedicated root
693 * cpuset of the jail but may still allow to
694 * change child sets, including subordinate jails'
695 * roots.
696 */
697 if ((set->cs_flags & CPU_SET_ROOT) != 0 &&
698 jailed(curthread->td_ucred) &&
699 set == curthread->td_ucred->cr_prison->pr_cpuset)
700 return (EPERM);
701 /*
702 * Verify that we have access to this set of
703 * cpus.
704 */
705 if ((set->cs_flags & (CPU_SET_ROOT | CPU_SET_RDONLY)) == CPU_SET_ROOT) {
706 KASSERT(set->cs_parent != NULL,
707 ("jail.cpuset=%d is not a proper child of parent jail's root.",
708 set->cs_id));
709
710 /*
711 * cpuset_getroot() cannot work here due to how top-level jail
712 * roots are constructed. Top-level jails are parented to
713 * thread0's cpuset (i.e. cpuset 1) rather than the system root.
714 */
715 root = set->cs_parent;
716 } else {
717 root = cpuset_getroot(set);
718 }
719 mtx_lock_spin(&cpuset_lock);
720 if (root && !CPU_SUBSET(&root->cs_mask, mask)) {
721 error = EINVAL;
722 goto out;
723 }
724 error = cpuset_testupdate(set, mask, 0);
725 if (error)
726 goto out;
727 CPU_COPY(mask, &set->cs_mask);
728 cpuset_update(set, mask);
729out:
730 mtx_unlock_spin(&cpuset_lock);
731
732 return (error);
733}
734
735/*
736 * Recursively check for errors that would occur from applying mask to

Callers 1

kern_cpuset_setaffinityFunction · 0.85

Calls 5

jailedFunction · 0.85
cpuset_getrootFunction · 0.85
cpuset_testupdateFunction · 0.85
cpuset_updateFunction · 0.85
priv_checkFunction · 0.70

Tested by

no test coverage detected