diff mbox series

[V2,1/2] restore_max_page_sharing: restore the value only if it was saved

Message ID 1521550951-8124-1-git-send-email-stanislav.kholmanskikh@oracle.com
State Accepted
Headers show
Series [V2,1/2] restore_max_page_sharing: restore the value only if it was saved | expand

Commit Message

Stanislav Kholmanskikh March 20, 2018, 1:02 p.m. UTC
Documentation/vm/ksm.txt states that the minimum value for max_page_sharing
is 2, so we can use it as a flag to test if save_max_page_sharing()
was called before.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
Changes to V1:
 - made the change to restore_max_page_sharing() following Cyril's proposal
 - split V1 into two patches, one - restore_max_page_sharing(), the other - ksm tests


 testcases/kernel/mem/lib/mem.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Comments

Cyril Hrubis March 20, 2018, 1:05 p.m. UTC | #1
Hi!
Both patches looks good, acked.
Stanislav Kholmanskikh March 20, 2018, 1:28 p.m. UTC | #2
Thank you very much. Pushed.

On 03/20/2018 04:05 PM, Cyril Hrubis wrote:
> Hi!
> Both patches looks good, acked.
>
diff mbox series

Patch

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 4992843..f36b33a 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -250,6 +250,15 @@  void save_max_page_sharing(void)
 
 void restore_max_page_sharing(void)
 {
+	/*
+	 * Documentation/vm/ksm.txt states that the minimum
+	 * value for max_page_sharing is 2, so on
+	 * max_page_sharing != 0 after save_max_page_sharing()
+	 * returns.
+	 */
+	if (!max_page_sharing)
+		return;
+
 	if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
 	        FILE_PRINTF(PATH_KSM "max_page_sharing",
 	                         "%d", max_page_sharing);