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] SelfTest: KVM: Drop Asserts for madvise failures
Date: Thu, 15 Nov 2018 20:09:07 +0200 [thread overview]
Message-ID: <20181115180907.13974-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()
failures implies that THP is not supported by host kernel.
Other options were 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 | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1b41e71283d5..7725cfdf1b79 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -586,14 +586,12 @@ 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) {
- ret = madvise(region->host_mem, npages * vm->page_size,
- src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : 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);
+ if (src_type == VM_MEM_SRC_ANONYMOUS) {
+ madvise(region->host_mem, npages * vm->page_size,
+ MADV_NOHUGEPAGE);
+ } else if (src_type == VM_MEM_SRC_ANONYMOUS_THP) {
+ madvise(region->host_mem, npages * vm->page_size,
+ MADV_HUGEPAGE);
}
region->unused_phy_pages = sparsebit_alloc();
--
2.18.1
next reply other threads:[~2018-11-15 18:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 18:09 Ahmed Abd El Mawgood [this message]
2018-11-16 9:11 ` [PATCH] SelfTest: KVM: Drop Asserts for madvise failures Andrew Jones
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=20181115180907.13974-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).