Skip to content

add arm64 support for clock frequency helpers#79

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

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

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

1 participant