~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to kernel/cpuset.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
1159
1159
static int update_relax_domain_level(struct cpuset *cs, s64 val)
1160
1160
{
1161
1161
#ifdef CONFIG_SMP
1162
 
        if (val < -1 || val >= SD_LV_MAX)
 
1162
        if (val < -1 || val >= sched_domain_level_max)
1163
1163
                return -EINVAL;
1164
1164
#endif
1165
1165
 
1367
1367
        return val;
1368
1368
}
1369
1369
 
1370
 
/* Protected by cgroup_lock */
1371
 
static cpumask_var_t cpus_attach;
1372
 
 
1373
1370
/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
1374
1371
static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cont,
1375
 
                             struct task_struct *tsk, bool threadgroup)
 
1372
                             struct task_struct *tsk)
1376
1373
{
1377
 
        int ret;
1378
1374
        struct cpuset *cs = cgroup_cs(cont);
1379
1375
 
1380
1376
        if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
1391
1387
        if (tsk->flags & PF_THREAD_BOUND)
1392
1388
                return -EINVAL;
1393
1389
 
1394
 
        ret = security_task_setscheduler(tsk);
1395
 
        if (ret)
1396
 
                return ret;
1397
 
        if (threadgroup) {
1398
 
                struct task_struct *c;
1399
 
 
1400
 
                rcu_read_lock();
1401
 
                list_for_each_entry_rcu(c, &tsk->thread_group, thread_group) {
1402
 
                        ret = security_task_setscheduler(c);
1403
 
                        if (ret) {
1404
 
                                rcu_read_unlock();
1405
 
                                return ret;
1406
 
                        }
1407
 
                }
1408
 
                rcu_read_unlock();
1409
 
        }
1410
1390
        return 0;
1411
1391
}
1412
1392
 
1413
 
static void cpuset_attach_task(struct task_struct *tsk, nodemask_t *to,
1414
 
                               struct cpuset *cs)
 
1393
static int cpuset_can_attach_task(struct cgroup *cgrp, struct task_struct *task)
 
1394
{
 
1395
        return security_task_setscheduler(task);
 
1396
}
 
1397
 
 
1398
/*
 
1399
 * Protected by cgroup_lock. The nodemasks must be stored globally because
 
1400
 * dynamically allocating them is not allowed in pre_attach, and they must
 
1401
 * persist among pre_attach, attach_task, and attach.
 
1402
 */
 
1403
static cpumask_var_t cpus_attach;
 
1404
static nodemask_t cpuset_attach_nodemask_from;
 
1405
static nodemask_t cpuset_attach_nodemask_to;
 
1406
 
 
1407
/* Set-up work for before attaching each task. */
 
1408
static void cpuset_pre_attach(struct cgroup *cont)
 
1409
{
 
1410
        struct cpuset *cs = cgroup_cs(cont);
 
1411
 
 
1412
        if (cs == &top_cpuset)
 
1413
                cpumask_copy(cpus_attach, cpu_possible_mask);
 
1414
        else
 
1415
                guarantee_online_cpus(cs, cpus_attach);
 
1416
 
 
1417
        guarantee_online_mems(cs, &cpuset_attach_nodemask_to);
 
1418
}
 
1419
 
 
1420
/* Per-thread attachment work. */
 
1421
static void cpuset_attach_task(struct cgroup *cont, struct task_struct *tsk)
1415
1422
{
1416
1423
        int err;
 
1424
        struct cpuset *cs = cgroup_cs(cont);
 
1425
 
1417
1426
        /*
1418
1427
         * can_attach beforehand should guarantee that this doesn't fail.
1419
1428
         * TODO: have a better way to handle failure here
1421
1430
        err = set_cpus_allowed_ptr(tsk, cpus_attach);
1422
1431
        WARN_ON_ONCE(err);
1423
1432
 
1424
 
        cpuset_change_task_nodemask(tsk, to);
 
1433
        cpuset_change_task_nodemask(tsk, &cpuset_attach_nodemask_to);
1425
1434
        cpuset_update_task_spread_flag(cs, tsk);
1426
 
 
1427
1435
}
1428
1436
 
1429
1437
static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont,
1430
 
                          struct cgroup *oldcont, struct task_struct *tsk,
1431
 
                          bool threadgroup)
 
1438
                          struct cgroup *oldcont, struct task_struct *tsk)
1432
1439
{
1433
1440
        struct mm_struct *mm;
1434
1441
        struct cpuset *cs = cgroup_cs(cont);
1435
1442
        struct cpuset *oldcs = cgroup_cs(oldcont);
1436
 
        static nodemask_t to;           /* protected by cgroup_mutex */
1437
 
 
1438
 
        if (cs == &top_cpuset) {
1439
 
                cpumask_copy(cpus_attach, cpu_possible_mask);
1440
 
        } else {
1441
 
                guarantee_online_cpus(cs, cpus_attach);
1442
 
        }
1443
 
        guarantee_online_mems(cs, &to);
1444
 
 
1445
 
        /* do per-task migration stuff possibly for each in the threadgroup */
1446
 
        cpuset_attach_task(tsk, &to, cs);
1447
 
        if (threadgroup) {
1448
 
                struct task_struct *c;
1449
 
                rcu_read_lock();
1450
 
                list_for_each_entry_rcu(c, &tsk->thread_group, thread_group) {
1451
 
                        cpuset_attach_task(c, &to, cs);
1452
 
                }
1453
 
                rcu_read_unlock();
1454
 
        }
1455
 
 
1456
 
        /* change mm; only needs to be done once even if threadgroup */
1457
 
        to = cs->mems_allowed;
 
1443
 
 
1444
        /*
 
1445
         * Change mm, possibly for multiple threads in a threadgroup. This is
 
1446
         * expensive and may sleep.
 
1447
         */
 
1448
        cpuset_attach_nodemask_from = oldcs->mems_allowed;
 
1449
        cpuset_attach_nodemask_to = cs->mems_allowed;
1458
1450
        mm = get_task_mm(tsk);
1459
1451
        if (mm) {
1460
 
                mpol_rebind_mm(mm, &to);
 
1452
                mpol_rebind_mm(mm, &cpuset_attach_nodemask_to);
1461
1453
                if (is_memory_migrate(cs))
1462
 
                        cpuset_migrate_mm(mm, &oldcs->mems_allowed, &to);
 
1454
                        cpuset_migrate_mm(mm, &cpuset_attach_nodemask_from,
 
1455
                                          &cpuset_attach_nodemask_to);
1463
1456
                mmput(mm);
1464
1457
        }
1465
1458
}
1809
1802
}
1810
1803
 
1811
1804
/*
1812
 
 * post_clone() is called at the end of cgroup_clone().
1813
 
 * 'cgroup' was just created automatically as a result of
1814
 
 * a cgroup_clone(), and the current task is about to
1815
 
 * be moved into 'cgroup'.
 
1805
 * post_clone() is called during cgroup_create() when the
 
1806
 * clone_children mount argument was specified.  The cgroup
 
1807
 * can not yet have any tasks.
1816
1808
 *
1817
1809
 * Currently we refuse to set up the cgroup - thereby
1818
1810
 * refusing the task to be entered, and as a result refusing
1911
1903
        .create = cpuset_create,
1912
1904
        .destroy = cpuset_destroy,
1913
1905
        .can_attach = cpuset_can_attach,
 
1906
        .can_attach_task = cpuset_can_attach_task,
 
1907
        .pre_attach = cpuset_pre_attach,
 
1908
        .attach_task = cpuset_attach_task,
1914
1909
        .attach = cpuset_attach,
1915
1910
        .populate = cpuset_populate,
1916
1911
        .post_clone = cpuset_post_clone,
2195
2190
        rcu_read_lock();
2196
2191
        cs = task_cs(tsk);
2197
2192
        if (cs)
2198
 
                cpumask_copy(&tsk->cpus_allowed, cs->cpus_allowed);
 
2193
                do_set_cpus_allowed(tsk, cs->cpus_allowed);
2199
2194
        rcu_read_unlock();
2200
2195
 
2201
2196
        /*
2222
2217
                 * Like above we can temporary set any mask and rely on
2223
2218
                 * set_cpus_allowed_ptr() as synchronization point.
2224
2219
                 */
2225
 
                cpumask_copy(&tsk->cpus_allowed, cpu_possible_mask);
 
2220
                do_set_cpus_allowed(tsk, cpu_possible_mask);
2226
2221
                cpu = cpumask_any(cpu_active_mask);
2227
2222
        }
2228
2223