Repository navigation
Conversation
…EVENTS. Make.defs put "#ifdef CONFIG_ARCH_PERF_EVENTS" around the line that adds intel64_perf.c. Make reads a line that starts with "#" as a comment, so the Make build compiled intel64_perf.c in every configuration. CMakeLists.txt already adds the file only with CONFIG_ARCH_PERF_EVENTS. Use ifeq, as for the other optional files. The CONFIG_ARCH_HAVE_PERF_EVENTS check in intel64_perf.c is then always true, because CONFIG_ARCH_PERF_EVENTS depends on it: remove it. [skip-cmake-parity]: CMakeLists.txt already has this condition. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
intel64_perf.c counts the TSC and converts with g_x86_64_timer_freq. Only the TSC DEADLINE and APIC timers set this frequency. With the HPET timer it is 0: perf_getfreq() returns 0 and up_perf_convert() divides by 0. CONFIG_ARCH_PERF_EVENTS is on by default with SCHED_IRQMONITOR and SCHED_CRITMONITOR, so qemu-intel64:citest_smp (HPET) has it. Select ARCH_HAVE_PERF_EVENTS from ARCH_INTEL64_HAVE_TSC, not from ARCH_X86_64. With the HPET timer, drivers/timers/arch_alarm.c then gives up_perf_*() from the HPET counter and its frequency. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
xiaoxiang781216
approved these changes
Nov 17, 2026
|
casaroli
marked this pull request as ready for review
November 17, 2026 23:34
casaroli
marked this pull request as draft
November 18, 2026 00:39
casaroli
marked this pull request as ready for review
November 18, 2026 00:39
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.
depends-on: /pull/21975
Summary
On x86_64 (intel64),
intel64_perf.cgivesup_perf_*()from the TSC (rdtscp) and converts withg_x86_64_timer_freq. Only the TSC DEADLINE and APIC timers set this frequency (x86_64_timer_calibrate_freq()). With the HPET timer (CONFIG_ARCH_INTEL64_HPET_ALARM) it is 0:perf_getfreq()returns 0 andup_perf_convert()divides by 0.CONFIG_ARCH_PERF_EVENTSis on by default withSCHED_IRQMONITORandSCHED_CRITMONITOR, soqemu-intel64:citest_smp(HPET,SCHED_IRQMONITOR) has it. A read of/proc/irqsthen divides by 0 in the kernel: inknsh_romfsthe system hangs, in the flatnshthe shell ends with SIGFPE. ostest reportsPerformance frequency = 0 Hz.The second commit selects
ARCH_HAVE_PERF_EVENTSfromARCH_INTEL64_HAVE_TSC(the two TSC timers) instead of fromARCH_X86_64. With the HPET timer,CONFIG_ARCH_PERF_EVENTSis then not available, anddrivers/timers/arch_alarm.cgivesup_perf_*()from the HPET counter with the HPET frequency, as on other architectures without a cycle counter.The first commit fixes
arch/x86_64/src/intel64/Make.defs, which put#ifdef CONFIG_ARCH_PERF_EVENTSaround the line that addsintel64_perf.c. Make reads a line that starts with#as a comment, so the Make build compiledintel64_perf.cin every configuration.CMakeLists.txtalready adds the file only withCONFIG_ARCH_PERF_EVENTS. The commit usesifeq, and removes theCONFIG_ARCH_HAVE_PERF_EVENTScheck insideintel64_perf.c, which is then always true.Impact
x86_64 intel64 only. With the TSC DEADLINE or APIC timer, nothing changes when
CONFIG_ARCH_PERF_EVENTSis on; when it is off, the Make build no longer compiles the unusedintel64_perf.c, as the CMake build already does. With the HPET timer,CONFIG_ARCH_PERF_EVENTSis not available, and perf events count the HPET. An HPET read is slower thanrdtscp; ostest under KVM takes the same time as on master (see Testing). All qemu-intel64 defconfigs give the samemake savedefconfig. No API change.Testing
QEMU 10.2.2 under KVM, GCC 12.3 in the NuttX CI image, make. "HPET" means
ARCH_INTEL64_HPET_ALARMandINTEL64_HPETinstead of the TSC deadline timer.+monmeansSCHED_IRQMONITORandARCH_PERF_EVENTSon (on this PRARCH_PERF_EVENTSis not available with the HPET); the flatnshalso hasSCHED_CRITMONITOR.knsh_romfs(kernel), HPET, +moncat /proc/irqsnsh(flat), HPET, +moncat /proc/irqsps: a newsh)nsh, HPET, +monPerformance frequency = 0 Hz,WARNING - Performance frequency is invalid, exit 0ARCH_PERF_EVENTSnot available: the perf test of ostest is skipped)nsh, HPET,SCHED_IRQMONITOR(+SCHED_CRITMONITOR)nsh, TSC deadline, +moncat /proc/irqs, ostestPerformance frequency = 2600000000 Hz, exit 0All 17 qemu-intel64 defconfigs build (make) with this PR and the other three intel64 fixes applied, and
make savedefconfiggives the same defconfig as on master for each.x86_64 has no protected build. Not built: CMake (no CMake file change; the Kconfig change applies to both). No CI test covers this: CI builds the x86_64 defconfigs but runs none of them.
tools/checkpatch.sh -c -u -m -gpasses.