From patchwork Mon Mar 14 17:52:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8582911 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 3CE9DC0553 for ; Mon, 14 Mar 2016 18:02:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 853B22015E for ; Mon, 14 Mar 2016 18:02:04 +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 A8BB5200FE for ; Mon, 14 Mar 2016 18:02:03 +0000 (UTC) Received: from localhost ([::1]:43135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afWod-0007Dg-6N for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Mar 2016 14:02:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afWhX-00033a-1T for qemu-devel@nongnu.org; Mon, 14 Mar 2016 13:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afWhT-0005AC-S7 for qemu-devel@nongnu.org; Mon, 14 Mar 2016 13:54:42 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afWhT-00059n-MK for qemu-devel@nongnu.org; Mon, 14 Mar 2016 13:54:39 -0400 Received: by mail-pf0-x243.google.com with SMTP id u190so10431894pfb.2 for ; Mon, 14 Mar 2016 10:54:39 -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=anc6MNm14a3Wr7j/Co6rn5LIWCS72jEnCgpWilzwMn4=; b=jA3e7NYNa5DbOd3P/Mh4HSxop9JtLiJ6CmdaOXlFKpbnrY7wzIZLuYZPBUHftyypKM TrLH0PihEzv4kSSDC7jIL6C7keK1qMkHy1I5s9089wI9Wd4DR8YF4tNXR75/dYSwjG1P 1GxWnBjvDpMeYq4BtVzngQ5bKXMmeoCmPLsPN9a2NUxfCaXCJcglGQpSRbCcXhHit2z+ AXRJvadCi5i7rW+OVX4J/0FrFbZboL1PV1bRbOZ5dRHjRxzX+ZMYqM3kVNnnDdHZs+4q bSnxhVsrkM4YCIaEpzZCwintJw/3iG2c316rVLUj/FbyAh+QDXhMTC2luyqSJsKuIPK7 y2SA== 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=anc6MNm14a3Wr7j/Co6rn5LIWCS72jEnCgpWilzwMn4=; b=NntCDuqpNQ5Ld7UbrjNWPLLnHIx1OIU0IlpN6W+9F39k/+lC39Nb4jBUTLo8vcCPZb /IASlFhns/f58wBCSiKD7/4wHPxHWrP5OxKE9MTcZggEI3ZjeBuARQJkctxFiy6jQxbc TmJyQg9sSruX0qUh6M4qp9wAzb+BuV/W8pIPWjGa+I/EICYOEG4O04GDSjxZ7ceSbwfL pILVYgphaXIkeoD/RJJPAOar9UtXbFPnb/nbUISpJiApBJOcCzyI+uR6IjpgjncVniiG 6dOW5fQ1oiEVo03E/pRUkVWzZUERS58iCEKkgAPwG6/AE8YRqCw7+I2i+0oqDvxMsuQj EIEw== X-Gm-Message-State: AD7BkJLh33phQIaZxYa79WOedjR3+wd9OXMsEisI9Nwn8p+xekUKcMV5qorfEN25A0Slkw== X-Received: by 10.98.93.211 with SMTP id n80mr32244069pfj.61.1457978078720; Mon, 14 Mar 2016 10:54:38 -0700 (PDT) Received: from localhost.localdomain ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id h19sm33669025pfh.43.2016.03.14.10.54.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Mar 2016 10:54:38 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Mon, 14 Mar 2016 23:22:33 +0530 Message-Id: <1457977953-28278-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::243 Subject: [Qemu-devel] [PATCH v3] 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..d7fa8ce 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, 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)