From: Paul Durrant <paul@xen.org>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Paul Durrant <pdurrant@amazon.com>,
Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wl@xen.org>
Subject: [PATCH] libxl: stop libxl_domain_info() consuming massive amounts of stack
Date: Thu, 28 May 2020 12:48:01 +0100 [thread overview]
Message-ID: <20200528114801.20241-1-paul@xen.org> (raw)
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.
---
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..c07ec8fd3a 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);
+ info = libxl__calloc(gc, 1024, sizeof(*info));
+
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
next reply other threads:[~2020-05-28 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 11:48 Paul Durrant [this message]
2020-05-28 14:56 ` [PATCH] libxl: stop libxl_domain_info() consuming massive amounts of stack Ian Jackson
2020-05-28 14:58 ` Paul Durrant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200528114801.20241-1-paul@xen.org \
--to=paul@xen.org \
--cc=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=pdurrant@amazon.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.