* Create a new non-anonymous set with the requested parent and mask. May * return failures if the mask is invalid or a new number can not be * allocated. * * If *setp is not NULL, then it will be used as-is. The caller must take * into account that *setp will be inserted at the head of cpuset_ids and * plan any potentially conflicting cs_link usage accordingly. */
| 345 | * plan any potentially conflicting cs_link usage accordingly. |
| 346 | */ |
| 347 | static int |
| 348 | cpuset_create(struct cpuset **setp, struct cpuset *parent, const cpuset_t *mask) |
| 349 | { |
| 350 | struct cpuset *set; |
| 351 | cpusetid_t id; |
| 352 | int error; |
| 353 | bool dofree; |
| 354 | |
| 355 | id = alloc_unr(cpuset_unr); |
| 356 | if (id == -1) |
| 357 | return (ENFILE); |
| 358 | dofree = (*setp == NULL); |
| 359 | if (*setp != NULL) |
| 360 | set = *setp; |
| 361 | else |
| 362 | *setp = set = uma_zalloc(cpuset_zone, M_WAITOK | M_ZERO); |
| 363 | error = cpuset_init(set, parent, mask, NULL, id); |
| 364 | if (error == 0) |
| 365 | return (0); |
| 366 | free_unr(cpuset_unr, id); |
| 367 | if (dofree) |
| 368 | uma_zfree(cpuset_zone, set); |
| 369 | |
| 370 | return (error); |
| 371 | } |
| 372 | |
| 373 | static void |
| 374 | cpuset_freelist_add(struct setlist *list, int count) |
no test coverage detected