gentoo-overlay/sys-kernel/hardened-kernel/files/linux-5.4/9105_0105-ksm-wakeups.patch

53 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Mon, 6 May 2019 12:57:09 -0500
Subject: [PATCH] ksm-wakeups
reduce wakeups in ksm by adding rounding (aligning) when
the sleep times are 1 second or longer
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
kernel/watchdog.c | 2 +-
mm/ksm.c | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index f41334ef0971..eb49c42f215b 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -41,7 +41,7 @@ unsigned long __read_mostly watchdog_enabled;
int __read_mostly watchdog_user_enabled = 1;
int __read_mostly nmi_watchdog_user_enabled = NMI_WATCHDOG_DEFAULT;
int __read_mostly soft_watchdog_user_enabled = 1;
-int __read_mostly watchdog_thresh = 10;
+int __read_mostly watchdog_thresh = 40;
static int __read_mostly nmi_watchdog_available;
static struct cpumask watchdog_allowed_mask __read_mostly;
diff --git a/mm/ksm.c b/mm/ksm.c
index 7905934cd3ad..9ea848346a0b 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2414,9 +2414,14 @@ static int ksm_scan_thread(void *nothing)
if (ksmd_should_run()) {
sleep_ms = READ_ONCE(ksm_thread_sleep_millisecs);
- wait_event_interruptible_timeout(ksm_iter_wait,
- sleep_ms != READ_ONCE(ksm_thread_sleep_millisecs),
- msecs_to_jiffies(sleep_ms));
+ if (sleep_ms >= 1000)
+ wait_event_interruptible_timeout(ksm_iter_wait,
+ sleep_ms != READ_ONCE(ksm_thread_sleep_millisecs),
+ msecs_to_jiffies(round_jiffies_relative(sleep_ms)));
+ else
+ wait_event_interruptible_timeout(ksm_iter_wait,
+ sleep_ms != READ_ONCE(ksm_thread_sleep_millisecs),
+ msecs_to_jiffies(sleep_ms));
} else {
wait_event_freezable(ksm_thread_wait,
ksmd_should_run() || kthread_should_stop());
--
https://clearlinux.org