[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [UNIKRAFT PATCH v2 1/2] lib/ukallocpool: Always provide `uk_alloc_availmem()`, `uk_alloc_maxalloc()`



Hi Cezar,

thanks a lot for your review.

On 03.03.21 21:10, Cezar Craciunoiu wrote:
Hey Simon,

This patch looks good to me.

Just one small thing. Why do these two functions return a signed value if 
obj_len is unsigned?

This is coming from the API and for the case to return error values as negative numbers, e.g., -ENOTSUP.

Thanks,

Simon


Cezar

Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@xxxxxxxxx 
[mailto:cezar.craciunoiu@xxxxxxxxx]>
On 2020-12-22 14:57:11, Simon Kuenzer <simon.kuenzer@xxxxxxxxx> wrote:
Adopts to the changed meaning of `CONFIG_LIBUKALLLC_IFSTATS` and provide
`uk_alloc_availmem()` and `uk_alloc_maxalloc()` always.

Signed-off-by: Simon Kuenzer
---
lib/ukallocpool/pool.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index 390f6b92..0ff24c38 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -208,14 +208,19 @@ void uk_allocpool_return_batch(struct uk_allocpool *p,
_prepend_free_obj(p, obj[i]);
}

-#if CONFIG_LIBUKALLOC_IFSTATS
static ssize_t pool_availmem(struct uk_alloc *a)
{
struct uk_allocpool *p = ukalloc2pool(a);

- return (size_t) p->free_obj_count * p->obj_len;
+ return (ssize_t) (p->free_obj_count * p->obj_len);
+}
+
+static ssize_t pool_maxalloc(struct uk_alloc *a)
+{
+ struct uk_allocpool *p = ukalloc2pool(a);
+
+ return (ssize_t) p->obj_len;
}
-#endif

size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
size_t obj_align)
@@ -300,6 +305,8 @@ out:
pool_free,
pool_posix_memalign,
uk_memalign_compat,
+ pool_maxalloc,
+ pool_availmem,
NULL);
#if CONFIG_LIBUKALLOC_IFSTATS
p->self.availmem = pool_availmem;
--
2.20.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.