|
Lines 39-44
Link Here
|
| 39 |
#ifdef GPROF |
39 |
#ifdef GPROF |
| 40 |
#include <sys/gmon.h> |
40 |
#include <sys/gmon.h> |
| 41 |
#endif |
41 |
#endif |
|
|
42 |
#include <sys/cpuset.h> |
| 42 |
#include <sys/kernel.h> |
43 |
#include <sys/kernel.h> |
| 43 |
#include <sys/ktr.h> |
44 |
#include <sys/ktr.h> |
| 44 |
#include <sys/lock.h> |
45 |
#include <sys/lock.h> |
|
Lines 85-91
Link Here
|
| 85 |
int mp_naps; /* # of Applications processors */ |
86 |
int mp_naps; /* # of Applications processors */ |
| 86 |
int boot_cpu_id = -1; /* designated BSP */ |
87 |
int boot_cpu_id = -1; /* designated BSP */ |
| 87 |
|
88 |
|
| 88 |
extern struct pcpu __pcpu[]; |
89 |
extern struct pcpu __pcpu[]; |
| 89 |
|
90 |
|
| 90 |
/* AP uses this during bootstrap. Do not staticize. */ |
91 |
/* AP uses this during bootstrap. Do not staticize. */ |
| 91 |
char *bootSTK; |
92 |
char *bootSTK; |
|
Lines 1145-1151
Link Here
|
| 1145 |
old_pending = cpu_ipi_pending[cpu]; |
1146 |
old_pending = cpu_ipi_pending[cpu]; |
| 1146 |
new_pending = old_pending | bitmap; |
1147 |
new_pending = old_pending | bitmap; |
| 1147 |
} while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], |
1148 |
} while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], |
| 1148 |
old_pending, new_pending)); |
1149 |
old_pending, new_pending)); |
| 1149 |
if (old_pending) |
1150 |
if (old_pending) |
| 1150 |
return; |
1151 |
return; |
| 1151 |
} |
1152 |
} |
|
Lines 1333-1339
Link Here
|
| 1333 |
*/ |
1334 |
*/ |
| 1334 |
if (ipi == IPI_STOP_HARD) |
1335 |
if (ipi == IPI_STOP_HARD) |
| 1335 |
atomic_set_int(&ipi_nmi_pending, PCPU_GET(other_cpus)); |
1336 |
atomic_set_int(&ipi_nmi_pending, PCPU_GET(other_cpus)); |
| 1336 |
|
|
|
| 1337 |
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); |
1337 |
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); |
| 1338 |
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); |
1338 |
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); |
| 1339 |
} |
1339 |
} |
|
Lines 1357-1363
Link Here
|
| 1357 |
cpustop_handler(); |
1357 |
cpustop_handler(); |
| 1358 |
return (0); |
1358 |
return (0); |
| 1359 |
} |
1359 |
} |
| 1360 |
|
1360 |
|
| 1361 |
/* |
1361 |
/* |
| 1362 |
* Handle an IPI_STOP by saving our current context and spinning until we |
1362 |
* Handle an IPI_STOP by saving our current context and spinning until we |
| 1363 |
* are resumed. |
1363 |
* are resumed. |
|
Lines 1447-1452
Link Here
|
| 1447 |
static int |
1447 |
static int |
| 1448 |
sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) |
1448 |
sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) |
| 1449 |
{ |
1449 |
{ |
|
|
1450 |
cpuset_t mask_set; |
| 1450 |
cpumask_t mask; |
1451 |
cpumask_t mask; |
| 1451 |
int error; |
1452 |
int error; |
| 1452 |
|
1453 |
|
|
Lines 1455-1472
Link Here
|
| 1455 |
if (error || !req->newptr) |
1456 |
if (error || !req->newptr) |
| 1456 |
return (error); |
1457 |
return (error); |
| 1457 |
|
1458 |
|
| 1458 |
if (logical_cpus_mask != 0 && |
1459 |
if (hlt_logical_cpus) |
| 1459 |
(mask & logical_cpus_mask) == logical_cpus_mask) |
1460 |
mask |= logical_cpus_mask; |
| 1460 |
hlt_logical_cpus = 1; |
1461 |
if (!hyperthreading_allowed) |
| 1461 |
else |
|
|
| 1462 |
hlt_logical_cpus = 0; |
| 1463 |
|
| 1464 |
if (! hyperthreading_allowed) |
| 1465 |
mask |= hyperthreading_cpus_mask; |
1462 |
mask |= hyperthreading_cpus_mask; |
| 1466 |
|
1463 |
|
|
|
1464 |
/* Don't disable BSP0 */ |
| 1467 |
if ((mask & all_cpus) == all_cpus) |
1465 |
if ((mask & all_cpus) == all_cpus) |
| 1468 |
mask &= ~(1<<0); |
1466 |
mask &= ~(1<<0); |
| 1469 |
hlt_cpus_mask = mask; |
1467 |
|
|
|
1468 |
CPU_ZERO(&mask_set); |
| 1469 |
CPU_SETMASK(~mask & all_cpus, &mask_set); |
| 1470 |
error = cpuset_zero_modify(&mask_set); |
| 1471 |
if (error == 0) |
| 1472 |
hlt_cpus_mask = mask; |
| 1470 |
return (error); |
1473 |
return (error); |
| 1471 |
} |
1474 |
} |
| 1472 |
SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, CTLTYPE_INT|CTLFLAG_RW, |
1475 |
SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, CTLTYPE_INT|CTLFLAG_RW, |
|
Lines 1476-1481
Link Here
|
| 1476 |
static int |
1479 |
static int |
| 1477 |
sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) |
1480 |
sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) |
| 1478 |
{ |
1481 |
{ |
|
|
1482 |
cpuset_t mask_set; |
| 1483 |
cpumask_t mask; |
| 1479 |
int disable, error; |
1484 |
int disable, error; |
| 1480 |
|
1485 |
|
| 1481 |
disable = hlt_logical_cpus; |
1486 |
disable = hlt_logical_cpus; |
|
Lines 1483-1506
Link Here
|
| 1483 |
if (error || !req->newptr) |
1488 |
if (error || !req->newptr) |
| 1484 |
return (error); |
1489 |
return (error); |
| 1485 |
|
1490 |
|
|
|
1491 |
mask = hlt_cpus_mask; |
| 1486 |
if (disable) |
1492 |
if (disable) |
| 1487 |
hlt_cpus_mask |= logical_cpus_mask; |
1493 |
mask |= logical_cpus_mask; |
| 1488 |
else |
1494 |
if (!hyperthreading_allowed) |
| 1489 |
hlt_cpus_mask &= ~logical_cpus_mask; |
1495 |
mask |= hyperthreading_cpus_mask; |
| 1490 |
|
1496 |
|
| 1491 |
if (! hyperthreading_allowed) |
1497 |
/* Don't disable BSP0 */ |
| 1492 |
hlt_cpus_mask |= hyperthreading_cpus_mask; |
1498 |
if ((mask & all_cpus) == all_cpus) |
|
|
1499 |
mask &= ~(1<<0); |
| 1493 |
|
1500 |
|
| 1494 |
if ((hlt_cpus_mask & all_cpus) == all_cpus) |
1501 |
printf("%s: mask: %d\n", __func__, mask); |
| 1495 |
hlt_cpus_mask &= ~(1<<0); |
|
|
| 1496 |
|
1502 |
|
| 1497 |
hlt_logical_cpus = disable; |
1503 |
CPU_ZERO(&mask_set); |
|
|
1504 |
CPU_SETMASK(~mask & all_cpus, &mask_set); |
| 1505 |
error = cpuset_zero_modify(&mask_set); |
| 1506 |
if (error == 0) |
| 1507 |
hlt_logical_cpus = disable; |
| 1498 |
return (error); |
1508 |
return (error); |
| 1499 |
} |
1509 |
} |
| 1500 |
|
1510 |
|
| 1501 |
static int |
1511 |
static int |
| 1502 |
sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) |
1512 |
sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) |
| 1503 |
{ |
1513 |
{ |
|
|
1514 |
cpuset_t mask_set; |
| 1515 |
cpumask_t mask; |
| 1504 |
int allowed, error; |
1516 |
int allowed, error; |
| 1505 |
|
1517 |
|
| 1506 |
allowed = hyperthreading_allowed; |
1518 |
allowed = hyperthreading_allowed; |
|
Lines 1508-1549
Link Here
|
| 1508 |
if (error || !req->newptr) |
1520 |
if (error || !req->newptr) |
| 1509 |
return (error); |
1521 |
return (error); |
| 1510 |
|
1522 |
|
| 1511 |
#ifdef SCHED_ULE |
1523 |
mask = hlt_cpus_mask; |
| 1512 |
/* |
1524 |
if (hlt_logical_cpus) |
| 1513 |
* SCHED_ULE doesn't allow enabling/disabling HT cores at |
1525 |
mask |= logical_cpus_mask; |
| 1514 |
* run-time. |
1526 |
if (!allowed) |
| 1515 |
*/ |
1527 |
mask |= hyperthreading_cpus_mask; |
| 1516 |
if (allowed != hyperthreading_allowed) |
|
|
| 1517 |
return (ENOTSUP); |
| 1518 |
return (error); |
| 1519 |
#endif |
| 1520 |
|
1528 |
|
| 1521 |
if (allowed) |
1529 |
/* Don't disable BSP0 */ |
| 1522 |
hlt_cpus_mask &= ~hyperthreading_cpus_mask; |
1530 |
if ((mask & all_cpus) == all_cpus) |
| 1523 |
else |
1531 |
mask &= ~(1<<0); |
| 1524 |
hlt_cpus_mask |= hyperthreading_cpus_mask; |
|
|
| 1525 |
|
1532 |
|
| 1526 |
if (logical_cpus_mask != 0 && |
1533 |
CPU_ZERO(&mask_set); |
| 1527 |
(hlt_cpus_mask & logical_cpus_mask) == logical_cpus_mask) |
1534 |
CPU_SETMASK(~mask & all_cpus, &mask_set); |
| 1528 |
hlt_logical_cpus = 1; |
1535 |
error = cpuset_zero_modify(&mask_set); |
| 1529 |
else |
1536 |
if (error == 0) |
| 1530 |
hlt_logical_cpus = 0; |
1537 |
hyperthreading_allowed = allowed; |
| 1531 |
|
|
|
| 1532 |
if ((hlt_cpus_mask & all_cpus) == all_cpus) |
| 1533 |
hlt_cpus_mask &= ~(1<<0); |
| 1534 |
|
| 1535 |
hyperthreading_allowed = allowed; |
| 1536 |
return (error); |
1538 |
return (error); |
| 1537 |
} |
1539 |
} |
| 1538 |
|
1540 |
|
| 1539 |
static void |
1541 |
static void |
| 1540 |
cpu_hlt_setup(void *dummy __unused) |
1542 |
cpu_hlt_setup(void *dummy __unused) |
| 1541 |
{ |
1543 |
{ |
|
|
1544 |
cpuset_t mask_set; |
| 1542 |
|
1545 |
|
| 1543 |
if (logical_cpus_mask != 0) { |
1546 |
if (logical_cpus_mask != 0) { |
| 1544 |
TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", |
1547 |
TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", |
| 1545 |
&hlt_logical_cpus); |
1548 |
&hlt_logical_cpus); |
|
|
1549 |
if (hlt_logical_cpus != 0) { |
| 1550 |
CPU_ZERO(&mask_set); |
| 1551 |
CPU_SETMASK(~logical_cpus_mask & all_cpus, &mask_set); |
| 1552 |
if (cpuset_zero_modify(&mask_set) == 0) |
| 1553 |
hlt_logical_cpus = 1; |
| 1554 |
else |
| 1555 |
hlt_logical_cpus = 0; |
| 1556 |
} |
| 1546 |
sysctl_ctx_init(&logical_cpu_clist); |
1557 |
sysctl_ctx_init(&logical_cpu_clist); |
|
|
1558 |
SYSCTL_ADD_UINT(&logical_cpu_clist, |
| 1559 |
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, |
| 1560 |
"all_cpus_mask", CTLTYPE_INT|CTLFLAG_RD, |
| 1561 |
&all_cpus, 0, ""); |
| 1547 |
SYSCTL_ADD_PROC(&logical_cpu_clist, |
1562 |
SYSCTL_ADD_PROC(&logical_cpu_clist, |
| 1548 |
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, |
1563 |
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, |
| 1549 |
"hlt_logical_cpus", CTLTYPE_INT|CTLFLAG_RW, 0, 0, |
1564 |
"hlt_logical_cpus", CTLTYPE_INT|CTLFLAG_RW, 0, 0, |
|
Lines 1553-1561
Link Here
|
| 1553 |
"logical_cpus_mask", CTLTYPE_INT|CTLFLAG_RD, |
1568 |
"logical_cpus_mask", CTLTYPE_INT|CTLFLAG_RD, |
| 1554 |
&logical_cpus_mask, 0, ""); |
1569 |
&logical_cpus_mask, 0, ""); |
| 1555 |
|
1570 |
|
| 1556 |
if (hlt_logical_cpus) |
|
|
| 1557 |
hlt_cpus_mask |= logical_cpus_mask; |
| 1558 |
|
| 1559 |
/* |
1571 |
/* |
| 1560 |
* If necessary for security purposes, force |
1572 |
* If necessary for security purposes, force |
| 1561 |
* hyperthreading off, regardless of the value |
1573 |
* hyperthreading off, regardless of the value |
|
Lines 1566-1573
Link Here
|
| 1566 |
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, |
1578 |
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, |
| 1567 |
"hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, |
1579 |
"hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, |
| 1568 |
0, 0, sysctl_hyperthreading_allowed, "IU", ""); |
1580 |
0, 0, sysctl_hyperthreading_allowed, "IU", ""); |
| 1569 |
if (! hyperthreading_allowed) |
|
|
| 1570 |
hlt_cpus_mask |= hyperthreading_cpus_mask; |
| 1571 |
} |
1581 |
} |
| 1572 |
} |
1582 |
} |
| 1573 |
} |
1583 |
} |
|
Lines 1627-1630
Link Here
|
| 1627 |
} |
1637 |
} |
| 1628 |
SYSINIT(mp_ipi_intrcnt, SI_SUB_INTR, SI_ORDER_MIDDLE, mp_ipi_intrcnt, NULL); |
1638 |
SYSINIT(mp_ipi_intrcnt, SI_SUB_INTR, SI_ORDER_MIDDLE, mp_ipi_intrcnt, NULL); |
| 1629 |
#endif |
1639 |
#endif |
| 1630 |
|
|
|