Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/zlib/zcalloc.c
Show All 18 Lines | |||||
void * | void * | ||||
zcalloc_nowait(void *nil, u_int items, u_int size) | zcalloc_nowait(void *nil, u_int items, u_int size) | ||||
{ | { | ||||
return mallocarray(items, size, M_ZLIB, M_NOWAIT); | return mallocarray(items, size, M_ZLIB, M_NOWAIT); | ||||
} | } | ||||
void * | |||||
zcalloc(void *nil, u_int items, u_int size) | |||||
{ | |||||
return zcalloc_nowait(nil, items, size); | |||||
ota_j.email.ne.jp: I had chosen waitok version in https://reviews.freebsd.org/D20271 based on the number of… | |||||
} | |||||
void | void | ||||
zcfree(void *nil, void *ptr) | zcfree(void *nil, void *ptr) | ||||
{ | { | ||||
free(ptr, M_ZLIB); | free(ptr, M_ZLIB); | ||||
} | } |
I had chosen waitok version in https://reviews.freebsd.org/D20271 based on the number of existing callers. We have more waitok callers than that of nowait.
I'm okay with nowait being default as well.
private email from Xin Li :
Another difference in my proposed change is that zcalloc in my version
would use M_NOWAIT. This is the userland behavior (if memory is full,
the function would bail out instead of block waiting), and I think a
majority of kernel code should be expecting this behavior (especially if
they are holding a lock, for example), and they are expected to handle
errors from zlib anyway.