From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auxCP-0000rj-Ss for qemu-devel@nongnu.org; Tue, 26 Apr 2016 03:14:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auxCL-0004FA-8o for qemu-devel@nongnu.org; Tue, 26 Apr 2016 03:14:21 -0400 References: <1461633961-31713-1-git-send-email-zhoujie2011@cn.fujitsu.com> From: Jason Wang Message-ID: <571F1544.2090109@redhat.com> Date: Tue, 26 Apr 2016 15:14:12 +0800 MIME-Version: 1.0 In-Reply-To: <1461633961-31713-1-git-send-email-zhoujie2011@cn.fujitsu.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] net/tap: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhou Jie , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org On 04/26/2016 09:26 AM, Zhou Jie wrote: > 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 > --- > 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) { Apply to net-next. Thanks