forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork0
Commit2279f54
sched/deadline: Fix priority inheritance with multiple scheduling classes
Glenn reported that "an application [he developed produces] a BUG indeadline.c when a SCHED_DEADLINE task contends with CFS tasks on nestedPTHREAD_PRIO_INHERIT mutexes. I believe the bug is triggered when a CFStask that was boosted by a SCHED_DEADLINE task boosts another CFS task(nested priority inheritance). ------------[ cut here ]------------ kernel BUG at kernel/sched/deadline.c:1462! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 12 PID: 19171 Comm: dl_boost_bug Tainted: ... Hardware name: ... RIP: 0010:enqueue_task_dl+0x335/0x910 Code: ... RSP: 0018:ffffc9000c2bbc68 EFLAGS: 00010002 RAX: 0000000000000009 RBX: ffff888c0af94c00 RCX: ffffffff81e12500 RDX: 000000000000002e RSI: ffff888c0af94c00 RDI: ffff888c10b22600 RBP: ffffc9000c2bbd08 R08: 0000000000000009 R09: 0000000000000078 R10: ffffffff81e12440 R11: ffffffff81e1236c R12: ffff888bc8932600 R13: ffff888c0af94eb8 R14: ffff888c10b22600 R15: ffff888bc8932600 FS: 00007fa58ac55700(0000) GS:ffff888c10b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa58b523230 CR3: 0000000bf44ab003 CR4: 00000000007606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: ? intel_pstate_update_util_hwp+0x13/0x170 rt_mutex_setprio+0x1cc/0x4b0 task_blocks_on_rt_mutex+0x225/0x260 rt_spin_lock_slowlock_locked+0xab/0x2d0 rt_spin_lock_slowlock+0x50/0x80 hrtimer_grab_expiry_lock+0x20/0x30 hrtimer_cancel+0x13/0x30 do_nanosleep+0xa0/0x150 hrtimer_nanosleep+0xe1/0x230 ? __hrtimer_init_sleeper+0x60/0x60 __x64_sys_nanosleep+0x8d/0xa0 do_syscall_64+0x4a/0x100 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7fa58b52330d ... ---[ end trace 0000000000000002 ]—He also provided a simple reproducer creating the situation below: So the execution order of locking steps are the following (N1 and N2 are non-deadline tasks. D1 is a deadline task. M1 and M2 are mutexes that are enabled * with priority inheritance.) Time moves forward as this timeline goes down: N1 N2 D1 | | | | | | Lock(M1) | | | | | | Lock(M2) | | | | | | Lock(M2) | | | | Lock(M1) | | (!!bug triggered!) |Daniel reported a similar situation as well, by just letting ksoftirqdrun with DEADLINE (and eventually block on a mutex).Problem is that boosted entities (Priority Inheritance) use staticDEADLINE parameters of the top priority waiter. However, there might becases where top waiter could be a non-DEADLINE entity that is currentlyboosted by a DEADLINE entity from a different lock chain (i.e., nestedpriority chains involving entities of non-DEADLINE classes). In thiscase, top waiter static DEADLINE parameters could be null (initializedto 0 at fork()) and replenish_dl_entity() would hit a BUG().Fix this by keeping track of the original donor and using its parameterswhen a task is boosted.Reported-by: Glenn Elliott <glenn@aurora.tech>Reported-by: Daniel Bristot de Oliveira <bristot@redhat.com>Signed-off-by: Juri Lelli <juri.lelli@redhat.com>Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>Tested-by: Daniel Bristot de Oliveira <bristot@redhat.com>Link:https://lkml.kernel.org/r/20201117061432.517340-1-juri.lelli@redhat.com1 parentec618b8 commit2279f54
3 files changed
+68
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
555 | 554 | | |
556 | 555 | | |
557 | 556 | | |
| |||
570 | 569 | | |
571 | 570 | | |
572 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
573 | 581 | | |
574 | 582 | | |
575 | 583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4912 | 4912 | | |
4913 | 4913 | | |
4914 | 4914 | | |
4915 | | - | |
| 4915 | + | |
4916 | 4916 | | |
4917 | | - | |
4918 | | - | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
4919 | 4920 | | |
4920 | 4921 | | |
4921 | 4922 | | |
4922 | | - | |
| 4923 | + | |
4923 | 4924 | | |
4924 | 4925 | | |
4925 | 4926 | | |
4926 | 4927 | | |
4927 | 4928 | | |
4928 | | - | |
| 4929 | + | |
4929 | 4930 | | |
4930 | 4931 | | |
4931 | 4932 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
46 | 68 | | |
47 | 69 | | |
48 | 70 | | |
| |||
698 | 720 | | |
699 | 721 | | |
700 | 722 | | |
701 | | - | |
| 723 | + | |
702 | 724 | | |
703 | 725 | | |
704 | 726 | | |
| |||
736 | 758 | | |
737 | 759 | | |
738 | 760 | | |
739 | | - | |
740 | | - | |
| 761 | + | |
741 | 762 | | |
742 | 763 | | |
743 | 764 | | |
744 | 765 | | |
745 | | - | |
| 766 | + | |
746 | 767 | | |
747 | 768 | | |
748 | 769 | | |
749 | 770 | | |
750 | 771 | | |
751 | 772 | | |
752 | | - | |
753 | | - | |
| 773 | + | |
| 774 | + | |
754 | 775 | | |
755 | 776 | | |
756 | 777 | | |
| |||
763 | 784 | | |
764 | 785 | | |
765 | 786 | | |
766 | | - | |
767 | | - | |
| 787 | + | |
| 788 | + | |
768 | 789 | | |
769 | 790 | | |
770 | 791 | | |
| |||
778 | 799 | | |
779 | 800 | | |
780 | 801 | | |
781 | | - | |
782 | | - | |
| 802 | + | |
| 803 | + | |
783 | 804 | | |
784 | 805 | | |
785 | 806 | | |
| |||
812 | 833 | | |
813 | 834 | | |
814 | 835 | | |
815 | | - | |
816 | | - | |
| 836 | + | |
817 | 837 | | |
818 | 838 | | |
819 | 839 | | |
| |||
835 | 855 | | |
836 | 856 | | |
837 | 857 | | |
838 | | - | |
| 858 | + | |
839 | 859 | | |
840 | | - | |
| 860 | + | |
841 | 861 | | |
842 | 862 | | |
843 | 863 | | |
| |||
922 | 942 | | |
923 | 943 | | |
924 | 944 | | |
925 | | - | |
926 | | - | |
| 945 | + | |
927 | 946 | | |
928 | 947 | | |
929 | 948 | | |
930 | 949 | | |
931 | 950 | | |
932 | | - | |
| 951 | + | |
933 | 952 | | |
934 | 953 | | |
935 | 954 | | |
936 | | - | |
| 955 | + | |
937 | 956 | | |
938 | 957 | | |
939 | 958 | | |
940 | 959 | | |
941 | | - | |
942 | | - | |
| 960 | + | |
| 961 | + | |
943 | 962 | | |
944 | 963 | | |
945 | 964 | | |
| |||
1038 | 1057 | | |
1039 | 1058 | | |
1040 | 1059 | | |
1041 | | - | |
| 1060 | + | |
1042 | 1061 | | |
1043 | 1062 | | |
1044 | 1063 | | |
| |||
1066 | 1085 | | |
1067 | 1086 | | |
1068 | 1087 | | |
1069 | | - | |
| 1088 | + | |
1070 | 1089 | | |
1071 | 1090 | | |
1072 | 1091 | | |
| |||
1156 | 1175 | | |
1157 | 1176 | | |
1158 | 1177 | | |
1159 | | - | |
| 1178 | + | |
1160 | 1179 | | |
1161 | 1180 | | |
1162 | 1181 | | |
| |||
1287 | 1306 | | |
1288 | 1307 | | |
1289 | 1308 | | |
1290 | | - | |
| 1309 | + | |
1291 | 1310 | | |
1292 | 1311 | | |
1293 | 1312 | | |
| |||
1481 | 1500 | | |
1482 | 1501 | | |
1483 | 1502 | | |
1484 | | - | |
1485 | | - | |
| 1503 | + | |
1486 | 1504 | | |
1487 | 1505 | | |
1488 | 1506 | | |
| |||
1493 | 1511 | | |
1494 | 1512 | | |
1495 | 1513 | | |
1496 | | - | |
| 1514 | + | |
1497 | 1515 | | |
1498 | | - | |
| 1516 | + | |
1499 | 1517 | | |
1500 | 1518 | | |
1501 | 1519 | | |
| |||
1512 | 1530 | | |
1513 | 1531 | | |
1514 | 1532 | | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
| 1533 | + | |
1528 | 1534 | | |
1529 | 1535 | | |
1530 | 1536 | | |
| |||
1557 | 1563 | | |
1558 | 1564 | | |
1559 | 1565 | | |
1560 | | - | |
| 1566 | + | |
1561 | 1567 | | |
1562 | 1568 | | |
1563 | 1569 | | |
| |||
1594 | 1600 | | |
1595 | 1601 | | |
1596 | 1602 | | |
1597 | | - | |
| 1603 | + | |
1598 | 1604 | | |
1599 | 1605 | | |
1600 | 1606 | | |
| |||
2787 | 2793 | | |
2788 | 2794 | | |
2789 | 2795 | | |
2790 | | - | |
2791 | 2796 | | |
2792 | 2797 | | |
2793 | 2798 | | |
2794 | 2799 | | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
2795 | 2804 | | |
2796 | 2805 | | |
2797 | 2806 | | |
| |||
0 commit comments
Comments
(0)