Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set the core affinity for the Timer Svc Task on SMP systems #805

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

sudeep-mohanty
Copy link
Contributor

@sudeep-mohanty sudeep-mohanty commented Sep 22, 2023

Title

Make Timer Service Task core affinity configurable

Description

This PR introduces the configTIMER_SERVICE_TASK_CORE_AFFINITY config option which allows a user to set the core affinity of the Timer Service Task on SMP systems. The motivation to have this feature comes from requests such as this and this on the ESP-IDF repository. It would be nice if the FreeRTOS-Kernel can support this natively.

Test Steps

N.A

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

None

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sudeep-mohanty sudeep-mohanty requested a review from a team as a code owner September 22, 2023 15:19
timers.c Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (1b2b090) 93.66% compared to head (8c1a99a) 93.66%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #805   +/-   ##
=======================================
  Coverage   93.66%   93.66%           
=======================================
  Files           6        6           
  Lines        2526     2526           
  Branches      604      604           
=======================================
  Hits         2366     2366           
  Misses        107      107           
  Partials       53       53           
Flag Coverage Δ
unittests 93.66% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
timers.c 98.77% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@archigup
Copy link
Member

Hey, thanks for the PR!

Could the #if ( configNUMBER_OF_CORES == 1 ) be moved inwards to just around the task create functions? Seems the rest of the logic in the blocks are the same.

@sudeep-mohanty
Copy link
Contributor Author

Thanks for the review @archigup. Updated as suggested.

@chinglee-iot
Copy link
Member

@sudeep-mohanty
Thank you for creating the feedback. The issue in your description indicates that timer task is pinned to core 0 and blocked by higher priority tasks on core 0. As a result, the application watchdog callback can not be called within timeout. The alternative solution also suggests that allowing tasks to run on any core could be a better solution, which is the current setting for timer task. Therefore, this should not be an issue in FreeRTOS SMP.

On the other hand, user can consider to create another task with core affinity to serve application specific requirement instead of changing the affinity of timer task cause it may have effect on software timer service.

@sudeep-mohanty
Copy link
Contributor Author

sudeep-mohanty commented Sep 26, 2023

Thanks for the feedback @chinglee-iot. The idea here is to give users the flexibility of either pinning the timer task to a core or letting it run unpinned. Ofcourse, all issues with a lower priority task getting blocked by a higher priority task remain even on an SMP system irrespective of the task's core affinity, so IMO this PR shouldn't cause change to how the timer task runs in practice. A counter argument could be to let the timer task run on a separate core uninterrupted for a potentially more responsive timer service which is not possible today.

…tems

This PR introduces the configTIMER_SERVICE_TASK_CORE_AFFINITY option
which allows the system to configure the core affinity of the Timer
Service Task on an SMP system. The default affinity of the Timer Service
Task is set to tskNO_AFFINITY which is the current behavior on SMP
systems.

Signed-off-by: Sudeep Mohanty <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Oct 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@aggarg aggarg merged commit 631ae9e into FreeRTOS:main Oct 16, 2023
17 checks passed
n9wxu pushed a commit to n9wxu/FreeRTOS-Kernel that referenced this pull request Oct 26, 2023
…tems (FreeRTOS#805)

This PR introduces the configTIMER_SERVICE_TASK_CORE_AFFINITY option
which allows the system to configure the core affinity of the Timer
Service Task on an SMP system. The default affinity of the Timer Service
Task is set to tskNO_AFFINITY which is the current behavior on SMP
systems.

Signed-off-by: Sudeep Mohanty <[email protected]>
Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
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