From patchwork Mon Mar 28 12:34:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8679191 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 8E80A9F54E for ; Mon, 28 Mar 2016 12:34:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE66D2027D for ; Mon, 28 Mar 2016 12:34:29 +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 3577B20272 for ; Mon, 28 Mar 2016 12:34:29 +0000 (UTC) Received: from localhost ([::1]:40793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akWNI-0006OX-5H for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Mar 2016 08:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akWNB-0006OO-57 for qemu-devel@nongnu.org; Mon, 28 Mar 2016 08:34:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akWN7-0003ru-T0 for qemu-devel@nongnu.org; Mon, 28 Mar 2016 08:34:21 -0400 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:36157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akWN7-0003rn-L9 for qemu-devel@nongnu.org; Mon, 28 Mar 2016 08:34:17 -0400 Received: by mail-pa0-x241.google.com with SMTP id 1so14971460pal.3 for ; Mon, 28 Mar 2016 05:34:17 -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=/3qr+tlTffSclfIohwqam39K/C1OOkwfztgkjnE2KdU=; b=V8HIieDKmTBk9J5tHQN+rstW/K7afdSJd1UU3P4y/9sY7uFKxLnskgR5GO6yHrUP9e HJwfmU6PMZcHJGDnzLOc+j5yY3u8qnpFCgVB9c/ZUw6IO1DpFkOl72Y4AsloZ/3Qam4C 3p4NxyuRS3SE+ZKAFU8uN6gHSw3Y2VNmp/U7tGkZZDfd373UVkb66BUIuJ+cNh2MfKcJ oMvM/69ppUuL2/50x1qQOpx1GWANCdVa9eWi6lBP2ZtHaNZpg5v1DY2JGEMxn+Oqh/9Q 7GNUXB3c8S6DbhHCu5Q+F1CQ3X5LpQxdpa8BjIAh2zHLzBTIkEMF8sN06I1qNIBcJFur ti3Q== 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=/3qr+tlTffSclfIohwqam39K/C1OOkwfztgkjnE2KdU=; b=Npf/wj3Xq4OSlWSJV26GH6dISdFMS7JrN0swh+1bhFl93ZpY2vASKniz0/Hnse9EcI ugosa7SnDTgXLpSSJxC0GrVl5S1I7ErYnzQ//J7y3LnOEPf8vct1rEFTXSZoLgF+Z6CO 3jMfljwyNSyWv/h+N573iRimLAHZokyf2nbg8KV+JSbvmCoDyT3M5uYVzRK1JNpuynSV TkMGQj21eUrpRFFlfBiV2xtYyo034HtR3Vd130lT6yuohYCV8ZYQsvRqTFqr/JIwRVGl fR4+dBXSIQWQVo8xrIvw8oq/PXiI1dZUn5ZOyFQuDBB091fgZ7F2+gUFD7asD36Pmw1A K0uQ== X-Gm-Message-State: AD7BkJLan7RCX8TWAVtwVhLfYWo4u3ygegaATwcR444RcOsHX+C0iURLZc8ngfqrgleK+Q== X-Received: by 10.66.118.7 with SMTP id ki7mr42612737pab.152.1459168456373; Mon, 28 Mar 2016 05:34:16 -0700 (PDT) Received: from Inspiron-N5010.domain.name ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id n74sm35558918pfa.45.2016.03.28.05.34.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Mar 2016 05:34:15 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Mon, 28 Mar 2016 18:04:11 +0530 Message-Id: <1459168451-2626-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:c03::241 Subject: [Qemu-devel] [PATCH v5] 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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Pooja Dhannawat --- 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,