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 Trace Hook Macros and function that returns the start of the stack. #659

Merged
merged 12 commits into from
Sep 7, 2023

Conversation

conara
Copy link
Contributor

@conara conara commented Apr 5, 2023

Add Trace Hook Macros and function that returns the start of the stack.

The purpose of this pull request is to provide better support for tracing tools such as systemview. Some time ago I made a post on the FreeRTOS forum describing the current problem: https://forums.freertos.org/t/add-additional-tracing-functionality-to-kernel/16513 . This patchset adds a few new trace hooks that can be used by trace tools such as systemview. For now, I've only added support for the Cortex-M7 port, but if the change is a good improvement, I can add support for other ports. Note that this patch set is heavily inspired on the deprecated SystemView patch set.

Test Steps

  • 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.

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

@conara conara requested a review from a team as a code owner April 5, 2023 11:41
tasks.c Outdated
@@ -1708,6 +1708,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
mtCOVERAGE_TEST_MARKER();
}

traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB);
Copy link
Member

Choose a reason for hiding this comment

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

Is this macro needed? A few lines earlier is the traceTASK_SUSPEND(pxTCB) macro (line 1688) So we already know that the function is called and the task is being suspended. Is it necessary to know that the suspension is happening 23 lines of code later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this macro is not necessarily needed.

Copy link
Member

@n9wxu n9wxu left a comment

Choose a reason for hiding this comment

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

traceMOVED_TASK_TO_SUSPEND_LIST seems redundant to traceTASK_SUSPEND.

include/task.h Outdated
*
* @return A pointer to the start of the stack.
*/
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Removed it from the patchset.

@conara
Copy link
Contributor Author

conara commented Apr 6, 2023

traceMOVED_TASK_TO_SUSPEND_LIST seems redundant to traceTASK_SUSPEND.

Removed it from the patchset.

n9wxu
n9wxu previously approved these changes Apr 6, 2023
@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (f13ad77) 94.35% compared to head (6248d98) 94.35%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #659   +/-   ##
=======================================
  Coverage   94.35%   94.35%           
=======================================
  Files           6        6           
  Lines        2446     2446           
  Branches      598      598           
=======================================
  Hits         2308     2308           
  Misses         85       85           
  Partials       53       53           
Flag Coverage Δ
unittests 94.35% <ø> (ø)

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

Files Changed Coverage Δ
tasks.c 94.83% <ø> (ø)

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

@n9wxu
Copy link
Member

n9wxu commented Apr 6, 2023

FreeRTOS.h is failing uncrustify. Please take a look so we can wrap this PR up.

@@ -94,7 +94,7 @@

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired != pdFALSE ) portYIELD(); } while( 0 )
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired != pdFALSE ) { traceISR_EXIT_TO_SCHEDULER(); portYIELD(); } else { traceISR_EXIT(); } } while( 0 )
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit only - I wonder if this could result in confusion when reading the resultant trace if the interrupts is preempted between the execution of the trace macro and the portYIELD.

Copy link
Contributor

@RichardBarry RichardBarry left a comment

Choose a reason for hiding this comment

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

https://www.freertos.org/rtos-trace-macros.html and the reference manula also needs updating to document the new macros - which the PR author can't do themselves.

@conara
Copy link
Contributor Author

conara commented Apr 23, 2023

Good point.

@Mancent Mancent linked an issue May 21, 2023 that may be closed by this pull request
@Skptak
Copy link
Member

Skptak commented May 22, 2023

Hey @conara, thanks for submitting this pull request! I wanted to reach out and ask if you wanted some help with closing out this PR? Or if you had planned on responding to the feedback and closing it out yourself?

n9wxu
n9wxu previously approved these changes Aug 31, 2023
@kar-rahul-aws
Copy link
Member

Hi @RichardBarry
We have updated https://www.freertos.org/rtos-trace-macros.html with the new macro changes for this PR and will be visible after the deployment.
We are keeping these macros ,
traceISR_ENTER
traceISR_EXIT
traceISR_EXIT_TO_SCHEDULER
and not separate ones for SysTick interrupt, since as @conara mentioned , they are called from other ISRs.

@conara
Copy link
Contributor Author

conara commented Sep 5, 2023

Thank you so much for helping me finalize my PR! Due to vacation I forgot this pull request. If I can help, let me know!

@rawalexe
Copy link
Member

rawalexe commented Sep 7, 2023

Just a concern here, why the Cortex-M7 port layer is being updated but no others. The M7 port is only for r0p1 cores which contain a bug - all other core versions should use the M4F port.

From,
Richard Barry.

@rawalexe rawalexe dismissed RichardBarry’s stale review September 7, 2023 23:19

The website has been updated to reflect the changes

@rawalexe rawalexe merged commit 2f94b18 into FreeRTOS:main Sep 7, 2023
15 checks passed
@conara conara mentioned this pull request Sep 18, 2023
2 tasks
aggarg pushed a commit that referenced this pull request Sep 20, 2023
Add trace hook macro for most ports

In pull request #659 we introduced better support for tracing
tools like systemview. This patchset adds support for more
ports as requested in the original pull request.
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.

> - [ ] ```
8 participants