Commit 0213b70
sched/uclamp: Fix uclamp_tg_restrict()
Now cpu.uclamp.min acts as a protection, we need to make sure that the
uclamp request of the task is within the allowed range of the cgroup,
that is it is clamp()'ed correctly by tg->uclamp[UCLAMP_MIN] and
tg->uclamp[UCLAMP_MAX].
As reported by Xuewen [1] we can have some corner cases where there's
inversion between uclamp requested by task (p) and the uclamp values of
the taskgroup it's attached to (tg). Following table demonstrates
2 corner cases:
| p | tg | effective
-----------+-----+------+-----------
CASE 1
-----------+-----+------+-----------
uclamp_min | 60% | 0% | 60%
-----------+-----+------+-----------
uclamp_max | 80% | 50% | 50%
-----------+-----+------+-----------
CASE 2
-----------+-----+------+-----------
uclamp_min | 0% | 30% | 30%
-----------+-----+------+-----------
uclamp_max | 20% | 50% | 20%
-----------+-----+------+-----------
With this fix we get:
| p | tg | effective
-----------+-----+------+-----------
CASE 1
-----------+-----+------+-----------
uclamp_min | 60% | 0% | 50%
-----------+-----+------+-----------
uclamp_max | 80% | 50% | 50%
-----------+-----+------+-----------
CASE 2
-----------+-----+------+-----------
uclamp_min | 0% | 30% | 30%
-----------+-----+------+-----------
uclamp_max | 20% | 50% | 30%
-----------+-----+------+-----------
Additionally uclamp_update_active_tasks() must now unconditionally
update both UCLAMP_MIN/MAX because changing the tg's UCLAMP_MAX for
instance could have an impact on the effective UCLAMP_MIN of the tasks.
| p | tg | effective
-----------+-----+------+-----------
old
-----------+-----+------+-----------
uclamp_min | 60% | 0% | 50%
-----------+-----+------+-----------
uclamp_max | 80% | 50% | 50%
-----------+-----+------+-----------
*new*
-----------+-----+------+-----------
uclamp_min | 60% | 0% | *60%*
-----------+-----+------+-----------
uclamp_max | 80% |*70%* | *70%*
-----------+-----+------+-----------
[1] https://lore.kernel.org/lkml/CAB8ipk_a6VFNjiEnHRHkUMBKbA+qzPQvhtNjJ_YNzQhqV_o8Zw@mail.gmail.com/
Fixes: 0c18f2e ("sched/uclamp: Fix wrong implementation of cpu.uclamp.min")
Reported-by: Xuewen Yan <xuewen.yan94@gmail.com>
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210617165155.3774110-1-qais.yousef@arm.com1 parent d7d6070 commit 0213b70
1 file changed
Lines changed: 18 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1403 | 1403 | | |
1404 | 1404 | | |
1405 | 1405 | | |
| 1406 | + | |
1406 | 1407 | | |
1407 | 1408 | | |
| 1409 | + | |
1408 | 1410 | | |
1409 | 1411 | | |
1410 | 1412 | | |
| |||
1415 | 1417 | | |
1416 | 1418 | | |
1417 | 1419 | | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1435 | 1425 | | |
1436 | 1426 | | |
1437 | 1427 | | |
| |||
1630 | 1620 | | |
1631 | 1621 | | |
1632 | 1622 | | |
1633 | | - | |
| 1623 | + | |
1634 | 1624 | | |
| 1625 | + | |
1635 | 1626 | | |
1636 | 1627 | | |
1637 | 1628 | | |
| |||
1651 | 1642 | | |
1652 | 1643 | | |
1653 | 1644 | | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
1657 | 1650 | | |
1658 | 1651 | | |
1659 | 1652 | | |
1660 | 1653 | | |
1661 | 1654 | | |
1662 | 1655 | | |
1663 | 1656 | | |
1664 | | - | |
1665 | | - | |
| 1657 | + | |
1666 | 1658 | | |
1667 | | - | |
1668 | 1659 | | |
1669 | 1660 | | |
1670 | 1661 | | |
1671 | 1662 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
| 1663 | + | |
| 1664 | + | |
1678 | 1665 | | |
1679 | 1666 | | |
1680 | 1667 | | |
| |||
9634 | 9621 | | |
9635 | 9622 | | |
9636 | 9623 | | |
9637 | | - | |
| 9624 | + | |
9638 | 9625 | | |
9639 | 9626 | | |
9640 | 9627 | | |
| |||
0 commit comments