[Devel] [PATCH RHEL10 COMMIT] mm/memory: build the page fault latency accounting for x86 only

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 21 19:42:23 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.6.vz10
------>
commit 490bd4688e3da92f9e7ab0c9675db136ab230749
Author: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Date:   Fri Aug 21 18:37:09 2026 +0200

    mm/memory: build the page fault latency accounting for x86 only
    
    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 <eva.kurchatova at virtuozzo.com>
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memory.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 837194e87664c..5e414c68f3a9c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -87,7 +87,9 @@
 #include <linux/uaccess.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#ifdef CONFIG_X86
 #include <asm/tsc.h>
+#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,


More information about the Devel mailing list