Repository navigation
Commit ff1cdc9
sched/core: Introduce set_next_task() helper for better code readability
When we pick the next task, we will do the following for the task:
1) p->se.exec_start = rq_clock_task(rq);
2) dequeue_pushable(_dl)_task(rq, p);
When we call set_curr_task(), we also need to do the same thing
above. In rt.c, the code at 1) is in the _pick_next_task_rt()
and the code at 2) is in the pick_next_task_rt(). If we put two
operations in one function, maybe better. So, we introduce a new
function set_next_task(), which is responsible for doing the above.
By introducing the function we can get rid of calling the
dequeue_pushable(_dl)_task() directly(We can call set_next_task())
in pick_next_task() and have better code readability and reuse.
In set_curr_task_rt(), we also can call set_next_task().
Do this things such that we end up with:
static struct task_struct *pick_next_task(struct rq *rq,
struct task_struct *prev,
struct rq_flags *rf)
{
/* do something else ... */
put_prev_task(rq, prev);
/* pick next task p */
set_next_task(rq, p);
/* do something else ... */
}
put_prev_task() can match set_next_task(), which can make the
code more readable.
Signed-off-by: Muchun Song <smuchun@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20181026131743.21786-1-smuchun@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>1 parent 3f130a3 commit ff1cdc9
2 files changed
Lines changed: 21 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1695 | 1695 | | |
1696 | 1696 | | |
1697 | 1697 | | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
1698 | 1706 | | |
1699 | 1707 | | |
1700 | 1708 | | |
| |||
1750 | 1758 | | |
1751 | 1759 | | |
1752 | 1760 | | |
1753 | | - | |
1754 | 1761 | | |
1755 | | - | |
1756 | | - | |
| 1762 | + | |
1757 | 1763 | | |
1758 | 1764 | | |
1759 | 1765 | | |
| |||
1808 | 1814 | | |
1809 | 1815 | | |
1810 | 1816 | | |
1811 | | - | |
1812 | | - | |
1813 | | - | |
1814 | | - | |
1815 | | - | |
1816 | | - | |
| 1817 | + | |
1817 | 1818 | | |
1818 | 1819 | | |
1819 | 1820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1498 | 1498 | | |
1499 | 1499 | | |
1500 | 1500 | | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
1501 | 1509 | | |
1502 | 1510 | | |
1503 | 1511 | | |
| |||
1518 | 1526 | | |
1519 | 1527 | | |
1520 | 1528 | | |
1521 | | - | |
1522 | 1529 | | |
1523 | 1530 | | |
1524 | 1531 | | |
| |||
1527 | 1534 | | |
1528 | 1535 | | |
1529 | 1536 | | |
1530 | | - | |
1531 | | - | |
1532 | | - | |
1533 | | - | |
| 1537 | + | |
1534 | 1538 | | |
1535 | 1539 | | |
1536 | 1540 | | |
| |||
1573 | 1577 | | |
1574 | 1578 | | |
1575 | 1579 | | |
1576 | | - | |
1577 | | - | |
| 1580 | + | |
1578 | 1581 | | |
1579 | 1582 | | |
1580 | 1583 | | |
| |||
2355 | 2358 | | |
2356 | 2359 | | |
2357 | 2360 | | |
2358 | | - | |
2359 | | - | |
2360 | | - | |
2361 | | - | |
2362 | | - | |
2363 | | - | |
| 2361 | + | |
2364 | 2362 | | |
2365 | 2363 | | |
2366 | 2364 | | |
| |||
0 commit comments