From patchwork Tue Mar 15 15:59:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8590231 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 64F7CC0553 for ; Tue, 15 Mar 2016 16:02:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEA4820263 for ; Tue, 15 Mar 2016 16:02:54 +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 C7A5D201C8 for ; Tue, 15 Mar 2016 16:02:50 +0000 (UTC) Received: from localhost ([::1]:49705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afrQn-0005ga-Rr for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Mar 2016 12:02:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afrQ9-0004oY-Ut for qemu-devel@nongnu.org; Tue, 15 Mar 2016 12:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afrQ5-00013i-TJ for qemu-devel@nongnu.org; Tue, 15 Mar 2016 12:02:09 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:32900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afrQ5-00013d-IG for qemu-devel@nongnu.org; Tue, 15 Mar 2016 12:02:05 -0400 Received: by mail-pf0-x242.google.com with SMTP id x3so3204269pfb.0 for ; Tue, 15 Mar 2016 09:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=aOJvT/ch6kAnVFkPeq50Yu7BwwkmhXU7/13NKSsh3hw=; b=iqY7ZecfQIDDyfcoQXtyEzyXJ5iXnGD/RSg0oIA54Jvfz5winJ4HBkZt6qvOuBya+3 80heZpBHH0Lzmorc6AK4wDTCGZXSsJbdIEWJRO+7ZeP8CG7N4JoZldWlm976d6Z4BEJI /VmtP1Y3EY594fZcuBkey6uDGhuJcJ9xdlcswCha887Rd8OK9H9swgb4myHqlxylUM1M b60KHDlX8RoN0KitbqMpwMj2dvFTfXyT2RhAAb3o5dlifkf7pOuJumpNQLZ0NWVQpoS6 P/dYPbaQ693jgrgnfU2TV8PpPQklTHkPoFityBD9R8rq2bBTOHIZHizCkS0OqwZgOfpL 0BzQ== 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; bh=aOJvT/ch6kAnVFkPeq50Yu7BwwkmhXU7/13NKSsh3hw=; b=aUIZZlMi9bSYJ464mOjph1bpTgb3D6ZWNTaAbKCh6TK4g0rdODrgKKuQoE4pWEmp43 ESjz/NOFzmpueACeFrYGm6cX9CT7MXZa/tWE9kVcrUUtcVHkOQZmlCuWviYml+p77JQ1 0eN0FxNBa0i0mD/Q3nfcR7vPmj6bKHKwNpEYTWrJOri6V1CiaEalTLUWtf7rXJkxKbMs Lu9IfTQTxP8yQ8rspsvmXsnYv084Px29mKi4RCClqJ+6TBMD2nr1vzu/+IBHB4riM7sy 264m9uZqEDtm+isPk6S5+t35rByjym5oja0hbjDeIuu291nU/Of6SNQzbjRSG+RFefo0 Secg== X-Gm-Message-State: AD7BkJKOFsG67iQKJ/oY/A/x6Km6zOzhcC0akJI4cliVHkbx8J1/TLpyiJyGdtEp1F4E8w== X-Received: by 10.98.7.81 with SMTP id b78mr29349299pfd.49.1458057724111; Tue, 15 Mar 2016 09:02:04 -0700 (PDT) Received: from localhost.localdomain ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id v14sm6525589pas.10.2016.03.15.09.02.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Mar 2016 09:02:03 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Tue, 15 Mar 2016 21:29:58 +0530 Message-Id: <1458057598-11041-1-git-send-email-dhannawatpooja1@gmail.com> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v4] 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..fd7f39f 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, buf1, NET_BUFSIZE, 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)