From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] ksm: perform cleanup actions only when they are actually required
Date: Tue, 20 Mar 2018 13:01:34 +0100 [thread overview]
Message-ID: <20180320120134.GB9226@ai> (raw)
In-Reply-To: <1521472983-7383-1-git-send-email-stanislav.kholmanskikh@oracle.com>
Hi!
> +static int max_page_sharing_saved;
> +
> static void verify_ksm(void)
> {
> create_same_memory(size, num, unit);
> @@ -70,6 +72,7 @@ static void setup(void)
> tst_brk(TCONF, "KSM configuration is not enabled");
>
> save_max_page_sharing();
> + max_page_sharing_saved = 1;
Given that we have the save_max_page_sharing() and
restore_max_page_sharing() functions it would be cleaner to put the flag
that tells us if we should restore it to the lib/mem.c so that we do not
have to repeat the code in all testcases.
Looking into kernel documentation is says that minimum for the
max_page_sharing is 2 so we may as well just do:
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 4992843f4..eedfe260f 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -250,6 +250,9 @@ void save_max_page_sharing(void)
void restore_max_page_sharing(void)
{
+ 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);
--
chrubis@suse.cz
next prev parent reply other threads:[~2018-03-20 12:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 15:23 [LTP] [PATCH] ksm: perform cleanup actions only when they are actually required Stanislav Kholmanskikh
2018-03-20 12:01 ` Cyril Hrubis [this message]
2018-03-20 13:02 ` [LTP] [PATCH V2 1/2] restore_max_page_sharing: restore the value only if it was saved Stanislav Kholmanskikh
2018-03-20 13:02 ` [LTP] [PATCH V2 2/2] ksm: perform cleanup actions only when they are actually required Stanislav Kholmanskikh
2018-03-20 13:05 ` [LTP] [PATCH V2 1/2] restore_max_page_sharing: restore the value only if it was saved Cyril Hrubis
2018-03-20 13:28 ` Stanislav Kholmanskikh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180320120134.GB9226@ai \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox