From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fNo-0007rt-Na for qemu-devel@nongnu.org; Sun, 22 May 2016 22:14:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4fNj-0002c0-2m for qemu-devel@nongnu.org; Sun, 22 May 2016 22:14:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fNi-0002bv-SY for qemu-devel@nongnu.org; Sun, 22 May 2016 22:14:10 -0400 From: Jason Wang Date: Mon, 23 May 2016 10:13:43 +0800 Message-Id: <1463969642-5908-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1463969642-5908-1-git-send-email-jasowang@redhat.com> References: <1463969642-5908-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PULL 01/20] net/tap: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: Zhou Jie , Jason Wang From: Zhou Jie net_init_tap has a huge stack usage of 8192 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Zhou Jie Signed-off-by: Jason Wang --- net/tap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/tap.c b/net/tap.c index 740e8a2..49817c7 100644 --- a/net/tap.c +++ b/net/tap.c @@ -769,8 +769,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } } else if (tap->has_fds) { - char *fds[MAX_TAP_QUEUES]; - char *vhost_fds[MAX_TAP_QUEUES]; + char **fds = g_new(char *, MAX_TAP_QUEUES); + char **vhost_fds = g_new(char *, MAX_TAP_QUEUES); int nfds, nvhosts; if (tap->has_ifname || tap->has_script || tap->has_downscript || @@ -818,6 +818,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } } + g_free(fds); + g_free(vhost_fds); } else if (tap->has_helper) { if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) { -- 2.7.4