From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Fri, 21 Aug 2026 18:37:09 +0200 Subject: [Devel] [PATCH vz10 23/32] mm/memory: build the page fault latency accounting for x86 only In-Reply-To: <20260821163718.187766-1-khorenko@virtuozzo.com> References: <20260821163718.187766-1-khorenko@virtuozzo.com> Message-ID: <20260821163718.187766-24-khorenko@virtuozzo.com> List-Id: From: Eva Kurchatova mm/memory.c accounts the latency of major page faults into the VZ statistics, converting TSC cycles to nanoseconds with CLKS2NSEC(), which is built on tsc_khz from asm/tsc.h. Both the header and the variable are x86-only, so generic mm/memory.c does not compile elsewhere - User Mode Linux, which we now want for KUnit, has no asm/tsc.h at all: mm/memory.c:90:10: fatal error: asm/tsc.h: No such file or directory Include the header on x86 only and let CLKS2NSEC() evaluate to 0 on other architectures, so the accounting keeps working where there is a cycle counter to read and reports no latency where there is not. Feature: ve: extra statistics (mm, latency) https://virtuozzo.atlassian.net/browse/VSTOR-134732 Signed-off-by: Eva Kurchatova Signed-off-by: Konstantin Khorenko --- mm/memory.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 837194e87664..5e414c68f3a9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -87,7 +87,9 @@ #include #include #include +#ifdef CONFIG_X86 #include +#endif #include "pgalloc-track.h" #include "internal.h" @@ -4455,7 +4457,12 @@ static struct folio *alloc_swap_folio(struct vm_fault *vmf) static DECLARE_WAIT_QUEUE_HEAD(swapcache_wq); +#ifdef CONFIG_X86 #define CLKS2NSEC(c) ((c) * 1000000 / tsc_khz) +#else +/* No cycle counter to convert from outside x86 */ +#define CLKS2NSEC(c) (0) +#endif /* * We enter with non-exclusive mmap_lock (to exclude vma changes, -- 2.47.1