summaryrefslogtreecommitdiff
path: root/lib/slab.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-03-09 09:13:31 +0100
committerMaria Matejka <mq@ucw.cz>2022-03-09 09:13:31 +0100
commit0c59f7ff0112abd1261afb8f21b7c00fc5e37885 (patch)
tree729362d6345c02a59c1b46ae777b039873dd040e /lib/slab.c
parentc20506dc07e1b99cf1d9f2cf9d00e9211cd9e2f4 (diff)
Revert "Bound allocated pages to resource pools with page caches to avoid unnecessary syscalls"
This reverts commit 7f0e59820899c30a243c18556ce2e3fb72d6d221.
Diffstat (limited to 'lib/slab.c')
-rw-r--r--lib/slab.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/slab.c b/lib/slab.c
index 70aa776a..8d16c433 100644
--- a/lib/slab.c
+++ b/lib/slab.c
@@ -152,7 +152,6 @@ slab_memsize(resource *r)
struct slab {
resource r;
- pool *p;
uint obj_size, head_size, head_bitfield_len;
uint objs_per_slab, num_empty_heads, data_size;
list empty_heads, partial_heads, full_heads;
@@ -192,7 +191,6 @@ slab *
sl_new(pool *p, uint size)
{
slab *s = ralloc(p, &sl_class);
- s->p = p;
uint align = sizeof(struct sl_alignment);
if (align < sizeof(int))
align = sizeof(int);
@@ -201,6 +199,7 @@ sl_new(pool *p, uint size)
s->obj_size = size;
s->head_size = sizeof(struct sl_head);
+ u64 page_size = get_page_size();
do {
s->objs_per_slab = (page_size - s->head_size) / size;
@@ -269,9 +268,9 @@ no_partial:
s->num_empty_heads--;
goto okay;
}
- h = alloc_page(s->p);
+ h = alloc_page();
#ifdef POISON
- memset(h, 0xba, page_size);
+ memset(h, 0xba, get_page_size());
#endif
ASSERT_DIE(SL_GET_HEAD(h) == h);
memset(h, 0, s->head_size);
@@ -330,9 +329,9 @@ sl_free(slab *s, void *oo)
if (s->num_empty_heads >= MAX_EMPTY_HEADS)
{
#ifdef POISON
- memset(h, 0xde, page_size);
+ memset(h, 0xde, get_page_size());
#endif
- free_page(s->p, h);
+ free_page(h);
}
else
{
@@ -349,11 +348,11 @@ slab_free(resource *r)
struct sl_head *h, *g;
WALK_LIST_DELSAFE(h, g, s->empty_heads)
- free_page(s->p, h);
+ free_page(h);
WALK_LIST_DELSAFE(h, g, s->partial_heads)
- free_page(s->p, h);
+ free_page(h);
WALK_LIST_DELSAFE(h, g, s->full_heads)
- free_page(s->p, h);
+ free_page(h);
}
static void
@@ -386,8 +385,7 @@ slab_memsize(resource *r)
WALK_LIST(h, s->full_heads)
heads++;
-// return ALLOC_OVERHEAD + sizeof(struct slab) + heads * (ALLOC_OVERHEAD + page_size);
- return ALLOC_OVERHEAD + sizeof(struct slab); /* The page sizes are accounted for in the pool */
+ return ALLOC_OVERHEAD + sizeof(struct slab) + heads * (ALLOC_OVERHEAD + get_page_size());
}
static resource *
@@ -397,10 +395,10 @@ slab_lookup(resource *r, unsigned long a)
struct sl_head *h;
WALK_LIST(h, s->partial_heads)
- if ((unsigned long) h < a && (unsigned long) h + page_size < a)
+ if ((unsigned long) h < a && (unsigned long) h + get_page_size() < a)
return r;
WALK_LIST(h, s->full_heads)
- if ((unsigned long) h < a && (unsigned long) h + page_size < a)
+ if ((unsigned long) h < a && (unsigned long) h + get_page_size() < a)
return r;
return NULL;
}