Skip to content

add arm64 support for clock frequency helpers#79

Closed
sdimitro wants to merge 1 commit intoPlatformLab:mainfrom
sdimitro:sdimitro/arm64-compat
Closed

add arm64 support for clock frequency helpers#79
sdimitro wants to merge 1 commit intoPlatformLab:mainfrom
sdimitro:sdimitro/arm64-compat

Conversation

@sdimitro
Copy link
Copy Markdown
Contributor

@sdimitro sdimitro commented Apr 7, 2026

Without this patch, building HomaModule on arm64 fails with the following message:

  error: 'cpu_khz' undeclared (first use in this function)

homa_clock() calls get_cycles(), whose backing source is arch-specific: RDTSC on x86 (frequency tsc_khz) and the generic timer on arm64 (frequency arch_timer_get_cntfrq()).

Make homa_clock_khz() return the correct value per arch:

  • x86: tsc_khz
  • arm64: arch_timer_get_cntfrq() / 1000
  • other: 1000000 (fallback)

Guard the tsc_khz-dependent scaling in homa_metrics_print() behind CONFIG_X86 and emit raw cycle counts on other arches where Linux and homa_clock() share the same counter.

Replace bare tsc_khz references in timetrace.c with homa_clock_khz() so the emitted cpu_khz header is correct on all architectures.

homa_clock() calls get_cycles(), whose backing source is
arch-specific: RDTSC on x86 (frequency tsc_khz) and the
generic timer on arm64 (frequency arch_timer_get_cntfrq()).

Make homa_clock_khz() return the correct value per arch:
 - x86:   tsc_khz  (not cpu_khz -- the kernel tracks them
          separately and they can diverge)
 - arm64: arch_timer_get_cntfrq() / 1000
 - other: 1000000 (fallback)

Guard the tsc_khz-dependent scaling in homa_metrics_print()
behind CONFIG_X86 and emit raw cycle counts on other arches
where Linux and homa_clock() share the same counter.

Replace bare tsc_khz references in timetrace.c with
homa_clock_khz() so the emitted cpu_khz header is correct
on all architectures.

Signed-off-by: Serapheim Dimitropoulos <sdimitropoulos@coreweave.com>
@sdimitro sdimitro force-pushed the sdimitro/arm64-compat branch from d7afcd1 to 2bae9a4 Compare April 7, 2026 15:18
@sdimitro sdimitro marked this pull request as ready for review April 7, 2026 15:36
@johnousterhout
Copy link
Copy Markdown
Member

Thanks for submitting this PR; I am merging it now. I simplified the patch a bit by eliminating the frequency scaling code in homa_metrics.c entirely. That code was leftover from a time when Homa didn't use get_cycles() on x86's; it should have been removed when Homa switched back to get_cycles().

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.

2 participants