From: Ahmed Abd El Mawgood <ahmedsoliman@mena.vt.edu>
To: Shuah Khan <shuah@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Andrew Jones <drjones@redhat.com>, Peter Xu <peterx@redhat.com>,
Colin Ian King <colin.king@canonical.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Hossam Hassan <7ossam9063@gmail.com>,
Ahmed Lotfy <A7med.lotfey@gmail.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Anders Roxell <anders.roxell@linaro.org>
Cc: Ahmed Abd El Mawgood <ahmedsoliman@mena.vt.edu>
Subject: [PATCH V2] SelfTest: KVM: Drop Asserts for madvise MADV_NOHUGEPAGE failure
Date: Fri, 16 Nov 2018 13:50:55 +0200 [thread overview]
Message-ID: <20181116115055.7415-1-ahmedsoliman0x666@gmail.com> (raw)
From: Ahmed Abd El Mawgood <ahmedsoliman@mena.vt.edu>
madvise() returns -1 without CONFIG_TRANSPARENT_HUGEPAGE=y. That would
trigger asserts when checking for return value of madvice. Following
similar decision to [1]. I thought it is ok to assume that madvise()
MADV_NOHUGEPAGE failures implies that THP is not supported by host kernel.
Other options was to check for Transparent Huge Page support in
/sys/kernel/mm/transparent_hugepage/enabled.
-- links --
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg04514.html
Signed-off-by: Ahmed Abd El Mawgood <ahmedsoliman@mena.vt.edu>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1b41e71283d5..437c5bb48061 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -586,14 +586,23 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
src_type == VM_MEM_SRC_ANONYMOUS_THP ? huge_page_size : 1);
/* As needed perform madvise */
- if (src_type == VM_MEM_SRC_ANONYMOUS || src_type == VM_MEM_SRC_ANONYMOUS_THP) {
+ if (src_type == VM_MEM_SRC_ANONYMOUS) {
+ /*
+ * Neglect madvise error because it is ok to not have THP
+ * support in this case.
+ */
+ madvise(region->host_mem, npages * vm->page_size,
+ MADV_NOHUGEPAGE);
+ } else if (src_type == VM_MEM_SRC_ANONYMOUS_THP) {
ret = madvise(region->host_mem, npages * vm->page_size,
- src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : MADV_HUGEPAGE);
+ MADV_HUGEPAGE);
TEST_ASSERT(ret == 0, "madvise failed,\n"
- " addr: %p\n"
- " length: 0x%lx\n"
- " src_type: %x",
- region->host_mem, npages * vm->page_size, src_type);
+ "Does the kernel have CONFIG_TRANSPARENT_HUGEPAGE=y\n"
+ " addr: %p\n"
+ " length: 0x%lx\n"
+ " src_type: %x\n",
+ region->host_mem, npages * vm->page_size,
+ src_type);
}
region->unused_phy_pages = sparsebit_alloc();
--
2.18.1
WARNING: multiple messages have this Message-ID (diff)
From: ahmedsoliman at mena.vt.edu (Ahmed Abd El Mawgood)
Subject: [PATCH V2] SelfTest: KVM: Drop Asserts for madvise MADV_NOHUGEPAGE failure
Date: Fri, 16 Nov 2018 13:50:55 +0200 [thread overview]
Message-ID: <20181116115055.7415-1-ahmedsoliman0x666@gmail.com> (raw)
From: Ahmed Abd El Mawgood <ahmedsoliman at mena.vt.edu>
madvise() returns -1 without CONFIG_TRANSPARENT_HUGEPAGE=y. That would
trigger asserts when checking for return value of madvice. Following
similar decision to [1]. I thought it is ok to assume that madvise()
MADV_NOHUGEPAGE failures implies that THP is not supported by host kernel.
Other options was to check for Transparent Huge Page support in
/sys/kernel/mm/transparent_hugepage/enabled.
-- links --
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg04514.html
Signed-off-by: Ahmed Abd El Mawgood <ahmedsoliman at mena.vt.edu>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1b41e71283d5..437c5bb48061 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -586,14 +586,23 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
src_type == VM_MEM_SRC_ANONYMOUS_THP ? huge_page_size : 1);
/* As needed perform madvise */
- if (src_type == VM_MEM_SRC_ANONYMOUS || src_type == VM_MEM_SRC_ANONYMOUS_THP) {
+ if (src_type == VM_MEM_SRC_ANONYMOUS) {
+ /*
+ * Neglect madvise error because it is ok to not have THP
+ * support in this case.
+ */
+ madvise(region->host_mem, npages * vm->page_size,
+ MADV_NOHUGEPAGE);
+ } else if (src_type == VM_MEM_SRC_ANONYMOUS_THP) {
ret = madvise(region->host_mem, npages * vm->page_size,
- src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : MADV_HUGEPAGE);
+ MADV_HUGEPAGE);
TEST_ASSERT(ret == 0, "madvise failed,\n"
- " addr: %p\n"
- " length: 0x%lx\n"
- " src_type: %x",
- region->host_mem, npages * vm->page_size, src_type);
+ "Does the kernel have CONFIG_TRANSPARENT_HUGEPAGE=y\n"
+ " addr: %p\n"
+ " length: 0x%lx\n"
+ " src_type: %x\n",
+ region->host_mem, npages * vm->page_size,
+ src_type);
}
region->unused_phy_pages = sparsebit_alloc();
--
2.18.1
WARNING: multiple messages have this Message-ID (diff)
From: ahmedsoliman@mena.vt.edu (Ahmed Abd El Mawgood)
Subject: [PATCH V2] SelfTest: KVM: Drop Asserts for madvise MADV_NOHUGEPAGE failure
Date: Fri, 16 Nov 2018 13:50:55 +0200 [thread overview]
Message-ID: <20181116115055.7415-1-ahmedsoliman0x666@gmail.com> (raw)
Message-ID: <20181116115055.e6yCuyOJYzTng_qflZn4pF2uH0eImkpVOBsN5p4CQFU@z> (raw)
From: Ahmed Abd El Mawgood <ahmedsoliman@mena.vt.edu>
madvise() returns -1 without CONFIG_TRANSPARENT_HUGEPAGE=y. That would
trigger asserts when checking for return value of madvice. Following
similar decision to [1]. I thought it is ok to assume that madvise()
MADV_NOHUGEPAGE failures implies that THP is not supported by host kernel.
Other options was to check for Transparent Huge Page support in
/sys/kernel/mm/transparent_hugepage/enabled.
-- links --
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg04514.html
Signed-off-by: Ahmed Abd El Mawgood <ahmedsoliman at mena.vt.edu>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1b41e71283d5..437c5bb48061 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -586,14 +586,23 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
src_type == VM_MEM_SRC_ANONYMOUS_THP ? huge_page_size : 1);
/* As needed perform madvise */
- if (src_type == VM_MEM_SRC_ANONYMOUS || src_type == VM_MEM_SRC_ANONYMOUS_THP) {
+ if (src_type == VM_MEM_SRC_ANONYMOUS) {
+ /*
+ * Neglect madvise error because it is ok to not have THP
+ * support in this case.
+ */
+ madvise(region->host_mem, npages * vm->page_size,
+ MADV_NOHUGEPAGE);
+ } else if (src_type == VM_MEM_SRC_ANONYMOUS_THP) {
ret = madvise(region->host_mem, npages * vm->page_size,
- src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : MADV_HUGEPAGE);
+ MADV_HUGEPAGE);
TEST_ASSERT(ret == 0, "madvise failed,\n"
- " addr: %p\n"
- " length: 0x%lx\n"
- " src_type: %x",
- region->host_mem, npages * vm->page_size, src_type);
+ "Does the kernel have CONFIG_TRANSPARENT_HUGEPAGE=y\n"
+ " addr: %p\n"
+ " length: 0x%lx\n"
+ " src_type: %x\n",
+ region->host_mem, npages * vm->page_size,
+ src_type);
}
region->unused_phy_pages = sparsebit_alloc();
--
2.18.1
next reply other threads:[~2018-11-16 11:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 11:50 Ahmed Abd El Mawgood [this message]
2018-11-16 11:50 ` [PATCH V2] SelfTest: KVM: Drop Asserts for madvise MADV_NOHUGEPAGE failure Ahmed Abd El Mawgood
2018-11-16 11:50 ` ahmedsoliman
2018-11-16 12:58 ` Andrew Jones
2018-11-16 12:58 ` Andrew Jones
2018-11-16 12:58 ` drjones
2018-12-24 14:56 ` Ahmed Soliman
2018-12-24 14:56 ` Ahmed Soliman
2018-12-24 14:56 ` ahmedsoliman
2018-12-27 0:44 ` shuah
2018-12-27 0:44 ` shuah
2018-12-27 0:44 ` shuah
2019-01-07 23:20 ` Paolo Bonzini
2019-01-07 23:20 ` Paolo Bonzini
2019-01-07 23:20 ` pbonzini
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=20181116115055.7415-1-ahmedsoliman0x666@gmail.com \
--to=ahmedsoliman@mena.vt.edu \
--cc=7ossam9063@gmail.com \
--cc=A7med.lotfey@gmail.com \
--cc=anders.roxell@linaro.org \
--cc=colin.king@canonical.com \
--cc=drjones@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=shuah@kernel.org \
--cc=vkuznets@redhat.com \
/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.