Skip to content

Comments

feat: get_lowest_priority_info#258

Merged
Koichi98 merged 20 commits intomainfrom
lo_priority_all_search
Dec 26, 2024
Merged

feat: get_lowest_priority_info#258
Koichi98 merged 20 commits intomainfrom
lo_priority_all_search

Conversation

@kobayu858
Copy link
Contributor

@kobayu858 kobayu858 commented Dec 24, 2024

Implementation of a function to obtain information on the lowest priority task in all searches.

Priorities are compared with the scheduler priority first, and if they are equal, the task priority is used for comparison.
The u64 priority value stores the scheduler priority in the upper 8 bits and the task priority in the lower 56 bits.
As a result, the aforementioned logic is naturally implemented by a simple u64 comparison.

Comparison of Scheduler Priority: 1, Task Priority: 1000 with Scheduler Priority: 2, Task Priority: 500
0x10000000003e8 < 0x20000000001f4

Comparison of Scheduler Priority: 1, Task Priority: 1000 with Scheduler Priority: 1, Task Priority: 2000
0x10000000003e8 < 0x10000000007d0

Test

[         4191 INFO] [4191433] Start test_sched_preempt at cpu_id: 1
[         4192 INFO] [4192279] GEDF is start at cpu_id: 3
[         4192 INFO] [4192420] FIFO is start at cpu_id: 2
[         5192 DEBUG] /home/emb4/awkernel/applications/tests/test_sched_preempt/src/lib.rs:69: Task ID: 1, sched_priority: 2, task_priority: 256

Among the FIFO tasks with low scheduler priority, the task with ID 1 that is executed first is returned.

kobayu858 added 9 commits December 24, 2024 13:16
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
@kobayu858 kobayu858 requested a review from Koichi98 December 24, 2024 05:05
@Koichi98 Koichi98 requested a review from atsushi421 December 25, 2024 01:58
@atsushi421
Copy link
Contributor

@kobayu858

comment 1: Unless you have a specific reason, I think the comparison based on the last execution time is unnecessary. Simple logic is better.

comment 2: I recommend not triggering preemption if the task priority is the same for performance. How do you think?

@Koichi98 Koichi98 requested a review from ytakano December 25, 2024 04:03
@kobayu858
Copy link
Contributor Author

@atsushi421
answer 1: At this point, it certainly does not seem necessary to consider the last execution time. However, by removing this, in the case of equal priority, the one with the fastest CPUID will choose the lowest priority. This point may need to be considered in the future.

answer 2: Certainly performance would be better without preemption at the same task priority. Thank you very much.
Also, since it is no longer necessary to compare by CPUID, remove it.

@kobayu858
Copy link
Contributor Author

Simulate for answer1.

Assume that there are tasks as follows.
Note that the priority 0 is the highest priority and 99 is the lowest priority.
Task(Sched Priority, Task Priority)

Tasks:

Task1(3, 10)
Task2(2, 15)
Task3(3, 10)
Task4(1, 20)

The following steps.

Step1

CPU1: Task1(3, 10)
CPU2: Task2(2, 15)
CPU3: Task3(3, 10)

Step2

Wake up Task4(1, 20)

CPU1: Task1(3, 10)
CPU2: Task2(2, 15)
CPU3: Task3(3, 10)

Step3

sends an IPI to CPU1

CPU1: Task1(3, 10)
CPU2: Task2(2, 15)
CPU3: Task3(3, 10)

Step4

CPU1: Receive the IPI and switch Task1(3, 10) to Task4(1, 20)
CPU2: Task2(2, 15)
CPU3: Task3(3, 10)

Thus, when a high priority task wakes while other tasks of the same priority are running, the one with the earlier CPUID is always preempted.

Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
kobayu858 added 7 commits December 25, 2024 20:09
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
@kobayu858 kobayu858 requested a review from ytakano December 25, 2024 11:52
@kobayu858 kobayu858 marked this pull request as draft December 25, 2024 11:54
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
@kobayu858 kobayu858 marked this pull request as ready for review December 25, 2024 12:18
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
@atsushi421 atsushi421 self-requested a review December 26, 2024 02:43
Copy link
Contributor

@atsushi421 atsushi421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Koichi98 Koichi98 merged commit 619216d into main Dec 26, 2024
1 check passed
@kobayu858 kobayu858 deleted the lo_priority_all_search branch April 14, 2025 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants