Received: by 10.192.165.156 with SMTP id m28csp1519932imm; Wed, 18 Apr 2018 10:57:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+3wvK8P0uvEiMohWoxFKVibZDhjOIjRdS0mNEK4u7wVohxYzgONKXZzibZVWhCOonGTvWt X-Received: by 2002:a17:902:2826:: with SMTP id e35-v6mr2960616plb.348.1524074247184; Wed, 18 Apr 2018 10:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524074247; cv=none; d=google.com; s=arc-20160816; b=xWe1eIj7/XQTvej3eYl36eP+1FsYEspaVjbZTo6vCsyQQxvfGr+OUq1oaVVWhlStwF mVDxwEl1HiwAg9Fz+WFuPYur6xdZxzqdeNDrH0p+YQVcCd0csiRxWBwQJaazZ0GZ8BrL QHir61yqWATe6lTYsleVL6E1RY3TMw311xQhsQUn/fjhThsNViKz5I996n2yVWQ90EVj U5KEO+UihBUliiUeWCRKXSz01J2JqbnXFWLjXN3I7apuaUiOiESmrTuODFC7TZp/vI+j sjs2ddYTbk5cb5s5tmtShWTpyDoeaYisw4I3+yeLcP5Q0qrCJi4RhwC49HknDWQHUYaM bsvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=dWcR9C/EtV7oEeK3lfmvU0ttsVcoV/taPDvfADmzLAg=; b=lbGqEgwzjl8Me+GQff554xqP4femwEC1p2MHk4Auzvc3t2WbIMbyE9ZOXREvPbniGK n4SXlmKMt9cE6A9X3wIIFPAIiBbSWfLurp/mYpOLyF4SiXt4P5W6mTTZTKB8g5+daUYS kgHPP6RoiwuDAji3TYR3bZvCSDz9YqNCze2gQxXpDDORzZ81N7a3xaDjZPlbYzLX7MVY QnUI+Vd8HSyddYsq2S0s5QErMkXkI+QN6mNQI3Tc2JZ4djc5+lQo9nEQom3n+pxD1IQG 2AY9gBnPHGSTlOFeZp1zQc/Bsm4QrcuSNqtKQEzSJfRPymqmBbe3QheM13SnR8Z1vIsy CgGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si1562689pfi.355.2018.04.18.10.57.13; Wed, 18 Apr 2018 10:57:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178AbeDRRzP (ORCPT + 99 others); Wed, 18 Apr 2018 13:55:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53002 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751407AbeDRRzO (ORCPT ); Wed, 18 Apr 2018 13:55:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2CCC8163AD4; Wed, 18 Apr 2018 17:55:13 +0000 (UTC) Received: from redhat.com (ovpn-124-112.rdu2.redhat.com [10.10.124.112]) by smtp.corp.redhat.com (Postfix) with SMTP id 5D8D41C720; Wed, 18 Apr 2018 17:55:13 +0000 (UTC) Date: Wed, 18 Apr 2018 20:55:13 +0300 From: "Michael S. Tsirkin" To: Eric Dumazet Cc: Mikulas Patocka , "David S. Miller" , Eric Dumazet , Joby Poriyath , Ben Hutchings , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: don't use kvzalloc for DMA memory Message-ID: <20180418204229-mutt-send-email-mst@kernel.org> References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 18 Apr 2018 17:55:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 18 Apr 2018 17:55:13 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 09:05:54AM -0700, Eric Dumazet wrote: > > > On 04/18/2018 07:34 AM, Mikulas Patocka wrote: > > The patch 74d332c13b21 changes alloc_netdev_mqs to use vzalloc if kzalloc > > fails (later patches change it to kvzalloc). > > > > The problem with this is that if the vzalloc function is actually used, > > virtio_net doesn't work (because it expects that the extra memory should > > be accessible with DMA-API and memory allocated with vzalloc isn't). > > > > This patch changes it back to kzalloc and adds a warning if the allocated > > size is too large (the allocation is unreliable in this case). > > > > Signed-off-by: Mikulas Patocka > > Fixes: 74d332c13b21 ("net: extend net_device allocation to vmalloc()") > > > > --- > > net/core/dev.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > Index: linux-2.6/net/core/dev.c > > =================================================================== > > --- linux-2.6.orig/net/core/dev.c 2018-04-16 21:08:36.000000000 +0200 > > +++ linux-2.6/net/core/dev.c 2018-04-18 16:24:43.000000000 +0200 > > @@ -8366,7 +8366,8 @@ struct net_device *alloc_netdev_mqs(int > > /* ensure 32-byte alignment of whole construct */ > > alloc_size += NETDEV_ALIGN - 1; > > > > - p = kvzalloc(alloc_size, GFP_KERNEL | __GFP_RETRY_MAYFAIL); > > + WARN_ON(alloc_size > PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER); > > + p = kzalloc(alloc_size, GFP_KERNEL | __GFP_RETRY_MAYFAIL); > > if (!p) > > return NULL; > > > > > > Since when a net_device needs to be in DMA zone ??? It's likely that we are not the only device like this. It would be better to find a way to find devices like this. Imagine you want to pass some data to card. Natural thing is to just put it in a variable and start DMA. However DMA API disallows stack access nowdays, so it's natural to put this within struct device. See e.g. commit a725ee3e44e39dab1ec82cc745899a785d2a555e Author: Andy Lutomirski Date: Mon Jul 18 15:34:49 2016 -0700 virtio-net: Remove more stack DMA > I would rather fix virtio_net, this looks very suspect to me. It's been done for years. I'm fine with changing virtio-net and allocating DMA memory separately but I am not sure it's appropriate on net. And OTOH, shouldn't drivers avoid allocating such huge device structs? Abusing vmalloc won't work well on 32 bit platforms. > Each virtio_net should probably allocate the exact amount of DMA-memory it wants, > instead of expecting core networking stack to have a huge chunk of DMA-memory for everything. It's not a DMA memory at all (not a synchronous memory) and it is not huge. It's a small chunk of regular memory that is mapped for DMA for a short while, then unmapped. -- MST