summaryrefslogtreecommitdiff
path: root/src/kernel/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/malloc.c')
-rw-r--r--src/kernel/malloc.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/kernel/malloc.c b/src/kernel/malloc.c
index 3c10108..ca44cfe 100644
--- a/src/kernel/malloc.c
+++ b/src/kernel/malloc.c
@@ -11,6 +11,27 @@
#define SCMIN 6 /* 1<<6 == 64 */
#define SCMAX 12 /* 1<<11 == 2048 */
+const char *tagnames[] = {
+ "TagInvalid",
+ "TagKernelFs",
+ "TagProcFs",
+ "TagUserFs",
+ "TagOpenPath",
+ "TagMountPath",
+ "TagMountUser",
+ "TagMountRoot",
+ "TagExecbuf",
+ "TagVfsReq",
+ "TagHandleset",
+ "TagHandle",
+ "TagProcess",
+ "TagProcessHandle",
+ "TagDevTime",
+ "TagRootCache",
+ "TagPageRefcount",
+};
+static_assert(sizeof(tagnames) == sizeof(const char *) * TagLast);
+
typedef struct Slab Slab;
struct Slab {
/* The slab is divided up into 1<<sizeclass sized regions.
@@ -108,13 +129,16 @@ getheader(void *addr)
}
void *
-kmalloc(size_t len, const char *desc)
+kmalloc(size_t len, enum MallocTag tag)
{
Slab *al;
void *ret;
int sizeclass, regsize;
uint64_t idx;
+ assert(tag != TagInvalid && tag < TagLast);
+ const char *desc = tagnames[tag] + 3; // very temporary
+
assert(len <= KMALLOC_MAX);
len += DESCLEN;
sizeclass = getsizeclass(len);