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

Function cpuset_modify_domain

freebsd/kern/kern_cpuset.c:802–873  ·  view source on GitHub ↗

* Modify the set 'set' to use a copy the domainset 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

800 * applying the changes.
801 */
802static int
803cpuset_modify_domain(struct cpuset *set, struct domainset *domain)
804{
805 struct domainlist domains;
806 struct domainset temp;
807 struct domainset *dset;
808 struct cpuset *root;
809 int ndomains, needed;
810 int error;
811
812 error = priv_check(curthread, PRIV_SCHED_CPUSET);
813 if (error)
814 return (error);
815 /*
816 * In case we are called from within the jail
817 * we do not allow modifying the dedicated root
818 * cpuset of the jail but may still allow to
819 * change child sets.
820 */
821 if (jailed(curthread->td_ucred) &&
822 set->cs_flags & CPU_SET_ROOT)
823 return (EPERM);
824 domainset_freelist_init(&domains, 0);
825 domain = domainset_create(domain);
826 ndomains = 0;
827
828 mtx_lock_spin(&cpuset_lock);
829 for (;;) {
830 root = cpuset_getroot(set);
831 dset = root->cs_domain;
832 /*
833 * Verify that we have access to this set of domains.
834 */
835 if (!domainset_valid(dset, domain)) {
836 error = EINVAL;
837 goto out;
838 }
839 /*
840 * If applying prefer we keep the current set as the fallback.
841 */
842 if (domain->ds_policy == DOMAINSET_POLICY_PREFER)
843 DOMAINSET_COPY(&set->cs_domain->ds_mask,
844 &domain->ds_mask);
845 /*
846 * Determine whether we can apply this set of domains and
847 * how many new domain structures it will require.
848 */
849 domainset_copy(domain, &temp);
850 needed = 0;
851 error = cpuset_testupdate_domain(set, &temp, set->cs_domain,
852 &needed, 0);
853 if (error)
854 goto out;
855 if (ndomains >= needed)
856 break;
857
858 /* Dropping the lock; we'll need to re-evaluate again. */
859 mtx_unlock_spin(&cpuset_lock);

Callers 1

kern_cpuset_setdomainFunction · 0.85

Calls 12

jailedFunction · 0.85
domainset_freelist_initFunction · 0.85
domainset_createFunction · 0.85
cpuset_getrootFunction · 0.85
domainset_validFunction · 0.85
domainset_copyFunction · 0.85
cpuset_testupdate_domainFunction · 0.85
domainset_freelist_addFunction · 0.85
cpuset_update_domainFunction · 0.85
domainset_freelist_freeFunction · 0.85
domainset_notifyFunction · 0.85
priv_checkFunction · 0.70

Tested by

no test coverage detected