From patchwork Tue Mar 15 18:25:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pooja Dhannawat X-Patchwork-Id: 8591401 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 719589F6E1 for ; Tue, 15 Mar 2016 18:27:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAA4F20259 for ; Tue, 15 Mar 2016 18:27:36 +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 0EB8C201FE for ; Tue, 15 Mar 2016 18:27:36 +0000 (UTC) Received: from localhost ([::1]:50554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aftgt-0003HC-5N for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Mar 2016 14:27:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aftgl-0003Gz-J8 for qemu-devel@nongnu.org; Tue, 15 Mar 2016 14:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aftgi-000075-ET for qemu-devel@nongnu.org; Tue, 15 Mar 2016 14:27:27 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aftgi-00006v-79 for qemu-devel@nongnu.org; Tue, 15 Mar 2016 14:27:24 -0400 Received: by mail-pf0-x244.google.com with SMTP id x3so3672094pfb.0 for ; Tue, 15 Mar 2016 11:27:24 -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=xG8SB61Z3HnEHiAqTdBttKunUwl+OeWsmmLF62f+N+I=; b=oxnJF+B+o+RsSOUIVUdm0Q4h7BhCoT3X/Ww+4st5zEQspWt6Od2oX85iWXYBhGi1R8 vLyDM2yjleUPtlwAkjru9yE4tDjECh4FFhyA7tlZozWb77AmFJ5pgGpRlEu/g5DIwSx1 DGmrcFevb+XmAy/eyNKvGKZvy6jJPt9YRuiy6Pvy5SRwjOqdQjZIypXxDJEHpZDKuRT3 Pg0VhaE7vlXoZtoQATrdGWx5sgVSfotIYJLzWouoo1f6nDVRziVW+O+SEitT1Ap8fCWr PaW8TC8m4R3q6PZw+5wZOEk4c8JAqqgP5Y45HYrx1a5TM+v8ejfo1gKvRDLsqN9kCDOX e6NQ== 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=xG8SB61Z3HnEHiAqTdBttKunUwl+OeWsmmLF62f+N+I=; b=P5BAWdyO4BBR7ZRAtV7/rzuvN43zFgv7hoR2KQXnrgqCCxe1GOKLSB09DlCapg3QvZ PvXZhnwDf7slVsoiPFw34ZdPAqbwOAVi9AaipDXcgp46mQ62Tbt88LQowjOvIVxjG0AT 92NwQLS4FDYAHvz7Do/XdoCPQkKVQUJuTD9JpwQ99i5GUMdnoUKmm9sUK131IsHpb5LT /mGV6IRhAi869dwXHVJcI8Slc3sNE+Si3UGstSWeVejFwFLszWiYCeMxSQO+GLu8XcoT m51U0ymI20vQy4o6d3asqxCiynsxIHiVyUbYBjTJnonmqfx7JShiVERXBKIXvZ1BZhj4 JUDg== X-Gm-Message-State: AD7BkJLymyczP5VrNufDO8BZrfGBRX/H3tnXAblqTIKiepoKaC5p3N/qP8KqEEPcywu8vQ== X-Received: by 10.98.33.208 with SMTP id o77mr796198pfj.108.1458066443338; Tue, 15 Mar 2016 11:27:23 -0700 (PDT) Received: from localhost.localdomain ([183.87.60.98]) by smtp.gmail.com with ESMTPSA id s197sm41230886pfs.62.2016.03.15.11.27.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Mar 2016 11:27:22 -0700 (PDT) From: Pooja Dhannawat To: qemu-devel@nongnu.org Date: Tue, 15 Mar 2016 23:55:13 +0530 Message-Id: <1458066313-12203-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::244 Subject: [Qemu-devel] [PATCH v3] 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 --- net/net.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..f03c571 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,29 @@ 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; uint8_t *buffer; size_t offset; + ssize_t ret; + + buf = g_new(uint8_t, NET_BUFSIZE); if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { 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,