From patchwork Mon Mar 14 15:40:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaya Tiwari X-Patchwork-Id: 8580991 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 0F7189F54C for ; Mon, 14 Mar 2016 15:40:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B26320260 for ; Mon, 14 Mar 2016 15:40:49 +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 33A2C20219 for ; Mon, 14 Mar 2016 15:40:48 +0000 (UTC) Received: from localhost ([::1]:41772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afUbv-0007AC-Gb for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Mar 2016 11:40:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afUbc-00079b-4O for qemu-devel@nongnu.org; Mon, 14 Mar 2016 11:40:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afUbZ-00014o-Ca for qemu-devel@nongnu.org; Mon, 14 Mar 2016 11:40:28 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afUbZ-00014T-1Y for qemu-devel@nongnu.org; Mon, 14 Mar 2016 11:40:25 -0400 Received: by mail-pf0-x243.google.com with SMTP id x3so5076937pfb.0 for ; Mon, 14 Mar 2016 08:40: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:in-reply-to:references; bh=mQOgY4aRsFXFPIC9E+Eyt62hZLB3FMk/zn7Gmou6qz4=; b=L7kSRI/e3acj1X2YxbbYmb2oku8SfZW1itz3XGjTwUu52eqdL2/9VhDGBJrgz3fRu5 apvd9Qzy1YOTCABxsRv+0SscAJhz8NR5/uenQh1ewmxki0fX4jcSBkVaLI9/mxXKtLld Yl1Ry00fYXDLZSgA6v7mNDaye2tM5CSmkXK9vMR4UD5NEW2ENp4KXh9vFFEBrHlxmEEb hzMQwD337izn7M/Xb9DvlsuPlFEtReMy3dcB6vEjpui0VgZllpg2U6j8xGPOOZOvqXfe d+vNZ/RzGv3BMmXwc3WPQekGDVtcsmewSPT+GF4E2xzPUp80L3N5cR7t6PXnV5Zz7BPn ZiDw== 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=mQOgY4aRsFXFPIC9E+Eyt62hZLB3FMk/zn7Gmou6qz4=; b=Fge9oaHhLWIla9kHXxmOT8YkBE+xsMqhq+SrflRqEyEwStAhqXGI+OV262bKxl9hdx Xh/+1n7IVNzeb4lVe4cJilY0XV0mYeySATc2WdcMpNlicq5584PcCE6595M4YcY3xqhx 8ZrrF1HPIMYlhL6iGgK2Jotb0D7SCeX0Suf1/RXlSL1OALpRpazcuVu4EuobsXj8XzN5 R0bqx0yVIfpZoJiWFBSZEWUROnSbkgzcRSZV8dcGaNQBiq1i4AYxe7lMK7Y3rXkJpVHp Y3Nixv31eMbMHU0rosnb0VaQqpktM+gvpSmQNo9K6oC2xJBmIf0KCdchKVqaGOzvg4xX yLDQ== X-Gm-Message-State: AD7BkJLLVGZM9CtPkLxbNhDCLD+rg+YmKUJcvGFfCfgf6YMr3/zHtKEorc45H2ZI5VGENw== X-Received: by 10.98.93.205 with SMTP id n74mr30854226pfj.99.1457970023957; Mon, 14 Mar 2016 08:40:23 -0700 (PDT) Received: from localhost.localdomain ([219.91.254.141]) by smtp.googlemail.com with ESMTPSA id g6sm18077088pfg.15.2016.03.14.08.40.21 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Mar 2016 08:40:23 -0700 (PDT) From: Jaya Tiwari To: qemu-devel@nongnu.org, mst@redhat.com Date: Mon, 14 Mar 2016 21:10:15 +0530 Message-Id: <1457970015-3181-1-git-send-email-tiwari.jaya18@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <56E6C89F.5030503@redhat.com> References: <56E6C89F.5030503@redhat.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 V2 1/1] virtio:Allocate temporary VirtQueueElementOld on 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 As per the list of functions in : http://wiki.qemu.org/BiteSizedTasks#Large_frames, qemu_get_virtqueue_element and qemu_put_virtqueue_element have large arrays on stack. Hence, moving them to heap This reduced their stack size from something 49248 to fit into less than 200. Signed-off-by: Jaya Tiwari --- hw/virtio/virtio.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 08275a9..027e7e2 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -636,67 +636,68 @@ typedef struct VirtQueueElementOld { void *qemu_get_virtqueue_element(QEMUFile *f, size_t sz) { VirtQueueElement *elem; - VirtQueueElementOld data; + VirtQueueElementOld *data = g_new(VirtQueueElementOld, 1); int i; - qemu_get_buffer(f, (uint8_t *)&data, sizeof(VirtQueueElementOld)); + qemu_get_buffer(f, (uint8_t *)data, sizeof(VirtQueueElementOld)); - elem = virtqueue_alloc_element(sz, data.out_num, data.in_num); - elem->index = data.index; + elem = virtqueue_alloc_element(sz, data->out_num, data->in_num); + elem->index = data->index; for (i = 0; i < elem->in_num; i++) { - elem->in_addr[i] = data.in_addr[i]; + elem->in_addr[i] = data->in_addr[i]; } for (i = 0; i < elem->out_num; i++) { - elem->out_addr[i] = data.out_addr[i]; + elem->out_addr[i] = data->out_addr[i]; } for (i = 0; i < elem->in_num; i++) { /* Base is overwritten by virtqueue_map. */ elem->in_sg[i].iov_base = 0; - elem->in_sg[i].iov_len = data.in_sg[i].iov_len; + elem->in_sg[i].iov_len = data->in_sg[i].iov_len; } for (i = 0; i < elem->out_num; i++) { /* Base is overwritten by virtqueue_map. */ elem->out_sg[i].iov_base = 0; - elem->out_sg[i].iov_len = data.out_sg[i].iov_len; + elem->out_sg[i].iov_len = data->out_sg[i].iov_len; } + g_free(data); virtqueue_map(elem); return elem; } void qemu_put_virtqueue_element(QEMUFile *f, VirtQueueElement *elem) { - VirtQueueElementOld data; + VirtQueueElementOld *data = g_new0(VirtQueueElementOld, 1); int i; - memset(&data, 0, sizeof(data)); - data.index = elem->index; - data.in_num = elem->in_num; - data.out_num = elem->out_num; + data->index = elem->index; + data->in_num = elem->in_num; + data->out_num = elem->out_num; for (i = 0; i < elem->in_num; i++) { - data.in_addr[i] = elem->in_addr[i]; + data->in_addr[i] = elem->in_addr[i]; } for (i = 0; i < elem->out_num; i++) { - data.out_addr[i] = elem->out_addr[i]; + data->out_addr[i] = elem->out_addr[i]; } for (i = 0; i < elem->in_num; i++) { /* Base is overwritten by virtqueue_map when loading. Do not * save it, as it would leak the QEMU address space layout. */ - data.in_sg[i].iov_len = elem->in_sg[i].iov_len; + data->in_sg[i].iov_len = elem->in_sg[i].iov_len; } for (i = 0; i < elem->out_num; i++) { /* Do not save iov_base as above. */ - data.out_sg[i].iov_len = elem->out_sg[i].iov_len; + data->out_sg[i].iov_len = elem->out_sg[i].iov_len; } - qemu_put_buffer(f, (uint8_t *)&data, sizeof(VirtQueueElementOld)); + qemu_put_buffer(f, (uint8_t *)data, sizeof(VirtQueueElementOld)); + g_free(data); } /* virtio device */