kernel/slab: Use FIFO queuing for PARANOID_KERNEL_FREE only.

FIFO does seem to be a slight performance hit, and the security benefits
are probably not too large in the end. So just use LIFO otherwise.
This commit is contained in:
Augustin Cavalier
2025-09-08 14:06:51 -04:00
parent cac7959664
commit e3d01e53a2
2 changed files with 28 additions and 2 deletions
+2 -2
View File
@@ -357,10 +357,10 @@ object_depot_make_empty(object_depot* depot, uint32 flags)
// detach the depot's full and empty magazines
slab_queue fullMagazines = depot->full;
depot->full.head = depot->full.tail = NULL;
depot->full.Init();
slab_queue emptyMagazines = depot->empty;
depot->empty.head = depot->empty.tail = NULL;
depot->empty.Init();
writeLocker.Unlock();
+26
View File
@@ -8,11 +8,14 @@
#include <stddef.h>
#include "kernel_debug_config.h"
struct slab_queue_link {
slab_queue_link* next;
};
#if PARANOID_KERNEL_FREE
struct slab_queue {
slab_queue_link* head;
slab_queue_link* tail;
@@ -44,6 +47,29 @@ struct slab_queue {
return item;
}
};
#else /* LIFO queue */
struct slab_queue {
slab_queue_link* head;
void Init()
{
head = NULL;
}
void Push(slab_queue_link* item)
{
item->next = head;
head = item;
}
slab_queue_link* Pop()
{
slab_queue_link* item = head;
head = item->next;
return item;
}
};
#endif
#endif // SLAB_QUEUE_H