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

Function cpuset_init

freebsd/kern/kern_cpuset.c:307–336  ·  view source on GitHub ↗

* Initialize a set in the space provided in 'set' with the provided parameters. * The set is returned with a single ref. May return EDEADLK if the set * will have no valid cpu based on restrictions from the parent. */

Source from the content-addressed store, hash-verified

305 * will have no valid cpu based on restrictions from the parent.
306 */
307static int
308cpuset_init(struct cpuset *set, struct cpuset *parent,
309 const cpuset_t *mask, struct domainset *domain, cpusetid_t id)
310{
311
312 if (domain == NULL)
313 domain = parent->cs_domain;
314 if (mask == NULL)
315 mask = &parent->cs_mask;
316 if (!CPU_OVERLAP(&parent->cs_mask, mask))
317 return (EDEADLK);
318 /* The domain must be prepared ahead of time. */
319 if (!domainset_valid(parent->cs_domain, domain))
320 return (EDEADLK);
321 CPU_COPY(mask, &set->cs_mask);
322 LIST_INIT(&set->cs_children);
323 refcount_init(&set->cs_ref, 1);
324 set->cs_flags = 0;
325 mtx_lock_spin(&cpuset_lock);
326 set->cs_domain = domain;
327 CPU_AND(&set->cs_mask, &parent->cs_mask);
328 set->cs_id = id;
329 set->cs_parent = cpuset_ref(parent);
330 LIST_INSERT_HEAD(&parent->cs_children, set, cs_siblings);
331 if (set->cs_id != CPUSET_INVALID)
332 LIST_INSERT_HEAD(&cpuset_ids, set, cs_link);
333 mtx_unlock_spin(&cpuset_lock);
334
335 return (0);
336}
337
338/*
339 * Create a new non-anonymous set with the requested parent and mask. May

Callers 3

cpuset_createFunction · 0.85
cpuset_shadowFunction · 0.85
cpuset_thread0Function · 0.85

Calls 3

domainset_validFunction · 0.85
refcount_initFunction · 0.85
cpuset_refFunction · 0.85

Tested by

no test coverage detected