diff mbox series

[RFC,V1,6/6] sched/numa: Allow scanning of shared VMAs

Message ID 0ff0d56b88a64e2017b427f37b15ab41aa5d4019.1693287931.git.raghavendra.kt@amd.com (mailing list archive)
State New
Headers show
Series sched/numa: Enhance disjoint VMA scanning | expand

Commit Message

Raghavendra K T Aug. 29, 2023, 6:06 a.m. UTC
VMAs being accessed by more than two tasks are critical. Scan them
unconditionally. Note that current patch considers full history of
VMA access.

Signed-off-by: Raghavendra K T <raghavendra.kt@amd.com>
---
 kernel/sched/fair.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6529da7f370a..70c8e62c1a89 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2981,6 +2981,19 @@  static inline bool vma_accessed_recent(struct vm_area_struct *vma)
 	return (bitmap_weight(pids, BITS_PER_LONG) >= 1);
 }
 
+#define SHARED_VMA_THRESH	3
+
+static inline bool vma_shared_access(struct vm_area_struct *vma)
+{
+	int i;
+	unsigned long pids = 0;
+
+	for (i = 0; i < NR_ACCESS_PID_HIST; i++)
+		pids  |= vma->numab_state->access_pids[i];
+
+	return (bitmap_weight(&pids, BITS_PER_LONG) >= SHARED_VMA_THRESH);
+}
+
 static bool vma_is_accessed(struct vm_area_struct *vma)
 {
 	/* Check at least one task had accessed VMA recently. */
@@ -2991,7 +3004,8 @@  static bool vma_is_accessed(struct vm_area_struct *vma)
 	if (vma_test_access_pid_history(vma))
 		return true;
 
-	return false;
+	/* Check if VMA is shared by many tasks. */
+	return vma_shared_access(vma);
 }
 
 #define VMA_PID_RESET_PERIOD (4 * sysctl_numa_balancing_scan_delay)