summaryrefslogtreecommitdiff
path: root/debian/patches/700007-Use-the-slab-allocator.patch
blob: e89f253eeca60369c8abebd7d41f9243be8cbef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From ad33ca5d3fbc25618d26b7af4d9a67be041c779a Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Fri, 26 Feb 2016 13:43:11 +0100
Subject: [PATCH gnumach 07/10] Use the slab allocator

---
 device/intr.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/device/intr.c b/device/intr.c
index b0dcd83..0fa43c5 100644
--- a/device/intr.c
+++ b/device/intr.c
@@ -10,6 +10,9 @@
 #define sti() __asm__ __volatile__ ("sti": : :"memory")
 #define cli() __asm__ __volatile__ ("cli": : :"memory")
 
+/* The cache which holds our proxy memory objects.  */
+static struct kmem_cache intr_entry_cache;
+
 struct intr_entry
 {
   queue_chain_t chain;
@@ -58,7 +61,7 @@ insert_intr_entry (int line, ipc_port_t dest, struct intr_entry **entry)
   struct intr_entry *e, *new;
   int free = 0;
 
-  new = (struct intr_entry *) kalloc (sizeof (*new));
+  new = (struct intr_entry *) kmem_cache_alloc (&intr_entry_cache);
   if (new == NULL)
     return D_NO_MEMORY;
   new->line = line;
@@ -81,7 +84,7 @@ insert_intr_entry (int line, ipc_port_t dest, struct intr_entry **entry)
 out:
   sti ();
   if (free)
-    kfree ((vm_offset_t) new, sizeof (*new));
+    kmem_cache_free (&intr_entry_cache, (vm_offset_t) new);
   *entry = new;
   return err;
 }
@@ -146,6 +149,9 @@ intr_thread ()
   queue_init (&intr_queue);
   init_mach_intr_notification (&mach_intr_notification_template);
 
+  kmem_cache_init (&intr_entry_cache, "intr_entry",
+		   sizeof (struct intr_entry), 0, NULL, 0);
+
   for (;;)
     {
       assert_wait ((event_t) &intr_thread, FALSE);
@@ -183,7 +189,7 @@ intr_thread ()
 	      assert (!queue_empty (&intr_queue));
 	      queue_remove (&intr_queue, e, struct intr_entry *, chain);
 	      sti ();
-	      kfree ((vm_offset_t) e, sizeof (*e));
+	      kmem_cache_free (&intr_entry_cache, (vm_offset_t) e);
 	      cli ();
 	    }
 	}
-- 
2.1.4