From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5kqu-0006vu-Ua for qemu-devel@nongnu.org; Wed, 25 May 2016 22:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5kqp-0001Rb-Aa for qemu-devel@nongnu.org; Wed, 25 May 2016 22:16:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5kqp-0001RX-4Z for qemu-devel@nongnu.org; Wed, 25 May 2016 22:16:43 -0400 From: Jason Wang Date: Thu, 26 May 2016 10:16:16 +0800 Message-Id: <1464228995-26657-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1464228995-26657-1-git-send-email-jasowang@redhat.com> References: <1464228995-26657-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PULL V3 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