Reland "fs: Reduce number of open() calls in passthroughfs"

This is a reland of commit 55a9bccead02fe03839f6a31dcd3b4a070f1c481

The fix is to make sure we drop to the lock guard acquired by the
inodes mutex, so we don't end up in a deadlock. By splitting the if
statement and separating the else block, the guard is dropped
automatically.

Original change's description:
> fs: Reduce number of open() calls in passthroughfs
>
> Instead of always opening a new file every time we do an entry lookup,
> check first if the entry already exists in our inode map.
>
> I ran a trace test while loading a game on arcvm with and without this
> patch.
>
> Without patch:
> System-wide trace:
> newfstatat calls = 19211
> openat calls = 13189
> ~68% ratio of all newstat() calls vs openat() call
>
> virtiofs trace:
> newfstatat calls = 11958
> openat calls = 9899
> 82% ratio of virtiofs newstat() calls vs openat() call
>
> With patch:
> System-wide trace:
> newfstatat calls = 20242
> openat calls = 12954
> 64% ratio of all newstat() calls vs openat() call
>
> virtiofs trace:
> newfstatat calls = 2223
> openat = 273
> ~12% ratio of virtiofs newstat() calls vs openat() call
>
> This is a significant reduction of unnecessary syscalls in virtiofs
> (82% -> 12%)
>
> BUG=b:261922849
> TEST=loaded a game in arcvm and compared syscall % count
>
> Change-Id: I28acbae05900d9735ba3730ee106368ddc792476
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4091563
> Auto-Submit: Morg <morg@chromium.org>
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug: b:261922849
Change-Id: Ib885cb5f2b3f725405df2eecc641228042ea2093
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4105201
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Morg <morg@chromium.org>
1 file changed
tree: 230ed30102aa5c8a8eb3aebfc8f62b8c5c2e4516
  1. .cargo/
  2. .devcontainer/
  3. .github/
  4. .vscode/
  5. aarch64/
  6. acpi_tables/
  7. anti_tamper/
  8. arch/
  9. argh_helpers/
  10. base/
  11. bit_field/
  12. broker_ipc/
  13. common/
  14. crash_report/
  15. cros_async/
  16. cros_fdt/
  17. cros_tracing/
  18. crosvm-fuzz/
  19. crosvm_cli/
  20. crosvm_control/
  21. crosvm_plugin/
  22. devices/
  23. disk/
  24. docs/
  25. e2e_tests/
  26. fuse/
  27. gpu_display/
  28. hypervisor/
  29. infra/
  30. io_uring/
  31. kernel_cmdline/
  32. kernel_loader/
  33. kvm/
  34. kvm_sys/
  35. libcras_stub/
  36. linux_input_sys/
  37. logo/
  38. media/
  39. metrics/
  40. net_sys/
  41. net_util/
  42. power_monitor/
  43. prebuilts/
  44. proto_build_tools/
  45. protos/
  46. qcow_utils/
  47. resources/
  48. rutabaga_gfx/
  49. sandbox/
  50. seccomp/
  51. serde_keyvalue/
  52. src/
  53. swap/
  54. system_api/
  55. tests/
  56. third_party/
  57. tools/
  58. tpm2/
  59. tpm2-sys/
  60. tube_transporter/
  61. usb_sys/
  62. usb_util/
  63. vfio_sys/
  64. vhost/
  65. virtio_sys/
  66. vm_control/
  67. vm_memory/
  68. win_audio/
  69. win_util/
  70. x86_64/
  71. .dockerignore
  72. .gitignore
  73. .gitmodules
  74. .rustfmt.toml
  75. ARCHITECTURE.md
  76. build.rs
  77. Cargo.lock
  78. Cargo.toml
  79. CONTRIBUTING.md
  80. DIR_METADATA
  81. LICENSE
  82. mypy.ini
  83. OWNERS
  84. OWNERS_COUNCIL
  85. PRESUBMIT.cfg
  86. pyproject.toml
  87. README.chromeos.md
  88. README.md
  89. rust-toolchain
README.md

crosvm - The Chrome OS Virtual Machine Monitor

crosvm is a virtual machine monitor (VMM) based on Linux’s KVM hypervisor, with a focus on simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security boundary for running native applications on the Chrome OS platform. Compared to QEMU, crosvm doesn’t emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as the virtio standard.

crosvm is currently used to run Linux/Android guests on Chrome OS devices.

Logo