From patchwork Mon Mar 14 16:37:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8581311 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EC051C0553 for ; Mon, 14 Mar 2016 16:40:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 520FA20254 for ; Mon, 14 Mar 2016 16:40:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3372E203B0 for ; Mon, 14 Mar 2016 16:40:33 +0000 (UTC) Received: from localhost ([::1]:42297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afVXk-0005Ne-LC for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Mar 2016 12:40:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afVXH-0004kn-LE for qemu-devel@nongnu.org; Mon, 14 Mar 2016 12:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afVXD-0000vs-At for qemu-devel@nongnu.org; Mon, 14 Mar 2016 12:40:03 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afVXD-0000vT-4I for qemu-devel@nongnu.org; Mon, 14 Mar 2016 12:39:59 -0400 Received: by mail-pf0-x241.google.com with SMTP id u190so10262737pfb.2 for ; Mon, 14 Mar 2016 09:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=Vbb3Dfs6Un9OvdUcvEbKPLG671ezUwYn3pldkZBeAWA=; b=vHOM0FpW0Kz4VuqPZahHUM6heE6uuVsvvwFXafe2S5sL9VG8ryDksGv/gQnD3KUClT OgOusHzbseN7ZNZrm6tw0CSepvRse7Lwh0QAXko2szGVbOXrhtwtNtrp22bs5MVDcad9 FUW7pa1FsG30MHFEQ83ztXXM2r93m+P9Nw9HcavNUyUAq22GvbP3m+AyUivxQcTW7zjP PK1FemOIk/VzbCmXdKmouWP+4IvkgHms5oG+yaUIjnUOABFzsYLiY0VtMTzJ9XTTfp+h IMAxszVzIHP6ykV647TRt8GCEO6YzDrbm+7lJFXNXiJOzTQjj24fVgWzsaSg0sn79XoR Pvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Vbb3Dfs6Un9OvdUcvEbKPLG671ezUwYn3pldkZBeAWA=; b=YLpSNzgnEpBFhXaSWIcZk1teGwFKjKsn9f4DAr3jhdn56izhtbkWIT+tanuw7PO/+7 HCUih6Ck1wuxj5szD+vuk+B7Pk46lv59S8O0SJXtN1q1cdnG8pc39bAik5U4Mijfo5XL qAI1k4zi2Ef+ikS+KWA22t5DsgoGr8TLO5ejJPp3YPAhAbSqnvrOMXwAcmW2ArEfUzxt i0tLR5+A5mdAaLRJWIBpPw0AcCOrTpPLowIWpHHvq4FWG4lbikyIk1a+ad3qBHbqXMq/ YOUTGhjt24tbS2GmBtmzbcLWt1JN4IU9Puj1Fzj1pIJk+lrEdjVM5IZSHb+GIquY11e0 w+6Q== X-Gm-Message-State: AD7BkJICzKqfHELjWA6dWXdul0cYD9pFgPO+ZSHqfh8Z7IhXcF9d+YHmaA5EzM9k+AuVZw== X-Received: by 10.98.86.146 with SMTP id h18mr31673683pfj.9.1457973598391; Mon, 14 Mar 2016 09:39:58 -0700 (PDT) Received: from localhost.localdomain ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id x64sm33378239pfa.72.2016.03.14.09.39.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Mar 2016 09:39:57 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Mon, 14 Mar 2016 22:07:53 +0530 Message-Id: <1457973473-21791-1-git-send-email-dhannawatpooja1@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com> References: <1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 1/1] socket: Allocating Large sized arrays to heap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP net_socket_send has a huge stack usage of 69712 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat --- net/socket.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/socket.c b/net/socket.c index e32e3cb..3fcd7a6 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; - uint8_t buf1[NET_BUFSIZE]; + uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE); const uint8_t *buf; - size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); + size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; - memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); + g_free(buf1); return; } @@ -222,6 +222,8 @@ static void net_socket_send(void *opaque) break; } } + + g_free(buf1); } static void net_socket_send_dgram(void *opaque)