Received: by 10.192.165.156 with SMTP id m28csp1514396imm; Wed, 18 Apr 2018 10:51:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx49tiNCHA6FcEC3OvxrH8Mrc1peD42/k6pZSVxYRcqw/bZ4BIccb+2nkenLZJoNrTspw6SgA X-Received: by 2002:a17:902:6689:: with SMTP id e9-v6mr3008850plk.176.1524073889222; Wed, 18 Apr 2018 10:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524073889; cv=none; d=google.com; s=arc-20160816; b=BcoJwHKBH3i2JPpCQ3/bgwiCLkul65NcQjyJ/FTy17l9G9iR1LSJgOFti4XOdyAeX9 6vFzM66L0zPsvVZxqQmT8xVMLKVGcn2nL0Gh94C5vl/PNZUMJn1J0dZVf4GK6UFeIORg X6Kg2NKNugHfZgdt5+qvjBc/+AR2Ez2ZkW4OX7teXVfF2oe8wYKJQLrmb53SV7+HBUwJ Jn4SWqnFpRt1fqvSZJ1ZGHbjNsiWNU4QdwXgUZUrjL7ztVCvpie5My1hkDqQ8vaUKDCG U/EiZrNMkkdvIvo2DSx238tkfLQ4WSoUgHTbpCKOi5VRRaA4GZQz2eO22QtPuSZgOXg/ I9Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=gYKKckqzJNaSB604g8glByn6aMk++IBKjLb6+tBdsk0=; b=mkxurE/ana7lLU/M3i20K04qvGmUFgow80bLo8nj+PjEPubYijKQOfEp88l2j9y9dm AHlTC7hh23iTHEJ3gZUGDnOfscvOcArz+7BASOfwY9UXdoaNDX4GjNZBdHA0XQW+G6RT Xk6gdE5+N5RCgtDycicHHH8u1CtIiTSG7XAbccNUnY2eVDu/9LPCev9jWwFV6Ulj/bDo pLAshyib0jAc1XsFbJDUD491AM5SzZfMTdXVA0QUG45bK3QFPEPLbddTQmfYT6jqKVtc l94CexLKY3BP8Td9CpnPBODPaFx6hZApz6H91R1ptb8/4ycPLMKT+YgmkAiMF0VxeYD7 be3Q== 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 az8-v6si1794425plb.153.2018.04.18.10.51.10; Wed, 18 Apr 2018 10:51:29 -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 S1753060AbeDRRt6 (ORCPT + 99 others); Wed, 18 Apr 2018 13:49:58 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751692AbeDRRt4 (ORCPT ); Wed, 18 Apr 2018 13:49:56 -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 6011EEB6E5; Wed, 18 Apr 2018 17:49:56 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57D051C720; Wed, 18 Apr 2018 17:49:54 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w3IHnsnt018651; Wed, 18 Apr 2018 13:49:54 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w3IHnsDG018647; Wed, 18 Apr 2018 13:49:54 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 18 Apr 2018 13:49:54 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Eric Dumazet cc: "David S. Miller" , Eric Dumazet , Ben Hutchings , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , virtualization@lists.linux-foundation.org Subject: Re: [PATCH] net: don't use kvzalloc for DMA memory In-Reply-To: <5f4e1286-b79f-0b9f-9a30-47d7654f3889@gmail.com> Message-ID: References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> <5f4e1286-b79f-0b9f-9a30-47d7654f3889@gmail.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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.1]); Wed, 18 Apr 2018 17:49:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 18 Apr 2018 17:49:56 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Apr 2018, Eric Dumazet wrote: > > > On 04/18/2018 09:44 AM, Mikulas Patocka wrote: > > > > > > On Wed, 18 Apr 2018, 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 ??? > >> > >> I would rather fix virtio_net, this looks very suspect to me. > >> > >> 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. > > > > The structure net_device is followed by arbitrary driver-specific data > > (accessible with the function netdev_priv). And for virtio-net, these > > driver-specific data must be in DMA memory. > > I get that, but how is the original xenvif problem will be solved ? > > Your patch would add a bug in some other driver(s) > > I suggest that virtio_net clearly identifies which part needs a specific allocation > and does its itself, instead of abusing the netdev_priv storage. > > Ie use a pointer to a block of memory, allocated by virtio_net, for virtio_net. There are drivers that need to do DMA to driver-specific area. And there are drivers that need driver-specific area larger than kmalloc limit. These are conflicting requirements and one of those drivers must be changed. I suggest to change the drivers that need large driver-specific area. That's why I added the WARN_ON, so that they can be identified. Mikulas