`peek_size` blocks until there is data available, so it is actually more
likely to see an EINTR than the `recv_with_fds` call that follows it.
Before, the following command failed had 5 flakes, 3 of which were
clearly caused by EINTR when recving on a tube. After, I saw no flakes.
./tools/run_tests --dut=vm --filter-expr="test(boot_test_vm_uring)" --repetitions 100
BUG=b:293463612
Change-Id: Ie0471a46be11d67f38d4d0a5a4793e5ca2fc1633
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4727022
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Due to MFD_NOEXEC_SEAL being applied by SharedMemory::new() on newer
kernels, the set of seals may not be 0 after shm creation. Tweak the
test to validate that only the F_SEAL_SEAL flag is clear before we
intentionally set it so the test can pass on both old and new kernels.
BUG=b:282221246
TEST=tools/dev_container tools/presubmit # on Linux 6.3.11 kernel
Fixes: 5b7cdc1eb0 ("base: use MFD_NOEXEC_SEAL if available when creating memfds")
Change-Id: I60e3886bf0401f037b3ca03ba1b43186adcec5bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4718767
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
open_file does not always open_file. It reuses given fd when it points
to a special path /proc/self/fd/XX.
BUG=b:291832160
TEST=build
Change-Id: If821834e3adbc457616c71e5b8425962286245e7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4706830
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
For bazel migration we will require lib entry points to be in their
standard location at src/lib.rs
BUG=b:289258700
TEST=CQ
Change-Id: I2346260212532716c5954ba65d6264afc7e55a68
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4691163
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This test is unrelated to vm_control; it is testing base::Event and
base::Tube functionality, so move it next to the existing Tube tests.
The test module was also in the middle of the file for some reason,
which caused clippy warnings in Rust 1.71.
Change-Id: I52858e71df8aa3e092b3b7d12e1232454b61c4d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4684827
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The internal buffer is changed from String to Vec<u8>. This avoids
breaking incomplete UTF-8 sequences during string parsing, which would
result in replacement characters in the output.
BUG=b:289736895
TEST=Check syslog for "…" when running a Debian VM on Linux
TEST=tools/presubmit
Change-Id: I9316e728d39aad2980946a5e90239d466e082d75
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4666847
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: James Ye <jamesye@google.com>
Introduce a TimerTrait that is implemented by both Timer and FakeTimer.
This trait can be used to write testable code without needing to
condition use statements on cfg(test).
BUG=None
TEST=CQ
Change-Id: I874ffe19fafe73e5c17fd5bb689e5b571e9f5b12
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4664188
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This cleans up the final windows/win/* file, so the import is removed.
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: I705d4789982284739a81694fbb0d15bd07cfa77f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126573
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Move platform_timer_utils.rs to src/sys/windows (out of win/) and do not
export its functions from base. These are only used internally and are
not cross-platform APIs, so they should not be public.
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: Id82065d15d7b2fabd33b3ba1784a6a8a243f1db0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126572
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
TEST=CQ
TEST=turn on building for perfetto, and rust-analyzer doesn't
complain about things I changed.
BUG=b:204409584
Change-Id: I4c290304028ecd155069d6194f776360d48b4220
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4618952
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
The new MFD_NOEXEC_SEAL flag allows creating memfds that don't have the
execute file mode. Add a function to detect whether this feature is
available on the currently running kernel so we can make the guest
memory memfd a non-executable file if the feature is available.
BUG=b:282221246
TEST=run crosvm on a ChromeOS kernel with MFD_NOEXEC patch
TEST=stat -L /proc/<crosvm pid>/fd/<crosvm memfd>; observe no x
TEST=run crosvm on an older vanilla Linux kernel without MFD_NOEXEC
Change-Id: I5d60cfe4b90eb23f79ecbc04d6bde9e1f46eeb8e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4528584
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jeff Xu <jeffxu@google.com>
This avoid opening timezone files from jailed process under unix.
BUG=b:280298742
TEST=manual - run crosvm with logging from battery device.
Change-Id: I1869ce5a79bdd0ace678e4e90ea1f9df2e90fd8a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4574297
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The new rust toolchain comes with improved clippy warnings that
catch more unnecessary casts than before.
Some cases have to be whitelisted since libc types have varying size
based on the architecture we are compiling for.
BUG=None
TEST=presubmit
Change-Id: Ia473b0bfe6e74bdb7b0d4ca15d2c9fb410fc353e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4568144
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Detecting if a Tube is disconnected used to be a little painful since
we'd have to extract the underlying io::Error and check for BrokenPipe.
On unix it wasn't ever this hard since Error::Disconnected exists for
the Tube Error type. On Windows it looks like we just forgot to
implement this.
This CL makes all broken pipes on Tube read/write return Disconnected
instead of a generic IO error.
BUG=b:276361599
TEST=manual run of VM.
Change-Id: I422951b770fd966d6d5e9618c3b756bb2ab5ef7d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558305
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
StreamChannel notifications were not properly handling broken pipes
when fetching the number of bytes available during the notification
sync. This is because the PeekNamedPipe call comes after the final read
call that drains the named pipe, and at this point the pipe is broken.
This CL fixes the problem by treating the byte count as zero if the
pipe is broken, which is technically true (it has no data).
BUG=b:279840868
TEST=manual
Change-Id: Ib563c7e5e426524f666ff191ec3774a4b40f59a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556842
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
base:🧵:spawn_with_timeout was stricter than
std:🧵:spawn, which wasn't really helpful.
(In prod code we use std:🧵:spawn, so being
stricter than that isn't useful or safer in a meaningful
way.)
BUG=b:276361599
TEST=builds
Change-Id: I4197d3ac082af4077f82d7d70a11869b0a886238
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556841
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
* Sometimes we want to split a Tube end into a reader & writer so
those responsibilities can be handled separately. This is what
`split_to_send_recv` does.
* On Windows, making a Tube directly attached to a named pipe will be
needed for the control client. This is what `PipeTube` implements.
Just like a raw named pipe, it has no notification support, and so it
hides those elements of the Tube API.
* On Windows, we need a way to ensure a Tube is flushed before it is
dropped so that a disconnecting client can ensure the server has read
its messages before the pipe is dropped / EPIPE happens.
Paradoxically, the "flush" can only be implemented on the server end
of a pipe, so in CrosVM, our "clients" are actually the server end of
pipes.
BUG=b:276361599
TEST=tested in future CL in the chain.
Change-Id: I70a7badc92461d49b9f08a5f997157b0698cff24
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556840
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
In our overlapped read helper API, ERROR_MORE_DATA was considered to be
a fatal error (if returned from the initial call to ReadFile). It looks
like this might only happen for message mode pipes, which probably
weren't used with this function until an upcoming CL. This error would
cause us to return early and leave the OverlappedWrapper in use. Leaving
the wrapper in use is still possible, so that's a bug (b/279459822).
BUG=b:276361599
TEST=future CLs in the chain.
Change-Id: Icc8dff9b83542365336664ee1219654cb3ec1eef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556839
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Similar to our other overlapped utility functions for read, this CL adds
one for the named pipe equivalent of accept (ConnectNamedPipe).
BUG=b:276361599
TEST=unit tests
Change-Id: I30780fbfea6ff57aaf4bb3176f400f5b5e5fb9de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556838
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
According to man 7 signal:
> On Linux, even in the absence of signal handlers, certain blocking
> interfaces can fail with the error EINTR after the process is stopped
> by one of the stop signals and then resumed via SIGCONT. This
> behavior is not sanctioned by POSIX.1, and doesn't occur on other
> systems.
>
> The Linux interfaces that display this behavior are:
>
> • "Input" socket interfaces, when a timeout (SO_RCVTIMEO) has
> been set on the socket using setsockopt(2): accept(2), recv(2),
> recvfrom(2), recvmmsg(2) (also with a non-NULL timeout argument),
> and recvmsg(2).
> • "Output" socket interfaces, when a timeout (SO_RCVTIMEO) has been
> set on the socket using setsockopt(2): connect(2), send(2),
> sendto(2), and sendmsg(2), if a send timeout (SO_SNDTIMEO) has
> been set.
The swap feature sends SIGSTOP and SIGCONT to crosvm processes. The
balloon command tube and the proxy devices fall into this category.
BUG=b:259621330
TEST=tools/dev_container tools/run_tests2
Change-Id: I34535430d6fcde4eaf3d2b21acf9ee444baad42c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4547741
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
It is confusing that `Tube::recv()` may return `Error::Send`. This was
because `TubeError::Recv` accepts `std::io::Error` only while socket
related raw function in base crate returns `base::Error`.
`TubeError::Recv` and `Tube::Send` should accept either of `base::Error`
or `std::io::Error` but the same one.
`std::io::Error` is preferred because send/recv on `ScmSocket` are I/O.
`std::io::Error::raw_os_error()` always returns `Some` if the error was
constructed via `std::io::Error::last_os_error()`.
BUG=b:276384648
TEST=tools/dev_container tools/run_tests2
Change-Id: I73509c7173b4b0e5e7ed939ef20e36db2f16ade3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546494
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Shin Kawamura <kawasin@google.com>
Move the AllowSetForegroundWindow() wrapper out of windows/win.
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: I401eb5098ce9d2d02c1f5d8651743d99c19a037f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126567
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
These helper functions for getting system information are only used to
implement the equivalent base functions, so move the implementation into
base itself.
This also cleans up the initialization of the cached system information
so that it is contained in a single once_cell::sync::Lazy. The relevant
data is retrieved once and stored in an internal struct SystemInfo to
avoid problems with storing SYSTEM_INFO itself (the Win32 structure
contains pointers, so it is not Sync and can't be stored directly in a
sync::Lazy).
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: I94d029ef165764f976fd34d846fab60b8754cfb1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126566
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
as part of stabilizing/formalizing the messages that will be sent on
optional registered event listening sockets, introduces a ProtoTube
wrapper around Tube, largely mirroring the functionality of the same
from Windows tubes.
BUG=b/278117550
TEST=unit test
Change-Id: Ib2a722ad9ccd8a454d2ebccbcaadec2a147efe40
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4510027
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: maciek swiech <drmasquatch@google.com>
This test will spin up block and net vhost user device processes. This
test will be used as a smoke test and won't run during presubmits
Also refactor functions that can be shared into the fixture crate.
BUG=b:281115884
TEST=ran test. Also verified messages get sent to vhost user devices
Change-Id: Ic7e78a8ed71290fd3c42f9e15bf59a238623c49e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4519650
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Currently, virtio-blk translates a FLUSH request to fsync system call.
However, fsync always updates the metadata of a file, which causes extra
journaling for metadata update. Since virtio-blk cares only the data of
the given block image file, we should avoid updating extra metadata.
After this change, virtio-blk now calls fdatasync for a FLUSH request.
If a write operation wrote to a data block that is already allocated
before, fdatasync can avoid triggering jdb2 journaling on an ext4 file
system.
Note there are structs which fall back to fsync for fdatasync. In
addition, io_uring executor does not implement fdatasync yet.
We observed statistically significant play_store_shown_time improvement
on trogdor-arc-r by -1.614% with this change. Including non
statistically significant data, we observed the following improvements.
| Name | delta | Count |
|-----------------------|---------|-------|
| trogdor-arc-r (lazor) | -1.614% | 170 |
| brya-arc-t (primus) | -1.478% | 200 |
| octopus-arc-t (apel) | -0.887% | 190 |
| kukui-arc-r (kakadu) | -0.451% | 170 |
BUG=b:281609112
TEST=run a vm with block and confirmed fdatasync is called by strace
Change-Id: Idc94a3ec169e9a5e04394079967f6d79ff4c32db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4523029
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Musl libc uses u32 for cmsg_len, cast it to usize when calling
the new CMSG_ALIGN const fn.
Bug: 216192129
Test: m USE_HOST_MUSL=true crosvm
Change-Id: Ida9f09f6a44f6db5f109513618dcf745cf547a5f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521472
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Cross <ccross@google.com>
Introduce support for a virtual CPU frequency device
to improve guest task placement behaviour along with performance
and power usage of workloads within VMs[1]. This device adds MMIO regions
that enables the guest to:
- Query for the frequency of the physical CPU that the current
vCPU is affined to.
- Send frequency requests that can be used as hint for the
host to schedule vCPU threads and choose physical CPU frequency.
Add a config option "--virt-cpufreq" that enables the virtual cpu device
and populates the frequencies of vCPUs through devicetree, which can
be used by a guest kernel cpufreq driver[2].
[1] https://lore.kernel.org/all/20230330224348.1006691-1-davidai@google.com/
[2] https://android-review.git.corp.google.com/c/kernel/common/+/2239182
Bug: None
Test: ./tools/presubmit
Change-Id: I03983c5e4a3fa288ca19504aa093ad1f7f9f7e51
Signed-off-by: David Dai <davidai@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4504738
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
These tests require initialization of the syslogger via
`openlog_and_get_socket` which requires no other threads in the
process to prevent conflicting file descriptors.
BUG=b:280331266
TEST=run_tests --dut=host
TEST=cargo test -p base --test syslog
TEST=cargo test -p base --lib
Change-Id: I3d83ecb80770d94914fc23b2d5760c7a54f6380f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4499660
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
These macros are no longer necessary, as we can replace them with const
fn implementations instead.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: If64cfa8fe08f113ead7236d11bb5a8b0fd51c290
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4484512
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
system_api bindings have been regenerated with protobuf 3.2; this should
be okay to land before the full ChromeOS system_api migration, since
crosvm always uses its own copy of the bindings rather than the ones
provided by the dev-rust/system_api package.
The protoc-rust crate is replaced with protobuf_codegen in 3.x.
BUG=b:277243607
BUG=b:279834784
TEST=tools/dev_container tools/presubmit
Change-Id: I6aad45ded2639d7506a7238800584bebab196455
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Some type parameters in <> were being mis-parsed as HTML tags.
BUG=b:276487055
TEST=tools/cargo-doc # with rust 1.68.2
Change-Id: Iaa9ec6cf94a6084cfdf323bb04c643396a320889
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485758
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Add cast to support Android. Libc Android has different types for some
variables than Libc Linux. This leads to casts required. Added skips on
clippy for these casts as they would be redundant on a platform while
required on another.
The same change is also applied to fuse:.
BUG=N/A
Test=presubmit
Change-Id: I994af922cf3ccc56438f2642fef9af91f6af5118
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485518
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Both single and multi process did not have realtime priority, due to us
dropping the multimedia trick handle in set_audio_thread_priority where
we should be holding it until the thread is finished.
BUG=b:276698085
TEST=Process explorer -> properties -> threads -> base priority
increases from 8 to 24
Change-Id: Ia9199f4816e087046b8718e85c60abc9479ec0f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4416757
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Some `as usize` casts are necessary on non-glibc C libraries, since the
type of `cmsg_len` and `msg_controllen` may not be usize in the libc
bindings, so these warnings are suppressed instead of removing the
casts.
BUG=b:276487055
TEST=tools/clippy # with Rust 1.68
Change-Id: I30d9a16d37710b1356cffc183a03f8c8f6f35680
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391102
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add method to deserialize sequences to arrays in custom serde.
This allows for a simpler conversation, avoiding more code for each
conversation, while bypassing the serde limitation on array deserialization
of sizes larger than 32.
BUG=N/A
TEST=tools/presubmit
Change-Id: I89e4d7599cdde2c9781117f2a8e53fc9c50aa909
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385874
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Uprev to version available in Debian.
This seem to end up doing uprev to 1.3 now.
BUG=b:265082456
BUG=b:229895468
TEST=build
Change-Id: I550778acb675c9034b9cfcea77f4ae847e2d2ea1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364559
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
The volatile_impl! and volatile_at_impl! macros were only used to
implement the traits for the File type, and they don't make sense for
any other type on Win32 anyway, so it is simpler to replace the macro
invocations with the actual implementation.
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: I695fdfdefa87fe267927ae15dc914a55b779021f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126569
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
"crosvm swap trim <socket_path>" command for trimming 2 types of pages
in the staging memory before swapping out to reduce the disk I/O.
* clean pages
* zero pages
The doc comment of TrimContext explains the page types.
BUG=b:265592787
TEST=cargo test -p swap
Change-Id: I5c33149f7d0bfd712f07fd11eb9aa07c1a8b0e7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4357224
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Add snapshot to vCPU for x86 and x86_64 arch.
BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket
Change-Id: I65d059a7537c713e9ef6c1456a7aeae2b6bc4728
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237759
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Pre-populating page cache improves the latency of swap-in which I/O wait
mostly have taken up. This was because page cache populations were
triggered on page fault basis. Since swap-in operation moves pages
sequentially, pre-populating has a benefit on the latency.
MADV_WILLNEED causes the kernel to asynchronously start populating the
pages, and MLOCK_ONFAULT ensures that the data remains in the page cache
until it is UFFD_COPYed. mlock(2) without MLOCK_ONFAULT is not
applicable because it blocks the calling thread until populated.
MADV_DONTNEED is also important in terms of the swap-in latency. It
frees the page cache which is already UFFD_COPYed to be reused for later
readaheading swap file. Otherwise the memory pressure from the swap file
page cache population triggers system-wide page frame collection which
is heavy.
Pre-populating page cache alone is actually not enough to improve the
swap-in latency without swapping in on a background thread
(https://crrev.com/c/4317028).
BUG=b:265606668
TEST=cargo test -p swap
Change-Id: I2069c1260d0cf45499298999a71621e563f28f30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4314186
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This CL introduced a negligible amount of overhead as some read
operations on some tiny data strucutres (acpi netlink events) are
converted from zerocopy to single copy.
Also fixed a naming mistake around PCI MSI and manually added
padding to allow AsBytes to be derived.
TEST=CQ
BUG=b:204409584
Change-Id: Ibafe4c413fbed50e61c54433d495ff024fe60da4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4348712
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>