testing/ostest: build the perf test only where it can link - #3676
Open
casaroli wants to merge 1 commit into
Open
testing/ostest: build the perf test only where it can link#3676casaroli wants to merge 1 commit into
casaroli wants to merge 1 commit into
Conversation
perf_gettime() and perf_getfreq() are kernel functions, defined in sched/clock/clock_perf.c. Neither appears in syscall.csv, and libc supplies only perf_gettime(), under CONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS. So a protected or kernel build cannot resolve either of them from user space: ostest/perf_gettime.c:91: undefined reference to `perf_gettime' ostest/perf_gettime.c:184: undefined reference to `perf_getfreq' make[1]: *** [nuttx_user.elf] Error 1 The call in user_main() is guarded by CONFIG_ARCH_PERF_EVENTS && !CONFIG_ARCH_PERF_EVENTS_USER_ACCESS -- which is exactly the case where the symbols are kernel-only -- so every such configuration fails to link. mps3-an547:knsh is one: it sets CONFIG_SCHED_IRQMONITOR, which makes ARCH_PERF_EVENTS default y. mps2-an521:knsh escapes only because it sets neither monitor, leaving ARCH_PERF_EVENTS off, so the call compiles out and the archive member is never pulled in. Require CONFIG_BUILD_FLAT, where ostest links against the kernel's own copy. No configuration that runs the test today stops running it. Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com> Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
xiaoxiang781216
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
testing/ostestcannot link in a protected or kernel build wheneverCONFIG_ARCH_PERF_EVENTSis set.perf_gettime()andperf_getfreq()are kernel functions, defined insched/clock/clock_perf.c. Neither appears insyscall.csv, andlibs/libc/sched/clock_perf.csupplies onlyperf_gettime(), gated onCONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS. So user space has no way to reacheither symbol unless the build is flat.
The pieces disagree about when to use them:
testing/ostest/Makefile/CMakeLists.txtcompileperf_gettime.cwhenCONFIG_ARCH_HAVE_PERF_EVENTSis set.ostest_main.ccallsperf_gettime_test()whenCONFIG_ARCH_PERF_EVENTSis set and
CONFIG_ARCH_PERF_EVENTS_USER_ACCESSis not — which is exactlythe case where the symbols are kernel-only.
So any protected/kernel configuration with
ARCH_PERF_EVENTS=yfails to link:mps3-an547:knshis one, because its defconfig setsCONFIG_SCHED_IRQMONITOR,which makes
ARCH_PERF_EVENTSdefaulty.mps2-an521:knshandmps2-an500:knshescape only because they set neitherSCHED_IRQMONITORnorSCHED_CRITMONITOR, soARCH_PERF_EVENTSis off, the call compiles out andthe archive member is never pulled in.
This adds
CONFIG_BUILD_FLATto all four sites, which is where ostest linksagainst the kernel's own copy of these functions.
Impact
No configuration that runs this test today stops running it — flat builds are
untouched. Protected and kernel builds that previously could not link ostest
at all now build, and skip the one test they could never have executed.
Users affected: anyone enabling
TESTING_OSTESTon aBUILD_PROTECTEDorBUILD_KERNELtarget withSCHED_IRQMONITOR,SCHED_CRITMONITOR,RPMSG_PINGorSEGGER_SYSVIEWenabled (the four that makeARCH_PERF_EVENTSdefaulty).No API, Kconfig or documentation change.
Testing
Host: macOS 15.5 (Darwin 25.5.0), Apple Silicon;
arm-none-eabi-gcc14.2.Rel1;QEMU 11.0.3.
Target:
mps3-an547:knsh— Armv8-M, Cortex-M55,BUILD_PROTECTED, theconfiguration that exposed this.
Before — link fails:
After — both blobs link:
and the image boots to NSH and runs
ostestunderqemu-system-arm -M mps3-an547.The flat path is unchanged by construction — the patch only ever adds a
condition, so no build that compiled
perf_gettime.cbefore and stillsatisfies
CONFIG_BUILD_FLATis affected.