kern_cpuset.c (01d4e2149e5566e5d9394913dc9fb032da259e0b) | kern_cpuset.c (662e7fa8d9fb296379f594ebb6a7f231c1ea8a2f) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> 5 * All rights reserved. 6 * 7 * Copyright (c) 2008 Nokia Corporation 8 * All rights reserved. --- 105 unchanged lines hidden (view full) --- 114 * 115 * A simple application should not concern itself with sets at all and 116 * rather apply masks to its own threads via CPU_WHICH_TID and a -1 id 117 * meaning 'curthread'. It may query available cpus for that tid with a 118 * getaffinity call using (CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, ...). 119 */ 120 121LIST_HEAD(domainlist, domainset); | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> 5 * All rights reserved. 6 * 7 * Copyright (c) 2008 Nokia Corporation 8 * All rights reserved. --- 105 unchanged lines hidden (view full) --- 114 * 115 * A simple application should not concern itself with sets at all and 116 * rather apply masks to its own threads via CPU_WHICH_TID and a -1 id 117 * meaning 'curthread'. It may query available cpus for that tid with a 118 * getaffinity call using (CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, ...). 119 */ 120 121LIST_HEAD(domainlist, domainset); |
122struct domainset __read_mostly domainset_prefer[MAXMEMDOM]; 123struct domainset __read_mostly domainset_roundrobin; |
|
122 123static uma_zone_t cpuset_zone; 124static uma_zone_t domainset_zone; 125static struct mtx cpuset_lock; 126static struct setlist cpuset_ids; 127static struct domainlist cpuset_domains; 128static struct unrhdr *cpuset_unr; 129static struct cpuset *cpuset_zero, *cpuset_default, *cpuset_kernel; --- 1234 unchanged lines hidden (view full) --- 1364 if (cpu == NOCPU) 1365 CPU_COPY(cpuset_root, &mask); 1366 else 1367 CPU_SET(cpu, &mask); 1368 return _cpuset_setthread(id, &mask, NULL); 1369} 1370 1371/* | 124 125static uma_zone_t cpuset_zone; 126static uma_zone_t domainset_zone; 127static struct mtx cpuset_lock; 128static struct setlist cpuset_ids; 129static struct domainlist cpuset_domains; 130static struct unrhdr *cpuset_unr; 131static struct cpuset *cpuset_zero, *cpuset_default, *cpuset_kernel; --- 1234 unchanged lines hidden (view full) --- 1366 if (cpu == NOCPU) 1367 CPU_COPY(cpuset_root, &mask); 1368 else 1369 CPU_SET(cpu, &mask); 1370 return _cpuset_setthread(id, &mask, NULL); 1371} 1372 1373/* |
1374 * Initialize static domainsets after NUMA information is available. This is 1375 * called very early during boot. 1376 */ 1377void 1378domainset_init(void) 1379{ 1380 struct domainset *dset; 1381 int i; 1382 1383 dset = &domainset_roundrobin; 1384 DOMAINSET_COPY(&all_domains, &dset->ds_mask); 1385 dset->ds_policy = DOMAINSET_POLICY_ROUNDROBIN; 1386 dset->ds_prefer = -1; 1387 _domainset_create(dset, NULL); 1388 1389 for (i = 0; i < vm_ndomains; i++) { 1390 dset = &domainset_prefer[i]; 1391 DOMAINSET_COPY(&all_domains, &dset->ds_mask); 1392 dset->ds_policy = DOMAINSET_POLICY_PREFER; 1393 dset->ds_prefer = i; 1394 _domainset_create(dset, NULL); 1395 } 1396} 1397 1398/* |
|
1372 * Create the domainset for cpuset 0, 1 and cpuset 2. 1373 */ 1374void 1375domainset_zero(void) 1376{ 1377 struct domainset *dset; | 1399 * Create the domainset for cpuset 0, 1 and cpuset 2. 1400 */ 1401void 1402domainset_zero(void) 1403{ 1404 struct domainset *dset; |
1378 int i; | |
1379 1380 mtx_init(&cpuset_lock, "cpuset", NULL, MTX_SPIN | MTX_RECURSE); 1381 1382 dset = &domainset0; | 1405 1406 mtx_init(&cpuset_lock, "cpuset", NULL, MTX_SPIN | MTX_RECURSE); 1407 1408 dset = &domainset0; |
1383 DOMAINSET_ZERO(&dset->ds_mask); 1384 for (i = 0; i < vm_ndomains; i++) 1385 DOMAINSET_SET(i, &dset->ds_mask); | 1409 DOMAINSET_COPY(&all_domains, &dset->ds_mask); |
1386 dset->ds_policy = DOMAINSET_POLICY_FIRSTTOUCH; 1387 dset->ds_prefer = -1; | 1410 dset->ds_policy = DOMAINSET_POLICY_FIRSTTOUCH; 1411 dset->ds_prefer = -1; |
1388 (void)domainset_empty_vm(dset); | |
1389 curthread->td_domain.dr_policy = _domainset_create(dset, NULL); 1390 1391 domainset_copy(dset, &domainset2); 1392 domainset2.ds_policy = DOMAINSET_POLICY_INTERLEAVE; 1393 kernel_object->domain.dr_policy = _domainset_create(&domainset2, NULL); | 1412 curthread->td_domain.dr_policy = _domainset_create(dset, NULL); 1413 1414 domainset_copy(dset, &domainset2); 1415 domainset2.ds_policy = DOMAINSET_POLICY_INTERLEAVE; 1416 kernel_object->domain.dr_policy = _domainset_create(&domainset2, NULL); |
1417 1418 /* Remove empty domains from the global policies. */ 1419 LIST_FOREACH(dset, &cpuset_domains, ds_link) 1420 (void)domainset_empty_vm(dset); |
|
1394} 1395 1396/* 1397 * Creates system-wide cpusets and the cpuset for thread0 including three 1398 * sets: 1399 * 1400 * 0 - The root set which should represent all valid processors in the 1401 * system. It is initially created with a mask of all processors --- 851 unchanged lines hidden --- | 1421} 1422 1423/* 1424 * Creates system-wide cpusets and the cpuset for thread0 including three 1425 * sets: 1426 * 1427 * 0 - The root set which should represent all valid processors in the 1428 * system. It is initially created with a mask of all processors --- 851 unchanged lines hidden --- |