fellow_cache: add fellow_cache_seglist_capaity utility

parent db0cdc22
...@@ -2480,6 +2480,15 @@ fellow_busy_fill_segmem(struct buddy_reqs *reqs, const void *priv) ...@@ -2480,6 +2480,15 @@ fellow_busy_fill_segmem(struct buddy_reqs *reqs, const void *priv)
AN(buddy_req_page(reqs, bits, 0)); AN(buddy_req_page(reqs, bits, 0));
} }
static size_t
fellow_cache_seglist_capacity(unsigned bits)
{
size_t segs = fellow_cache_seglist_fit((size_t)1 << bits);
if (segs > FELLOW_DISK_SEGLIST_MAX_SEGS)
segs = FELLOW_DISK_SEGLIST_MAX_SEGS;
return (segs);
}
struct fellow_cache_res struct fellow_cache_res
fellow_busy_obj_alloc(struct fellow_cache *fc, fellow_busy_obj_alloc(struct fellow_cache *fc,
struct fellow_cache_obj **fcop, uintptr_t *priv2, struct fellow_cache_obj **fcop, uintptr_t *priv2,
...@@ -2774,9 +2783,7 @@ fellow_busy_body_seglist_size_strategy(size_t segs, unsigned chunk_exponent) ...@@ -2774,9 +2783,7 @@ fellow_busy_body_seglist_size_strategy(size_t segs, unsigned chunk_exponent)
else if (bits > chunk_exponent) else if (bits > chunk_exponent)
bits = chunk_exponent; bits = chunk_exponent;
segs = fellow_cache_seglist_fit((size_t)1 << bits); segs = fellow_cache_seglist_capacity(bits);
if (segs > FELLOW_DISK_SEGLIST_MAX_SEGS)
segs = FELLOW_DISK_SEGLIST_MAX_SEGS;
assert(segs <= UINT16_MAX); assert(segs <= UINT16_MAX);
return ((uint16_t)segs); return ((uint16_t)segs);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment