Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion homa_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#ifndef __UPSTREAM__ /* See strip.py */
#include "homa.h"
#include <linux/version.h>
#ifdef CONFIG_ARM64
#include <clocksource/arm_arch_timer.h>
#endif
#include "homa_devel.h"
#else /* See strip.py */
#include <linux/homa.h>
Expand Down Expand Up @@ -842,7 +845,13 @@ static inline u64 homa_clock_khz(void)
return 1000000;
#else /* __UNIT_TEST__ */
#ifndef __UPSTREAM__ /* See strip.py */
return cpu_khz;
#ifdef CONFIG_X86
return tsc_khz;
#elif defined(CONFIG_ARM64)
return arch_timer_get_cntfrq() / 1000;
#else
return 1000000;
#endif
#else /* See strip.py */
return 1000000;
#endif /* See strip.py */
Expand Down
15 changes: 14 additions & 1 deletion homa_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,26 @@ char *homa_metrics_print(void)
M("bypass_softirq_cycles", m->bypass_softirq_cycles,
"Time spent in homa_softirq during bypass from GRO\n");

/* Adjust stats gathered in Linux that use rdtsc. */
/* Adjust stats gathered in Linux via get_cycles (RDTSC on
* x86, arch timer on arm64). On x86 both Linux and
* homa_clock() read the TSC, so the ratio is 1; the
* explicit conversion is kept in case the sources ever
* diverge. On non-x86 the counters are identical, so raw
* values are emitted directly.
*/
#ifdef CONFIG_X86
M("linux_softirq_cycles", m->linux_softirq_cycles *
(homa_clock_khz() / 1000) / (tsc_khz / 1000),
"Time spent in all Linux SoftIRQ\n");
M("napi_cycles", m->napi_cycles * (homa_clock_khz() / 1000) /
(tsc_khz / 1000),
"Time spent in NAPI-level packet handling\n");
#else
M("linux_softirq_cycles", m->linux_softirq_cycles,
"Time spent in all Linux SoftIRQ\n");
M("napi_cycles", m->napi_cycles,
"Time spent in NAPI-level packet handling\n");
#endif
M("linux_softirqd_actions", m->linux_softirqd_actions,
"SoftIRQ actions taken in the background softirqd thread\n");
M("send_cycles", m->send_cycles,
Expand Down
7 changes: 4 additions & 3 deletions timetrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ int tt_proc_open(struct inode *inode, struct file *file)

if (!tt_test_no_khz) {
pf->bytes_available = snprintf(pf->msg_storage, TT_PF_BUF_SIZE,
"cpu_khz: %u\n", tsc_khz);
"cpu_khz: %llu\n",
homa_clock_khz());
}

done:
Expand Down Expand Up @@ -631,7 +632,7 @@ void tt_print_file(char *path)

bytes_used += snprintf(buffer + bytes_used,
sizeof(buffer) - bytes_used,
"cpu_khz: %u\n", tsc_khz);
"cpu_khz: %llu\n", homa_clock_khz());

/* Each iteration of this loop printk's one event. */
while (true) {
Expand Down Expand Up @@ -758,7 +759,7 @@ void tt_printk(void)
}
#endif

pr_err("cpu_khz: %u, start: %llu\n", tsc_khz, start_time);
pr_err("cpu_khz: %llu, start: %llu\n", homa_clock_khz(), start_time);

/* Each iteration of this loop printk's one event. */
while (true) {
Expand Down