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

riscv_pmp.c: Revert LOG2_CEIL back to run-time log2ceil function #11374

Merged
merged 1 commit into from Dec 12, 2023

Conversation

pussuw
Copy link
Contributor

@pussuw pussuw commented Dec 12, 2023

Summary

The macro LOG2_CEIL is intended to be used in the pre-processor phase. If used run-time it will generate a massive amount of extra code (~3.5K) which is a problem, as the PMP configuration is quite often executed from a first stage bootloader with a limited amount of code memory.

Code size differences pre- and post:

Memory region         Used Size  Region Size  %age Used
            envm:      112064 B     112384 B     99.72%

Memory region         Used Size  Region Size  %age Used
            envm:      108952 B     112384 B     96.95%

Impact

Decrease code footprint of the PMP driver

Testing

MPFS

The macro LOG2_CEIL is intended to be used in the pre-processor phase. If
used run-time it will generate a massive amount of extra code (~3.5K) which
is a problem, as the PMP configuration is quite often executed from a first
stage bootloader with a limited amount of code memory.

Code size differences pre- and post:

Memory region         Used Size  Region Size  %age Used
            envm:      112064 B     112384 B     99.72%

Memory region         Used Size  Region Size  %age Used
            envm:      108952 B     112384 B     96.95%
@xiaoxiang781216 xiaoxiang781216 merged commit 7bcbaa5 into apache:master Dec 12, 2023
26 checks passed
*
****************************************************************************/

static uintptr_t log2ceil(uintptr_t x)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we extract to a common function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that could be useful, I just didn't know where to put it. Does a place for kernel internal / integer math functions exist ?

Copy link
Contributor

Choose a reason for hiding this comment

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

put to include/nuttx/lib/math32.h too.

@pussuw pussuw deleted the pmp_log2ceil branch December 12, 2023 16:55
@jerpelea jerpelea added this to To-Add in Release Notes - 12.4.0 Dec 27, 2023
@jerpelea jerpelea moved this from To-Add to processed in Release Notes - 12.4.0 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants