* [PATCH v2] libxl: stop libxl_domain_info() consuming massive amounts of stack
@ 2020-05-28 15:13 Paul Durrant
2020-05-28 15:44 ` Ian Jackson
0 siblings, 1 reply; 2+ messages in thread
From: Paul Durrant @ 2020-05-28 15:13 UTC (permalink / raw)
To: xen-devel; +Cc: Anthony PERARD, Paul Durrant, Ian Jackson, Wei Liu
From: Paul Durrant <pdurrant@amazon.com>
Currently an array of 1024 xc_domaininfo_t is declared on stack. That alone
consumes ~112k. Since libxl_domain_info() creates a new gc this patch simply
uses it to allocate the array instead.
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>
This is small and IMO it would be nice to have this in 4.14 but I'd like an
opinion from a maintainer too.
v2:
- Use GCNEW_ARRAY
---
tools/libxl/libxl_domain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index fef2cd4e13..bb21087eb8 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -314,11 +314,13 @@ libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int *nb_domain_out)
{
libxl_dominfo *ptr = NULL;
int i, ret;
- xc_domaininfo_t info[1024];
+ xc_domaininfo_t *info;
int size = 0;
uint32_t domid = 0;
GC_INIT(ctx);
+ GCNEW_ARRAY(info, 1024);
+
while ((ret = xc_domain_getinfolist(ctx->xch, domid, 1024, info)) > 0) {
ptr = libxl__realloc(NOGC, ptr, (size + ret) * sizeof(libxl_dominfo));
for (i = 0; i < ret; i++) {
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] libxl: stop libxl_domain_info() consuming massive amounts of stack
2020-05-28 15:13 [PATCH v2] libxl: stop libxl_domain_info() consuming massive amounts of stack Paul Durrant
@ 2020-05-28 15:44 ` Ian Jackson
0 siblings, 0 replies; 2+ messages in thread
From: Ian Jackson @ 2020-05-28 15:44 UTC (permalink / raw)
To: Paul Durrant; +Cc: Anthony Perard, xen-devel, Paul Durrant, Wei Liu
Paul Durrant writes ("[PATCH v2] libxl: stop libxl_domain_info() consuming massive amounts of stack"):
> From: Paul Durrant <pdurrant@amazon.com>
>
> Currently an array of 1024 xc_domaininfo_t is declared on stack. That alone
> consumes ~112k. Since libxl_domain_info() creates a new gc this patch simply
> uses it to allocate the array instead.
>
> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wl@xen.org>
> Cc: Anthony PERARD <anthony.perard@citrix.com>
>
> This is small and IMO it would be nice to have this in 4.14 but I'd like an
> opinion from a maintainer too.
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
I agree that this is 4.14 material.
Ian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-28 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 15:13 [PATCH v2] libxl: stop libxl_domain_info() consuming massive amounts of stack Paul Durrant
2020-05-28 15:44 ` Ian Jackson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.