From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v5 3/3] syscalls/migrate_pages03.c: Add new regression test
Date: Wed, 16 May 2018 04:48:58 -0400 (EDT) [thread overview]
Message-ID: <1248273908.19613427.1526460538191.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <5AFA9A99.8090509@cn.fujitsu.com>
----- Original Message -----
> Hi, Jan and Cyril,
>
> Could you help me push the v5 patch ? Thanks a lot. :-)
Rebased and pushed.
Regards,
Jan
>
> Best Regards,
> Xiao Yang
> On 2018/02/07 5:20, Jan Stancek wrote:
> >
> > ----- Original Message -----
> >> Hi Jan, Cyril
> >>
> >> Could you help me review the v5 patch set. Thanks a lot.
> > Looks good to me - I didn't have a chance to test it though.
> >
> > Regards,
> > Jan
> >
> >> Thanks,
> >> Xiao Yang
> >> On 2018/01/05 10:48, xiao yang wrote:
> >>> The bug has been fixed in kernel:
> >>> '4b0ece6fa016("mm: migrate: fix remove_migration_pte() for ksm pages")'
> >>>
> >>> Signed-off-by: xiao yang<yangx.jy@cn.fujitsu.com>
> >>> ---
> >>> runtest/syscalls | 1 +
> >>> testcases/kernel/syscalls/.gitignore | 1 +
> >>> .../syscalls/migrate_pages/migrate_pages03.c | 151
> >>> +++++++++++++++++++++
> >>> 3 files changed, 153 insertions(+)
> >>> create mode 100644
> >>> testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
> >>>
> >>> diff --git a/runtest/syscalls b/runtest/syscalls
> >>> index 97fc643..ee8850f 100644
> >>> --- a/runtest/syscalls
> >>> +++ b/runtest/syscalls
> >>> @@ -587,6 +587,7 @@ memcpy01 memcpy01
> >>>
> >>> migrate_pages01 migrate_pages01
> >>> migrate_pages02 migrate_pages02
> >>> +migrate_pages03 migrate_pages03
> >>>
> >>> mlockall01 mlockall01
> >>> mlockall02 mlockall02
> >>> diff --git a/testcases/kernel/syscalls/.gitignore
> >>> b/testcases/kernel/syscalls/.gitignore
> >>> index 12a136e..27e30b2 100644
> >>> --- a/testcases/kernel/syscalls/.gitignore
> >>> +++ b/testcases/kernel/syscalls/.gitignore
> >>> @@ -538,6 +538,7 @@
> >>> /memset/memset01
> >>> /migrate_pages/migrate_pages01
> >>> /migrate_pages/migrate_pages02
> >>> +/migrate_pages/migrate_pages03
> >>> /mincore/mincore01
> >>> /mincore/mincore02
> >>> /mkdir/mkdir01
> >>> diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
> >>> b/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
> >>> new file mode 100644
> >>> index 0000000..ecfc552
> >>> --- /dev/null
> >>> +++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
> >>> @@ -0,0 +1,151 @@
> >>> +/*
> >>> + * Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
> >>> + * Author(s): Xiao Yang<yangx.jy@cn.fujitsu.com>
> >>> + * Jie Fei<feij.fnst@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/>.
> >>> + */
> >>> +
> >>> +/*
> >>> + * Description:
> >>> + * This is a regression test for ksm page migration which is
> >>> miscalculated.
> >>> + *
> >>> + * The kernel bug has been fixed by:
> >>> + *
> >>> + * commit 4b0ece6fa0167b22c004ff69e137dc94ee2e469e
> >>> + * Author: Naoya Horiguchi<n-horiguchi@ah.jp.nec.com>
> >>> + * Date: Fri Mar 31 15:11:44 2017 -0700
> >>> + *
> >>> + * mm: migrate: fix remove_migration_pte() for ksm pages
> >>> + */
> >>> +
> >>> +#include<errno.h>
> >>> +#include<unistd.h>
> >>> +#include<stdlib.h>
> >>> +
> >>> +#include "tst_test.h"
> >>> +#include "lapi/syscalls.h"
> >>> +#include "lapi/mmap.h"
> >>> +#include "ksm_helper.h"
> >>> +#include "numa_helper.h"
> >>> +#include "migrate_pages_common.h"
> >>> +
> >>> +#ifdef HAVE_NUMA_V2
> >>> +#define N_PAGES 20
> >>> +#define N_LOOPS 600
> >>> +#define TEST_NODES 2
> >>> +
> >>> +static int orig_ksm_run = -1;
> >>> +static unsigned int page_size;
> >>> +static void *test_pages[N_PAGES];
> >>> +static int num_nodes, max_node;
> >>> +static int *nodes;
> >>> +static unsigned long *new_nodes[2];
> >>> +
> >>> +static void setup(void)
> >>> +{
> >>> + int n;
> >>> + unsigned long nodemask_size;
> >>> +
> >>> + if (access(PATH_KSM, F_OK))
> >>> + tst_brk(TCONF, "KSM configuration was not enabled");
> >>> +
> >>> + if (get_allowed_nodes_arr(NH_MEMS,&num_nodes,&nodes)< 0)
> >>> + tst_brk(TBROK | TERRNO, "get_allowed_nodes() failed");
> >>> +
> >>> + if (num_nodes< TEST_NODES) {
> >>> + tst_brk(TCONF, "requires NUMA with at least %d node",
> >>> + TEST_NODES);
> >>> + }
> >>> +
> >>> + max_node = LTP_ALIGN(get_max_node(), sizeof(unsigned long) * 8);
> >>> + nodemask_size = max_node / 8;
> >>> + new_nodes[0] = SAFE_MALLOC(nodemask_size);
> >>> + new_nodes[1] = SAFE_MALLOC(nodemask_size);
> >>> + memset(new_nodes[0], 0, nodemask_size);
> >>> + memset(new_nodes[1], 0, nodemask_size);
> >>> + set_bit(new_nodes[0], nodes[0], 1);
> >>> + set_bit(new_nodes[1], nodes[1], 1);
> >>> +
> >>> + page_size = getpagesize();
> >>> +
> >>> + for (n = 0; n< N_PAGES; n++) {
> >>> + test_pages[n] = SAFE_MMAP(NULL, page_size, PROT_READ | PROT_WRITE |
> >>> PROT_EXEC,
> >>> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> >>> + if (madvise(test_pages[n], page_size, MADV_MERGEABLE)) {
> >>> + if (errno == EINVAL) {
> >>> + tst_brk(TCONF | TERRNO, "madvise() didn't "
> >>> + "support MADV_MERGEABLE");
> >>> + }
> >>> +
> >>> + tst_brk(TBROK | TERRNO,
> >>> + "madvise(MADV_MERGEABLE) failed");
> >>> + }
> >>> +
> >>> + if (mbind(test_pages[n], page_size, MPOL_BIND, new_nodes[0],
> >>> + max_node, 0))
> >>> + tst_brk(TBROK | TERRNO, "mbind(MPOL_BIND) failed");
> >>> +
> >>> + memset(test_pages[n], 0, page_size);
> >>> + }
> >>> +
> >>> + SAFE_FILE_SCANF(PATH_KSM "run", "%d",&orig_ksm_run);
> >>> + SAFE_FILE_PRINTF(PATH_KSM "run", "%d", 1);
> >>> + wait_ksmd_full_scan();
> >>> +}
> >>> +
> >>> +static void cleanup(void)
> >>> +{
> >>> + int n;
> >>> +
> >>> + for (n = 0; n< N_PAGES; n++) {
> >>> + if (test_pages[n])
> >>> + SAFE_MUNMAP(test_pages[n], page_size);
> >>> + }
> >>> +
> >>> + free(new_nodes[0]);
> >>> + free(new_nodes[1]);
> >>> +
> >>> + if (orig_ksm_run != -1)
> >>> + SAFE_FILE_PRINTF(PATH_KSM "run", "%d", orig_ksm_run);
> >>> +}
> >>> +
> >>> +static void migrate_test(void)
> >>> +{
> >>> + int loop, i, ret;
> >>> +
> >>> + for (loop = 0; loop< N_LOOPS; loop++) {
> >>> + i = loop % 2;
> >>> + ret = tst_syscall(__NR_migrate_pages, 0, max_node,
> >>> + new_nodes[i], new_nodes[i ? 0 : 1]);
> >>> + if (ret< 0) {
> >>> + tst_res(TFAIL | TERRNO, "migrate_pages() failed");
> >>> + return;
> >>> + }
> >>> + }
> >>> +
> >>> + tst_res(TPASS, "migrate_pages() passed");
> >>> +}
> >>> +
> >>> +static struct tst_test test = {
> >>> + .min_kver = "2.6.32",
> >>> + .needs_root = 1,
> >>> + .setup = setup,
> >>> + .cleanup = cleanup,
> >>> + .test_all = migrate_test,
> >>> +};
> >>> +
> >>> +#else
> >>> + TST_TEST_TCONF("require libnuma>= 2 and it's development packages");
> >>> +#endif
> >>
> >>
> >>
> >
> > .
> >
>
>
>
>
next prev parent reply other threads:[~2018-05-16 8:48 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 ` [LTP] [PATCH v3 1/2] lib/mem.c: factor out wait_ksmd_full_scan() Xiao Yang
2018-01-04 9:44 ` [LTP] [PATCH v4 " 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 [this message]
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=1248273908.19613427.1526460538191.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.