From patchwork Thu Mar 17 15:47:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8612431 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4B5349F3D1 for ; Thu, 17 Mar 2016 15:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A72462021B for ; Thu, 17 Mar 2016 15:50:05 +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 0BDB120212 for ; Thu, 17 Mar 2016 15:50:05 +0000 (UTC) Received: from localhost ([::1]:36041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaBY-0004zZ-Eo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 11:50:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaBM-0004wY-Lz for qemu-devel@nongnu.org; Thu, 17 Mar 2016 11:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agaBI-0008Oe-F1 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 11:49:52 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:32778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaBI-0008OX-7s for qemu-devel@nongnu.org; Thu, 17 Mar 2016 11:49:48 -0400 Received: by mail-pf0-x242.google.com with SMTP id x3so11639128pfb.0 for ; Thu, 17 Mar 2016 08:49:47 -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=EEPeZhEtL56sufM/rrQHawk1OpXA4ajBjSWjKfe5s1o=; b=Etj1SqCRo/eKrf75lj5jMczAOHgMZ5+cns8Akx6XTc6ns20mv++tiMBtYz/kb+iFsQ l1YXyrDRyvcMaYhs7DWTM2JcNlr1xoAVoaG/oeIADYU2jJ6BwjMLkZhx1LvwOpUGKN1f eMJkerhgPpAIWItr8Vy4NfMvHnjbelqeCkydatHrgwJqgjBFGI8kw+1njh/jfhQYGgL3 c5t1C1KeLak5mTuzef0kKPElN/mNiD8WCysW06ldB3vbh70csaraL11nvz67fz4zoT6h XkS4UkrHh54bxh2XH/XEsUtq8NUO8L9y1deWJMfDAMmr+6qhi1kYoWAmtUgw1ycJVPLn Jywg== 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=EEPeZhEtL56sufM/rrQHawk1OpXA4ajBjSWjKfe5s1o=; b=fd+eGRbyukXpif+FiUpwlcqCbdQF93G6HiyvYd6GN0oQpmvYdcSSM+TeBzen+mnREE +zktfPacnK/5aKtesCOsD1GOuh3PzweeIU1z0+wuw0nAVt3K+5KCCVVpUF69uMLJroVo Fa/cNjkkXY1+ZGapUtR/UrczUZFd+TdpX5qlY6pJBv6aWYhtUNcRbU7nJbG9QX7r2cIs HteDt9NDSrPG21Bcw4wJcQXkI/G/Hd5QnuXx+zCy+IG4wV0RKXYKlu21CH0m8wNgWrbK hW3KMPXMvPV9F/Adw+FVpGbCvzipIzBGbQ0GwSZKTC0Ve73xgMgDIBW1XXUFejU0Jnmc E2gw== X-Gm-Message-State: AD7BkJKp2Lud+vrnIlEKiy/AeD/bTlYAXz18947sftIoXYkHZ/nD7oy240IidkyOllkdqw== X-Received: by 10.98.72.90 with SMTP id v87mr858072pfa.71.1458229787380; Thu, 17 Mar 2016 08:49:47 -0700 (PDT) Received: from localhost.localdomain ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id e87sm14328553pfb.76.2016.03.17.08.49.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Mar 2016 08:49:46 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Thu, 17 Mar 2016 21:17:40 +0530 Message-Id: <1458229660-6712-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] net: 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 nc_sendv_compat has a huge stack usage of 69680 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat Reviewed-by: Stefan Hajnoczi --- net/net.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..663da13 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,28 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { - uint8_t buf[NET_BUFSIZE]; + uint8_t *buf = NULL; uint8_t *buffer; size_t offset; + ssize_t ret; if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { + buf = g_new(uint8_t, NET_BUFSIZE); buffer = buf; - offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); + offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { - return nc->info->receive_raw(nc, buffer, offset); + ret = nc->info->receive_raw(nc, buffer, offset); } else { - return nc->info->receive(nc, buffer, offset); + ret = nc->info->receive(nc, buffer, offset); } + + g_free(buf); + return ret; } ssize_t qemu_deliver_packet_iov(NetClientState *sender,