* [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED)
@ 2022-10-12 2:13 Zhao Gongyi via ltp
2022-10-12 8:33 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Zhao Gongyi via ltp @ 2022-10-12 2:13 UTC (permalink / raw)
To: ltp
Test cases for madvise(2) system call, verify that MADV_DONTNEED
can be applied to Huge TLB pages after kernel version 5.18.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/madvise/.gitignore | 1 +
testcases/kernel/syscalls/madvise/madvise04.c | 49 +++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 testcases/kernel/syscalls/madvise/madvise04.c
diff --git a/runtest/syscalls b/runtest/syscalls
index c81764df4..eb1910cec 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -941,6 +941,7 @@ mincore04 mincore04
madvise01 madvise01
madvise02 madvise02
madvise03 madvise03
+madvise04 madvise04
madvise05 madvise05
madvise06 madvise06
madvise07 madvise07
diff --git a/testcases/kernel/syscalls/madvise/.gitignore b/testcases/kernel/syscalls/madvise/.gitignore
index f4bfdfefe..db8ce47c1 100644
--- a/testcases/kernel/syscalls/madvise/.gitignore
+++ b/testcases/kernel/syscalls/madvise/.gitignore
@@ -1,6 +1,7 @@
/madvise01
/madvise02
/madvise03
+/madvise04
/madvise05
/madvise06
/madvise07
diff --git a/testcases/kernel/syscalls/madvise/madvise04.c b/testcases/kernel/syscalls/madvise/madvise04.c
new file mode 100644
index 000000000..ba15de092
--- /dev/null
+++ b/testcases/kernel/syscalls/madvise/madvise04.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
+ * Author: Zhao Gongyi <zhaogongyi@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test cases for madvise(2) system call, advise value as "MADV_MADV_DONTNEED":
+ * MADV_DONTNEED can be applied to Huge TLB pages after kernel version 5.18.
+ */
+
+#include "tst_test.h"
+
+#define MAP_SIZE (8 * 1024)
+
+static char *addr;
+static int mapsz;
+
+static void run(void)
+{
+ TST_EXP_PASS(madvise(addr, mapsz, MADV_DONTNEED));
+}
+
+static void setup(void)
+{
+ mapsz = tst_get_hugepage_size();
+ addr = SAFE_MMAP(NULL, mapsz,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
+ -1, 0);
+}
+
+static void cleanup(void)
+{
+ if (addr)
+ SAFE_MUNMAP(addr, mapsz);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "5.18",
+ .needs_root = 1,
+ .hugepages = {1, TST_NEEDS},
+};
+
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED)
2022-10-12 2:13 [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED) Zhao Gongyi via ltp
@ 2022-10-12 8:33 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2022-10-12 8:33 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: ltp
Hi!
> Test cases for madvise(2) system call, verify that MADV_DONTNEED
> can be applied to Huge TLB pages after kernel version 5.18.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/madvise/.gitignore | 1 +
> testcases/kernel/syscalls/madvise/madvise04.c | 49 +++++++++++++++++++
> 3 files changed, 51 insertions(+)
> create mode 100644 testcases/kernel/syscalls/madvise/madvise04.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index c81764df4..eb1910cec 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -941,6 +941,7 @@ mincore04 mincore04
> madvise01 madvise01
> madvise02 madvise02
> madvise03 madvise03
> +madvise04 madvise04
> madvise05 madvise05
> madvise06 madvise06
> madvise07 madvise07
> diff --git a/testcases/kernel/syscalls/madvise/.gitignore b/testcases/kernel/syscalls/madvise/.gitignore
> index f4bfdfefe..db8ce47c1 100644
> --- a/testcases/kernel/syscalls/madvise/.gitignore
> +++ b/testcases/kernel/syscalls/madvise/.gitignore
> @@ -1,6 +1,7 @@
> /madvise01
> /madvise02
> /madvise03
> +/madvise04
> /madvise05
> /madvise06
> /madvise07
> diff --git a/testcases/kernel/syscalls/madvise/madvise04.c b/testcases/kernel/syscalls/madvise/madvise04.c
> new file mode 100644
> index 000000000..ba15de092
> --- /dev/null
> +++ b/testcases/kernel/syscalls/madvise/madvise04.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
> + * Author: Zhao Gongyi <zhaogongyi@huawei.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Test cases for madvise(2) system call, advise value as "MADV_MADV_DONTNEED":
> + * MADV_DONTNEED can be applied to Huge TLB pages after kernel version 5.18.
> + */
> +
> +#include "tst_test.h"
> +
> +#define MAP_SIZE (8 * 1024)
> +
> +static char *addr;
> +static int mapsz;
> +
> +static void run(void)
> +{
> + TST_EXP_PASS(madvise(addr, mapsz, MADV_DONTNEED));
>
Should we check that the pages have been zero filled like in the
previous case?
+}
> +
> +static void setup(void)
> +{
> + mapsz = tst_get_hugepage_size();
> + addr = SAFE_MMAP(NULL, mapsz,
> + PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
> + -1, 0);
> +}
> +
> +static void cleanup(void)
> +{
> + if (addr)
> + SAFE_MUNMAP(addr, mapsz);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .cleanup = cleanup,
> + .min_kver = "5.18",
> + .needs_root = 1,
> + .hugepages = {1, TST_NEEDS},
> +};
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED)
@ 2022-10-12 8:59 zhaogongyi via ltp
0 siblings, 0 replies; 5+ messages in thread
From: zhaogongyi via ltp @ 2022-10-12 8:59 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp@lists.linux.it
Hi,
>
> Hi!
> > Test cases for madvise(2) system call, verify that MADV_DONTNEED can
> > be applied to Huge TLB pages after kernel version 5.18.
> >
> > Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> > ---
> > runtest/syscalls | 1 +
> > testcases/kernel/syscalls/madvise/.gitignore | 1 +
> > testcases/kernel/syscalls/madvise/madvise04.c | 49
> +++++++++++++++++++
> > 3 files changed, 51 insertions(+)
> > create mode 100644 testcases/kernel/syscalls/madvise/madvise04.c
> >
> > diff --git a/runtest/syscalls b/runtest/syscalls index
> > c81764df4..eb1910cec 100644
> > --- a/runtest/syscalls
> > +++ b/runtest/syscalls
> > @@ -941,6 +941,7 @@ mincore04 mincore04
> > madvise01 madvise01
> > madvise02 madvise02
> > madvise03 madvise03
> > +madvise04 madvise04
> > madvise05 madvise05
> > madvise06 madvise06
> > madvise07 madvise07
> > diff --git a/testcases/kernel/syscalls/madvise/.gitignore
> > b/testcases/kernel/syscalls/madvise/.gitignore
> > index f4bfdfefe..db8ce47c1 100644
> > --- a/testcases/kernel/syscalls/madvise/.gitignore
> > +++ b/testcases/kernel/syscalls/madvise/.gitignore
> > @@ -1,6 +1,7 @@
> > /madvise01
> > /madvise02
> > /madvise03
> > +/madvise04
> > /madvise05
> > /madvise06
> > /madvise07
> > diff --git a/testcases/kernel/syscalls/madvise/madvise04.c
> > b/testcases/kernel/syscalls/madvise/madvise04.c
> > new file mode 100644
> > index 000000000..ba15de092
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/madvise/madvise04.c
> > @@ -0,0 +1,49 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
> > + * Author: Zhao Gongyi <zhaogongyi@huawei.com> */
> > +
> > +/*\
> > + * [Description]
> > + *
> > + * Test cases for madvise(2) system call, advise value as
> "MADV_MADV_DONTNEED":
> > + * MADV_DONTNEED can be applied to Huge TLB pages after kernel
> version 5.18.
> > + */
> > +
> > +#include "tst_test.h"
> > +
> > +#define MAP_SIZE (8 * 1024)
> > +
> > +static char *addr;
> > +static int mapsz;
> > +
> > +static void run(void)
> > +{
> > + TST_EXP_PASS(madvise(addr, mapsz, MADV_DONTNEED));
> >
>
> Should we check that the pages have been zero filled like in the previous
> case?
>
It looks good to add the checking.
Regards,
Gongyi
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED)
@ 2022-10-13 13:47 Zhao Gongyi via ltp
0 siblings, 0 replies; 5+ messages in thread
From: Zhao Gongyi via ltp @ 2022-10-13 13:47 UTC (permalink / raw)
To: ltp
Test cases for madvise(2) system call, verify that MADV_DONTNEED
can be applied to Huge TLB pages after kernel version 5.18.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/madvise/.gitignore | 1 +
testcases/kernel/syscalls/madvise/madvise04.c | 49 +++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 testcases/kernel/syscalls/madvise/madvise04.c
diff --git a/runtest/syscalls b/runtest/syscalls
index c81764df4..eb1910cec 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -941,6 +941,7 @@ mincore04 mincore04
madvise01 madvise01
madvise02 madvise02
madvise03 madvise03
+madvise04 madvise04
madvise05 madvise05
madvise06 madvise06
madvise07 madvise07
diff --git a/testcases/kernel/syscalls/madvise/.gitignore b/testcases/kernel/syscalls/madvise/.gitignore
index f4bfdfefe..db8ce47c1 100644
--- a/testcases/kernel/syscalls/madvise/.gitignore
+++ b/testcases/kernel/syscalls/madvise/.gitignore
@@ -1,6 +1,7 @@
/madvise01
/madvise02
/madvise03
+/madvise04
/madvise05
/madvise06
/madvise07
diff --git a/testcases/kernel/syscalls/madvise/madvise04.c b/testcases/kernel/syscalls/madvise/madvise04.c
new file mode 100644
index 000000000..ba15de092
--- /dev/null
+++ b/testcases/kernel/syscalls/madvise/madvise04.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
+ * Author: Zhao Gongyi <zhaogongyi@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test cases for madvise(2) system call, advise value as "MADV_MADV_DONTNEED":
+ * MADV_DONTNEED can be applied to Huge TLB pages after kernel version 5.18.
+ */
+
+#include "tst_test.h"
+
+#define MAP_SIZE (8 * 1024)
+
+static char *addr;
+static int mapsz;
+
+static void run(void)
+{
+ TST_EXP_PASS(madvise(addr, mapsz, MADV_DONTNEED));
+}
+
+static void setup(void)
+{
+ mapsz = tst_get_hugepage_size();
+ addr = SAFE_MMAP(NULL, mapsz,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
+ -1, 0);
+}
+
+static void cleanup(void)
+{
+ if (addr)
+ SAFE_MUNMAP(addr, mapsz);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "5.18",
+ .needs_root = 1,
+ .hugepages = {1, TST_NEEDS},
+};
+
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED)
@ 2022-10-13 13:55 zhaogongyi via ltp
0 siblings, 0 replies; 5+ messages in thread
From: zhaogongyi via ltp @ 2022-10-13 13:55 UTC (permalink / raw)
To: ltp@lists.linux.it
Hi,
>
> Test cases for madvise(2) system call, verify that MADV_DONTNEED can be
> applied to Huge TLB pages after kernel version 5.18.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/madvise/.gitignore | 1 +
> testcases/kernel/syscalls/madvise/madvise04.c | 49
> +++++++++++++++++++
> 3 files changed, 51 insertions(+)
> create mode 100644 testcases/kernel/syscalls/madvise/madvise04.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls index c81764df4..eb1910cec
> 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -941,6 +941,7 @@ mincore04 mincore04
> madvise01 madvise01
> madvise02 madvise02
> madvise03 madvise03
> +madvise04 madvise04
> madvise05 madvise05
> madvise06 madvise06
> madvise07 madvise07
> diff --git a/testcases/kernel/syscalls/madvise/.gitignore
> b/testcases/kernel/syscalls/madvise/.gitignore
> index f4bfdfefe..db8ce47c1 100644
> --- a/testcases/kernel/syscalls/madvise/.gitignore
> +++ b/testcases/kernel/syscalls/madvise/.gitignore
> @@ -1,6 +1,7 @@
> /madvise01
> /madvise02
> /madvise03
> +/madvise04
> /madvise05
> /madvise06
> /madvise07
> diff --git a/testcases/kernel/syscalls/madvise/madvise04.c
> b/testcases/kernel/syscalls/madvise/madvise04.c
> new file mode 100644
> index 000000000..ba15de092
> --- /dev/null
> +++ b/testcases/kernel/syscalls/madvise/madvise04.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
> + * Author: Zhao Gongyi <zhaogongyi@huawei.com> */
> +
> +/*\
> + * [Description]
> + *
> + * Test cases for madvise(2) system call, advise value as
> "MADV_MADV_DONTNEED":
> + * MADV_DONTNEED can be applied to Huge TLB pages after kernel
> version 5.18.
> + */
> +
> +#include "tst_test.h"
> +
> +#define MAP_SIZE (8 * 1024)
> +
> +static char *addr;
> +static int mapsz;
> +
> +static void run(void)
> +{
> + TST_EXP_PASS(madvise(addr, mapsz, MADV_DONTNEED)); }
> +
> +static void setup(void)
> +{
> + mapsz = tst_get_hugepage_size();
> + addr = SAFE_MMAP(NULL, mapsz,
> + PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
> + -1, 0);
> +}
> +
> +static void cleanup(void)
> +{
> + if (addr)
> + SAFE_MUNMAP(addr, mapsz);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .cleanup = cleanup,
> + .min_kver = "5.18",
> + .needs_root = 1,
> + .hugepages = {1, TST_NEEDS},
> +};
> +
> --
> 2.17.1
I am so sorry for resubmit this patch by mistake, please skip this patch and see the v4 of the patch.
Regards,
Gongyi
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-13 13:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 2:13 [LTP] [PATCH v3] syscalls/madvise04: new test for madvise(MADV_DONTNEED) Zhao Gongyi via ltp
2022-10-12 8:33 ` Cyril Hrubis
-- strict thread matches above, loose matches on Subject: below --
2022-10-12 8:59 zhaogongyi via ltp
2022-10-13 13:47 Zhao Gongyi via ltp
2022-10-13 13:55 zhaogongyi via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox