函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:arch\x86\kernel\cpu\resctrl\rdtgroup.c Create Date:2022-07-27 09:10:55
首页 Copyright©Brick

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
              cpumask_var_t tmpmask)
{
    struct rdtgroup *prgrp = rdtgrp->mon.parent, *crgrp;
    struct list_head *head;
 
    /* Check whether cpus belong to parent ctrl group */
    cpumask_andnot(tmpmask, newmask, &prgrp->cpu_mask);
    if (cpumask_weight(tmpmask)) {
        rdt_last_cmd_puts("Can only add CPUs to mongroup that belong to parent\n");
        return -EINVAL;
    }
 
    /* Check whether cpus are dropped from this group */
    cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask);
    if (cpumask_weight(tmpmask)) {
        /* Give any dropped cpus to parent rdtgroup */
        cpumask_or(&prgrp->cpu_mask, &prgrp->cpu_mask, tmpmask);
        update_closid_rmid(tmpmask, prgrp);
    }
 
    /*
     * If we added cpus, remove them from previous group that owned them
     * and update per-cpu rmid
     */
    cpumask_andnot(tmpmask, newmask, &rdtgrp->cpu_mask);
    if (cpumask_weight(tmpmask)) {
        head = &prgrp->mon.crdtgrp_list;
        list_for_each_entry(crgrp, head, mon.crdtgrp_list) {
            if (crgrp == rdtgrp)
                continue;
            cpumask_andnot(&crgrp->cpu_mask, &crgrp->cpu_mask,
                       tmpmask);
        }
        update_closid_rmid(tmpmask, rdtgrp);
    }
 
    /* Done pushing/pulling - update this group with new mask */
    cpumask_copy(&rdtgrp->cpu_mask, newmask);
 
    return 0;
}