<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/tools/testing/selftests/kvm/demand_paging_test.c, branch linux-rolling-stable</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2024-05-12T07:18:11Z</updated>
<entry>
<title>Merge tag 'kvm-x86-selftests_utils-6.10' of https://github.com/kvm-x86/linux into HEAD</title>
<updated>2024-05-12T07:18:11Z</updated>
<author>
<name>Paolo Bonzini</name>
<email>pbonzini@redhat.com</email>
</author>
<published>2024-05-12T07:18:11Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=dee7ea42a1eba18bf4722a27b10773607c66e21d'/>
<id>urn:sha1:dee7ea42a1eba18bf4722a27b10773607c66e21d</id>
<content type='text'>
KVM selftests treewide updates for 6.10:

 - Define _GNU_SOURCE for all selftests to fix a warning that was introduced by
   a change to kselftest_harness.h late in the 6.9 cycle, and because forcing
   every test to #define _GNU_SOURCE is painful.

 - Provide a global psuedo-RNG instance for all tests, so that library code can
   generate random, but determinstic numbers.

 - Use the global pRNG to randomly force emulation of select writes from guest
   code on x86, e.g. to help validate KVM's emulation of locked accesses.

 - Rename kvm_util_base.h back to kvm_util.h, as the weird layer of indirection
   was added purely to avoid manually #including ucall_common.h in a handful of
   locations.

 - Allocate and initialize x86's GDT, IDT, TSS, segments, and default exception
   handlers at VM creation, instead of forcing tests to manually trigger the
   related setup.
</content>
</entry>
<entry>
<title>Revert "kvm: selftests: move base kvm_util.h declarations to kvm_util_base.h"</title>
<updated>2024-04-29T19:54:13Z</updated>
<author>
<name>Sean Christopherson</name>
<email>seanjc@google.com</email>
</author>
<published>2024-03-14T23:26:20Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2b7deea3ec7c81a92d4c17751d3bcd780d065ae4'/>
<id>urn:sha1:2b7deea3ec7c81a92d4c17751d3bcd780d065ae4</id>
<content type='text'>
Effectively revert the movement of code from kvm_util.h =&gt; kvm_util_base.h,
as the TL;DR of the justification for the move was to avoid #idefs and/or
circular dependencies between what ended up being ucall_common.h and what
was (and now again, is), kvm_util.h.

But avoiding #ifdef and circular includes is trivial: don't do that.  The
cost of removing kvm_util_base.h is a few extra includes of ucall_common.h,
but that cost is practically nothing.  On the other hand, having a "base"
version of a header that is really just the header itself is confusing,
and makes it weird/hard to choose names for headers that actually are
"base" headers, e.g. to hold core KVM selftests typedefs.

For all intents and purposes, this reverts commit
7d9a662ed9f0403e7b94940dceb81552b8edb931.

