aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2025-02-05 00:11:31 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-02-05 00:11:31 +0100
commiteeb12a40ea48aa4d5658618a46baef9fe3c3818e (patch)
tree829c2ebc8192f823d2ca77b96bf384932061e41d
parent0933418a1625da62d7ba79d5ee33ee2c256999a5 (diff)
downloadhurd-eeb12a40ea48aa4d5658618a46baef9fe3c3818e.tar.gz
hurd-eeb12a40ea48aa4d5658618a46baef9fe3c3818e.tar.bz2
hurd-eeb12a40ea48aa4d5658618a46baef9fe3c3818e.zip
rumpdisk: Call thread_wire in all our threadsHEADmaster
So the kernel gives us vm_privilege so we can work even when memory is getting low.
-rw-r--r--rumpdisk/main.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/rumpdisk/main.c b/rumpdisk/main.c
index ca166274..0de01312 100644
--- a/rumpdisk/main.c
+++ b/rumpdisk/main.c
@@ -99,13 +99,28 @@ static struct argp_child empty_argp_children[] = {{0}};
static struct argp rumpdisk_argp = {options, parse_opt, 0, 0, empty_argp_children};
static const struct argp *rumpdisk_argp_bootup = &rumpdisk_argp;
+static int __thread wired = 0;
+static int rumpdisk_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
+{
+ /* FIXME: we are not wired while receiving our first message. */
+ if (!wired)
+ {
+ mach_port_t self = mach_thread_self ();
+ thread_wire (_hurd_host_priv, self, TRUE);
+ mach_port_deallocate (mach_task_self (), self);
+ wired = 1;
+ }
+
+ return machdev_demuxer (inp, outp);
+}
+
static void *
rumpdisk_multithread_server(void *arg)
{
do
{
ports_manage_port_operations_multithread (machdev_device_bucket,
- machdev_demuxer,
+ rumpdisk_demuxer,
1000 * 60 * 2, /* 2 minute thread */
1000 * 60 * 10, /* 10 minute server */
0);
@@ -140,7 +155,10 @@ main (int argc, char **argv)
swapping. */
err = wire_task_self ();
if (err)
- error (1, errno, "cannot lock all memory");
+ error (1, err, "cannot lock all memory");
+ err = thread_wire (_hurd_host_priv, mach_thread_self (), TRUE);
+ if (err != KERN_SUCCESS)
+ error (1, err, "cannot get vm_privilege");
machdev_device_init ();
err = pthread_create (&t, NULL, rumpdisk_multithread_server, NULL);