From patchwork Wed Aug 2 04:33:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 796466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xMgKn6XGNz9sRm for ; Wed, 2 Aug 2017 14:33:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="cqzQ1Tyu"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xMgKn5GrwzDrKs for ; Wed, 2 Aug 2017 14:33:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="cqzQ1Tyu"; dkim-atps=neutral X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xMgKg1YZRzDrGy for ; Wed, 2 Aug 2017 14:33:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="cqzQ1Tyu"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id y129so5167542pgy.3 for ; Tue, 01 Aug 2017 21:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=988F9+6YzGTIRQpOWKj7X+a4c51PwveGD82b53BZdvU=; b=cqzQ1TyuW0ohbNcYndgNM5L9HvKnF6XUTqAwWkXREsMLWAMVaV4bVSDteYtoXy6unV CgyjZiMk3XZXbzydR8v8+K/7srBqIDGzKYN+UPDXdPBmEQTllti0Gx2oSnbNLM2yYt5a MJnbCDr1MtN9Jsma/uG5u+CvFSvx9L/6kcUnhxe67wp601PyBpubktuWeGek0A17q5UN 2MbBeXv6/J6/ct5acjm6GV6vH/8iXLNAUImvDl5NNWvFICLuR1qyCHfOaT0Z2hZg8Jy9 UpWul09ULJdqTBJF/7BIHlkRIvf+bg4xXUQ9tXD7KcU9buiY6/DxUIzrRoRGBEUwOkLk Mr+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=988F9+6YzGTIRQpOWKj7X+a4c51PwveGD82b53BZdvU=; b=rqLb7+sU9TEdE8Nd9rPrKDGHXshlmD2WfxnnWqHtxGlTU35Ux4Bb4pKdbVJUz88K3N jacLjTxLUCB0EYeuEYAuZN3eYPQulDUyidGAG27O/xC5lqnqjFqhFcNu+nYMs841IRPL TQAXwA6TBlOw1JYULf7siXEVMMcj1jJM5QQg7KX7o9BBqU7DXGyialc19Qd5/iof1NMQ 3nJYLDRz2A8eTkTpcJwX1ppdvTsoKgoMHXGnjJz+gyHlbV8djy5ClWKXoIRnwjCoyai6 qMSTlVbsW5BpPcrcLp2Qjka+soEFRBvP0tHue21FXACQTFVgMUhyqV6sLjwnoac3WSwD Ai4A== X-Gm-Message-State: AIVw111WRBt0aF+dMP8/3gL2O6e1fk+kgW7pzOmU1jACF6pmdhgbWCps 1ewOIVzkWkwTEIiMgHE= X-Received: by 10.99.97.194 with SMTP id v185mr21086297pgb.165.1501648388807; Tue, 01 Aug 2017 21:33:08 -0700 (PDT) Received: from [10.61.2.175] ([122.99.82.10]) by smtp.googlemail.com with ESMTPSA id b185sm37722766pfa.65.2017.08.01.21.33.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 21:33:07 -0700 (PDT) To: Thomas Huth , Nikunj A Dadhania , slof@lists.ozlabs.org References: <20170801063942.29591-1-nikunj@linux.vnet.ibm.com> From: Alexey Kardashevskiy Message-ID: Date: Wed, 2 Aug 2017 14:33:03 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-AU Subject: Re: [SLOF] [PATCH] virtio-net: use common receive buffer for devices X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" On 02/08/17 04:14, Thomas Huth wrote: > On 01.08.2017 08:39, Nikunj A Dadhania wrote: >> Found that virtio-net is using a around 200K receive buffer per device, if we >> connect more than 40 virtio-net devices the heap(8MB) gets over. Because of >> which allocation starts failing and the VM does not boot. >> >> Use common receive buffer for all the virtio-net devices. This will reduce the >> memory requirement per virtio-net device in slof. > > Not sure whether this is a really good idea... I think theoretically an > OF client could open multiple network devices and use them in parallel - > and then the devices would destroy their shared receive buffers mutually. > Maybe you could change the code so that the buffers are only allocated > when the device is opened, and released again when the device is closed > again? Agree, something like this would make sense imho: diff --git a/include/netdriver.h b/include/netdriver.h index d81134e..5fd1d6e 100644 --- a/include/netdriver.h +++ b/include/netdriver.h @@ -19,6 +19,7 @@ typedef struct net_driver { uint8_t mac_addr[6]; uint32_t reg; int running; + void *dev; } net_driver_t; #endif diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c index 2573031..bfbf718 100644 --- a/lib/libvirtio/virtio-net.c +++ b/lib/libvirtio/virtio-net.c @@ -197,6 +197,8 @@ dev_error: */ static int virtionet_term(net_driver_t *driver) { + struct virtio_device *dev = driver->dev; + dprintf("virtionet_term()\n"); if (driver->running == 0) @@ -210,6 +212,8 @@ static int virtionet_term(net_driver_t *driver) driver->running = 0; + /* free the buffers, etc */ + return 0; } @@ -334,6 +338,8 @@ net_driver_t *virtionet_open(struct virtio_device *dev) if (virtionet_init(driver)) goto FAIL; + driver->dev = dev; + return driver; FAIL: SLOF_free_mem(driver, sizeof(*driver));