Reviewed-by: Ackerley Tng &lt;ackerleytng@google.com&gt;
Link: https://lore.kernel.org/r/20240314232637.2538648-2-seanjc@google.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Define _GNU_SOURCE for all selftests code</title>
<updated>2024-04-29T19:49:10Z</updated>
<author>
<name>Sean Christopherson</name>
<email>seanjc@google.com</email>
</author>
<published>2024-04-23T19:03:08Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=730cfa45b5f4f170095707b526dc7af99c9f0959'/>
<id>urn:sha1:730cfa45b5f4f170095707b526dc7af99c9f0959</id>
<content type='text'>
Define _GNU_SOURCE is the base CFLAGS instead of relying on selftests to
manually #define _GNU_SOURCE, which is repetitive and error prone.  E.g.
kselftest_harness.h requires _GNU_SOURCE for asprintf(), but if a selftest
includes kvm_test_harness.h after stdio.h, the include guards result in
the effective version of stdio.h consumed by kvm_test_harness.h not
defining asprintf():

  In file included from x86_64/fix_hypercall_test.c:12:
  In file included from include/kvm_test_harness.h:11:
 ../kselftest_harness.h:1169:2: error: call to undeclared function
  'asprintf'; ISO C99 and later do not support implicit function declarations
  [-Wimplicit-function-declaration]
   1169 |         asprintf(&amp;test_name, "%s%s%s.%s", f-&gt;name,
        |         ^

When including the rseq selftest's "library" code, #undef _GNU_SOURCE so
that rseq.c controls whether or not it wants to build with _GNU_SOURCE.

Reported-by: Muhammad Usama Anjum &lt;usama.anjum@collabora.com&gt;
Acked-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Acked-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
Acked-by: Anup Patel &lt;anup@brainfault.org&gt;
Reviewed-by: Muhammad Usama Anjum &lt;usama.anjum@collabora.com&gt;
Link: https://lore.kernel.org/r/20240423190308.2883084-1-seanjc@google.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Use EPOLL in userfaultfd_util reader threads</title>
<updated>2024-04-09T21:30:14Z</updated>
<author>
<name>Anish Moorthy</name>
<email>amoorthy@google.com</email>
</author>
<published>2024-02-15T23:54:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0cba6442e9e2dfabea042b899c99f5bfda5ab582'/>
<id>urn:sha1:0cba6442e9e2dfabea042b899c99f5bfda5ab582</id>
<content type='text'>
With multiple reader threads POLLing a single UFFD, the demand paging test
suffers from the thundering herd problem: performance degrades as the
number of reader threads is increased. Solve this issue [1] by switching
the the polling mechanism to EPOLL + EPOLLEXCLUSIVE.

Also, change the error-handling convention of uffd_handler_thread_fn.
Instead of just printing errors and returning early from the polling
loop, check for them via TEST_ASSERT(). "return NULL" is reserved for a
successful exit from uffd_handler_thread_fn, i.e. one triggered by a
write to the exit pipe.

Performance samples generated by the command in [2] are given below.

Num Reader Threads, Paging Rate (POLL), Paging Rate (EPOLL)
1      249k      185k
2      201k      235k
4      186k      155k
16     150k      217k
32     89k       198k

[1] Single-vCPU performance does suffer somewhat.
[2] ./demand_paging_test -u MINOR -s shmem -v 4 -o -r &lt;num readers&gt;

Signed-off-by: Anish Moorthy &lt;amoorthy@google.com&gt;
Acked-by: James Houghton &lt;jthoughton@google.com&gt;
Link: https://lore.kernel.org/r/20240215235405.368539-13-amoorthy@google.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Allow many vCPUs and reader threads per UFFD in demand paging test</title>
<updated>2024-04-09T21:28:53Z</updated>
<author>
<name>Anish Moorthy</name>
<email>amoorthy@google.com</email>
</author>
<published>2024-02-15T23:54:02Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=df4ec5aada9da30486d5464f34ffc80acd0373d6'/>
<id>urn:sha1:df4ec5aada9da30486d5464f34ffc80acd0373d6</id>
<content type='text'>
At the moment, demand_paging_test does not support profiling/testing
multiple vCPU threads concurrently faulting on a single uffd because

    (a) "-u" (run test in userfaultfd mode) creates a uffd for each vCPU's
        region, so that each uffd services a single vCPU thread.
    (b) "-u -o" (userfaultfd mode + overlapped vCPU memory accesses)
        simply doesn't work: the test tries to register the same memory
        to multiple uffds, causing an error.

Add support for many vcpus per uffd by
    (1) Keeping "-u" behavior unchanged.
    (2) Making "-u -a" create a single uffd for all of guest memory.
    (3) Making "-u -o" implicitly pass "-a", solving the problem in (b).
In cases (2) and (3) all vCPU threads fault on a single uffd.

With potentially multiple vCPUs per UFFD, it makes sense to allow
configuring the number of reader threads per UFFD as well: add the "-r"
flag to do so.

Signed-off-by: Anish Moorthy &lt;amoorthy@google.com&gt;
Acked-by: James Houghton &lt;jthoughton@google.com&gt;
Link: https://lore.kernel.org/r/20240215235405.368539-12-amoorthy@google.com
[sean: fix kernel style violations, use calloc() for arrays]
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Report per-vcpu demand paging rate from demand paging test</title>
<updated>2024-04-09T21:16:48Z</updated>
<author>
<name>Anish Moorthy</name>
<email>amoorthy@google.com</email>
</author>
<published>2024-02-15T23:54:01Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2ca76c12c48b7a2792b21a673ca01a6d8fb2e835'/>
<id>urn:sha1:2ca76c12c48b7a2792b21a673ca01a6d8fb2e835</id>
<content type='text'>
Using the overall demand paging rate to measure performance can be
slightly misleading when vCPU accesses are not overlapped. Adding more
vCPUs will (usually) increase the overall demand paging rate even
if performance remains constant or even degrades on a per-vcpu basis. As
such, it makes sense to report both the total and per-vcpu paging rates.

Signed-off-by: Anish Moorthy &lt;amoorthy@google.com&gt;
Link: https://lore.kernel.org/r/20240215235405.368539-11-amoorthy@google.com
[sean: fix formatting]
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Remove redundant newlines</title>
<updated>2024-01-29T16:39:14Z</updated>
<author>
<name>Andrew Jones</name>
<email>ajones@ventanamicro.com</email>
</author>
<published>2023-12-06T17:02:43Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=250e138d876838774bca3140d544438898df0489'/>
<id>urn:sha1:250e138d876838774bca3140d544438898df0489</id>
<content type='text'>
TEST_* functions append their own newline. Remove newlines from
TEST_* callsites to avoid extra newlines in output.

Signed-off-by: Andrew Jones &lt;ajones@ventanamicro.com&gt;
Link: https://lore.kernel.org/r/20231206170241.82801-8-ajones@ventanamicro.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Allow specify physical cpu list in demand paging test</title>
<updated>2023-06-07T00:29:49Z</updated>
<author>
<name>Peter Xu</name>
<email>peterx@redhat.com</email>
</author>
<published>2023-06-07T00:12:26Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d4ec586c60ab978554245c58cf432df444c93b4e'/>
<id>urn:sha1:d4ec586c60ab978554245c58cf432df444c93b4e</id>
<content type='text'>
Mimic the dirty log test and allow the user to pin demand paging test
tasks to physical CPUs.

Put the help message into a general helper as suggested by Sean.

Signed-off-by: Peter Xu &lt;peterx@redhat.com&gt;
[sean: rebase, tweak arg ordering, add "print" to helper, print program name]
Link: https://lore.kernel.org/r/20230607001226.1398889-1-seanjc@google.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Setup vcpu_alias only for minor mode test</title>
<updated>2023-05-31T21:05:02Z</updated>
<author>
<name>Peter Xu</name>
<email>peterx@redhat.com</email>
</author>
<published>2023-04-27T20:11:11Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ba125de35da5184c5325bef5c4c89f6928ce8875'/>
<id>urn:sha1:ba125de35da5184c5325bef5c4c89f6928ce8875</id>
<content type='text'>
This fixes two things:

- Unbreaks MISSING mode test on anonymous memory type

- Prefault alias mem before uffd thread creations, otherwise the uffd
  thread timing will be inaccurate when guest mem size is large, because
  it'll take prefault time into total time.

Signed-off-by: Peter Xu &lt;peterx@redhat.com&gt;
Reviewed-by: James Houghton &lt;jthoughton@google.com&gt;
Link: https://lore.kernel.org/r/20230427201112.2164776-2-peterx@redhat.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
<entry>
<title>KVM: selftests: Fix nsec to sec conversion in demand_paging_test</title>
<updated>2023-03-24T15:26:23Z</updated>
<author>
<name>Anish Moorthy</name>
<email>amoorthy@google.com</email>
</author>
<published>2023-02-23T00:18:05Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f6baabdcadd1080893aa5e49e6959cb070244703'/>
<id>urn:sha1:f6baabdcadd1080893aa5e49e6959cb070244703</id>
<content type='text'>
demand_paging_test uses 1E8 as the denominator to convert nanoseconds to
seconds, which is wrong. Use NSEC_PER_SEC instead to fix the issue and
make the conversion obvious.

Reported-by: James Houghton &lt;jthoughton@google.com&gt;
Signed-off-by: Anish Moorthy &lt;amoorthy@google.com&gt;
Reviewed-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
Reviewed-by: Sean Christopherson &lt;seanjc@google.com&gt;
Link: https://lore.kernel.org/r/20230223001805.2971237-1-amoorthy@google.com
Signed-off-by: Sean Christopherson &lt;seanjc@google.com&gt;
</content>
</entry>
</feed>
