bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] pci-arbiter,rumpdisk: Lock all memory for swapping


From: Damien Zammit
Subject: [PATCH 4/5] pci-arbiter,rumpdisk: Lock all memory for swapping
Date: Sun, 26 Dec 2021 22:38:56 +1100

This locks all memory in bootstrap processes so that
disk driver dependencies don't get swapped out.

---
 pci-arbiter/main.c | 9 +++++++++
 rumpdisk/main.c    | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/pci-arbiter/main.c b/pci-arbiter/main.c
index 510e7dbc..602a545c 100644
--- a/pci-arbiter/main.c
+++ b/pci-arbiter/main.c
@@ -203,8 +203,17 @@ main (int argc, char **argv)
 
   if (next_task != MACH_PORT_NULL)
     {
+      /* We are a bootstrap process */
+
       machdev_register (&pci_arbiter_emulation_ops);
       machdev_trivfs_init (argc, argv, next_task, "pci", NULL /* _SERVERS_BUS 
"pci" */, &bootstrap);
+
+      /* Make sure we will not swap out, in case we are needed for swapping
+         back in.  */
+      err = mlockall(MCL_CURRENT | MCL_FUTURE);
+      if (err)
+        error (1, errno, "cannot lock all memory");
+
       machdev_device_init ();
       err = pthread_create (&t, NULL, machdev_server, NULL);
       if (err)
diff --git a/rumpdisk/main.c b/rumpdisk/main.c
index bafe0250..a1873c31 100644
--- a/rumpdisk/main.c
+++ b/rumpdisk/main.c
@@ -25,6 +25,7 @@
 #include <error.h>
 #include <argp.h>
 #include <version.h>
+#include <sys/mman.h>
 
 #include "libmachdev/machdev.h"
 #include "block-rump.h"
@@ -113,6 +114,13 @@ main (int argc, char **argv)
 
   rump_register_block ();
   machdev_trivfs_init (argc, argv, bootstrap_resume_task, "rumpdisk", 
"/dev/rumpdisk", &bootstrap);
+
+  /* Make sure we will not swap out, in case we drive the disk used for
+     swapping.  */
+  err = mlockall(MCL_CURRENT | MCL_FUTURE);
+  if (err)
+    error (1, errno, "cannot lock all memory");
+
   machdev_device_init ();
   err = pthread_create (&t, NULL, machdev_server, NULL);
   if (err)
-- 
2.33.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]