public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Rick Edgecombe <rick.p.edgecombe@intel.com>
To: pbonzini@redhat.com, ackerleytng@google.com, seanjc@google.com
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, rick.p.edgecombe@intel.com
Subject: [PATCH] KVM: selftests: Include linux version of mman.h
Date: Mon, 27 Apr 2026 13:43:13 -0700	[thread overview]
Message-ID: <20260427204313.50741-1-rick.p.edgecombe@intel.com> (raw)

Fix a selftest build error by switching a mman.h header include from the
"sys" version to the "linux" one.

Recently a reference to MADV_COLLAPSE was added to guest_memfd_test.c.
This works fine if the system libc has this definition, but against older
libcs, it leads to build errors like:
  In file included from include/kvm_util.h:8,
                   from guest_memfd_test.c:21:
  guest_memfd_test.c: In function ‘test_collapse’:
  guest_memfd_test.c:219:47: error: ‘MADV_COLLAPSE’ undeclared (first use in this function); did you mean ‘MADV_COLD’?
      219 |         TEST_ASSERT_EQ(madvise(mem, pmd_size, MADV_COLLAPSE), -1);
          |                                               ^~~~~~~~~~~~~
    include/test_util.h:62:16: note: in definition of macro ‘TEST_ASSERT_EQ’
       62 |         typeof(a) __a = (a);                                            \
          |                ^
    guest_memfd_test.c:219:47: note: each undeclared identifier is reported only once for each function it appears in
      219 |         TEST_ASSERT_EQ(madvise(mem, pmd_size, MADV_COLLAPSE), -1);
          |                                               ^~~~~~~~~~~~~
    include/test_util.h:62:16: note: in definition of macro ‘TEST_ASSERT_EQ’
       62 |         typeof(a) __a = (a);                                            \
          |                ^

The problem is the test is pulling in the libc version of mman.h instead of
the Linux one. Switch it to the Linux one so MADV_COLLAPSE will be
guaranteed to be present (if the user installs the headers).

Fixes: 9830209b4ae8 ("KVM: selftests: Test MADV_COLLAPSE on guest_memfd")
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---

Hi,

I'm not sure if there is standard official version of the header to include
for the selftests, but the KVM selftests no longer build for me. This fixes
it.

 tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index ec7644aae999..7c113b8c4f75 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -14,7 +14,7 @@
 #include <linux/bitmap.h>
 #include <linux/falloc.h>
 #include <linux/sizes.h>
-#include <sys/mman.h>
+#include <linux/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
-- 
2.54.0


             reply	other threads:[~2026-04-27 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 20:43 Rick Edgecombe [this message]
2026-04-27 23:39 ` [PATCH] KVM: selftests: Include linux version of mman.h Sean Christopherson
2026-04-27 23:49   ` Edgecombe, Rick P
2026-04-27 23:57     ` Sean Christopherson
2026-04-27 23:59       ` Edgecombe, Rick P
2026-04-28 23:55 ` Ackerley Tng

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=20260427204313.50741-1-rick.p.edgecombe@intel.com \
    --to=rick.p.edgecombe@intel.com \
    --cc=ackerleytng@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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