public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] lib/mem.c: factor out wait_ksmd_full_scan()
Date: Thu, 4 Jan 2018 17:34:42 +0800	[thread overview]
Message-ID: <5A4DF532.9070401@cn.fujitsu.com> (raw)
In-Reply-To: <1515058018-19913-1-git-send-email-yangx.jy@cn.fujitsu.com>

Hi,

Sorry, there is duplicate code with this patch set. So please ignore it.

Thanks,
Xiao Yang

On 2018/01/04 17:26, xiao yang wrote:
> Move common wait_ksmd_full_scan() to kernel/lib/ksm_helper.c
> and create accompanying kernel/include/ksm_helper.h.
>
> Signed-off-by: xiao yang <yangx.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/include/ksm_helper.h | 26 +++++++++++++++++++
>  testcases/kernel/lib/ksm_helper.c     | 49 +++++++++++++++++++++++++++++++++++
>  testcases/kernel/mem/lib/mem.c        | 28 +-------------------
>  3 files changed, 76 insertions(+), 27 deletions(-)
>  create mode 100644 testcases/kernel/include/ksm_helper.h
>  create mode 100644 testcases/kernel/lib/ksm_helper.c
>
> diff --git a/testcases/kernel/include/ksm_helper.h b/testcases/kernel/include/ksm_helper.h
> new file mode 100644
> index 0000000..0b35218
> --- /dev/null
> +++ b/testcases/kernel/include/ksm_helper.h
> @@ -0,0 +1,26 @@
> +/*
> + * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
> + * Author(s): Xiao Yang <yangx.jy@cn.fujitsu.com>
> + *
> + * This program is free software;  you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY;  without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> + * the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program, if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef KSM_HELPER_H
> +#define KSM_HELPER_H
> +
> +#define PATH_KSM	"/sys/kernel/mm/ksm/"
> +
> +void wait_ksmd_full_scan(void);
> +
> +#endif /* KSM_HELPER_H */
> diff --git a/testcases/kernel/lib/ksm_helper.c b/testcases/kernel/lib/ksm_helper.c
> new file mode 100644
> index 0000000..eba28d4
> --- /dev/null
> +++ b/testcases/kernel/lib/ksm_helper.c
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
> + * Author(s): Xiao Yang <yangx.jy@cn.fujitsu.com>
> + *
> + * This program is free software;  you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY;  without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> + * the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program, if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#define TST_NO_DEFAULT_MAIN
> +
> +#include <unistd.h>
> +#include "tst_test.h"
> +#include "ksm_helper.h"
> +
> +void wait_ksmd_full_scan(void)
> +{
> +	unsigned long full_scans, at_least_one_full_scan;
> +	int count = 0;
> +
> +	SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
> +	/*
> +	 * The current scan is already in progress so we can't guarantee that
> +	 * the get_user_pages() is called on every existing rmap_item if we
> +	 * only waited for the remaining part of the scan.
> +	 *
> +	 * The actual merging happens after the unstable tree has been built so
> +	 * we need to wait at least two full scans to guarantee merging, hence
> +	 * wait full_scans to increment by 3 so that at least two full scans
> +	 * will run.
> +	 */
> +	at_least_one_full_scan = full_scans + 3;
> +	while (full_scans < at_least_one_full_scan) {
> +		sleep(1);
> +		count++;
> +		SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
> +	}
> +
> +	tst_res(TINFO, "ksm daemon takes %ds to run two full scans", count);
> +}
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index 7f2099b..4275f63 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -23,6 +23,7 @@
>  #include <unistd.h>
>  
>  #include "mem.h"
> +#include "ksm_helper.h"
>  #include "numa_helper.h"
>  
>  /* OOM */
> @@ -268,33 +269,6 @@ static void check(char *path, long int value)
>  		tst_res(TPASS, "%s is %ld.", path, actual_val);
>  }
>  
> -static void wait_ksmd_full_scan(void)
> -{
> -	unsigned long full_scans, at_least_one_full_scan;
> -	int count = 0;
> -
> -	SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
> -	/*
> -	 * The current scan is already in progress so we can't guarantee that
> -	 * the get_user_pages() is called on every existing rmap_item if we
> -	 * only waited for the remaining part of the scan.
> -	 *
> -	 * The actual merging happens after the unstable tree has been built so
> -	 * we need to wait at least two full scans to guarantee merging, hence
> -	 * wait full_scans to increment by 3 so that at least two full scans
> -	 * will run.
> -	 */
> -	at_least_one_full_scan = full_scans + 3;
> -	while (full_scans < at_least_one_full_scan) {
> -		sleep(1);
> -		count++;
> -		SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
> -	}
> -
> -	tst_res(TINFO, "ksm daemon takes %ds to run two full scans",
> -		count);
> -}
> -
>  static void final_group_check(int run, int pages_shared, int pages_sharing,
>  			  int pages_volatile, int pages_unshared,
>  			  int sleep_millisecs, int pages_to_scan)




  parent reply	other threads:[~2018-01-04  9:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28 10:07 [LTP] [PATCH] syscalls/migrate_pages03.c: Add new regression test Xiao Yang
2017-11-30 15:20 ` Cyril Hrubis
2017-12-21 10:03   ` [LTP] [PATCH v2] " Xiao Yang
2017-12-25 10:26     ` Xiao Yang
2017-12-25 10:37   ` xiao yang
2018-01-03 12:04     ` Jan Stancek
2018-01-03 14:38     ` Cyril Hrubis
2018-01-04  9:26       ` [LTP] [PATCH v3 1/2] lib/mem.c: factor out wait_ksmd_full_scan() xiao yang
2018-01-04  9:26         ` [LTP] [PATCH v3 2/2] syscalls/migrate_pages03.c: Add new regression test xiao yang
2018-01-04  9:34         ` Xiao Yang [this message]
2018-01-04  9:44       ` [LTP] [PATCH v4 1/2] lib/mem.c: factor out wait_ksmd_full_scan() xiao yang
2018-01-04  9:44         ` [LTP] [PATCH v4 2/2] syscalls/migrate_pages03.c: Add new regression test xiao yang
2018-01-04 15:30           ` Cyril Hrubis
2018-01-05  1:51             ` Xiao Yang
2018-01-05  2:48             ` [LTP] [PATCH v5 1/3] lib/mem.c: factor out wait_ksmd_full_scan() xiao yang
2018-01-05  2:48               ` [LTP] [PATCH v5 2/3] syscalls/migrate_pages*: Small cleanup xiao yang
2018-02-07 16:22                 ` Cyril Hrubis
2018-01-05  2:48               ` [LTP] [PATCH v5 3/3] syscalls/migrate_pages03.c: Add new regression test xiao yang
2018-01-19  1:51                 ` Xiao Yang
2018-02-02  8:11                 ` Xiao Yang
2018-02-06 21:20                   ` Jan Stancek
2018-05-15  8:30                     ` Xiao Yang
2018-05-16  8:48                       ` Jan Stancek
2018-03-20  9:18                 ` Xiao Yang

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=5A4DF532.9070401@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --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