Received: by 10.192.165.156 with SMTP id m28csp1447654imm; Wed, 18 Apr 2018 09:45:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx496vfQaVflNThE9xna35qPrjTuOUKm5QgQZpr7mJgROQkt+RIC4uPm8GQGI/51AEMY3aYQf X-Received: by 2002:a17:902:b94c:: with SMTP id h12-v6mr2801839pls.321.1524069958817; Wed, 18 Apr 2018 09:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524069958; cv=none; d=google.com; s=arc-20160816; b=lLNs2hrfQ9YqNU1mAC2YYT5eXRVONi3eDqAnCp2qCwz6jve1zrGTdMz4ba/BznyHZ2 MpsXCoKQppCEjVxkz3yuhBHBrToPPNc/iUticjvOTEPn5DXLdHGxlhB5USWucZiCvfsx xAp0F2xisfkLKwyHBr2vNFBpgEw+qWc3QLqDzlUg3BGGaWhotetSt+U/xTPFT9eoXNnN GIZ84noGfeXpR440bdI2zhsGeiBbMjX/QWRag36bIgT0v9Hbw58pRChiGUjvitEXaeI1 Ndn6eCt2bF27c/IQ2iAcxvDQUXwNjAsaTE6U7GpbS0EQmLGouo2mcOZ+xtMYflWXvVKt AwfA== 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=kNNi/cfCJIWtIlC8AFYEt3K6VGAh811VoKlJOmG1D3k=; b=LJupy2IOV1jjWBc/B9Oy8Z5urlZxEmXk7HcfxLvJW/r3dmoXi3bEsJ2X4ThGGM0vBs lV+WVhY5GM4U3whsWbRY9mFIiNvHlsVrSPatZG81DI8Zvw28kfGSjRdABJgo6C6GzhdK sOIGjmiuNEpCOY0DfySnV+goBtdNFSWHxah3k8TuNd6sV2Tso6OuieWtWLog2mtSEsxd wgwllpe5zz6aW9moJtjQNhN2w+R8WJ+BwA/D/TOWEZXwSSG0q7gPAxjobQ70MDGgjlQr MQFsTFAA476A+rYQnsvwgtPvMvi7DAGaeEy4e+Z3xZffrfXPmSDZ0Lc0LugKyUmWQ7Qi LxMQ== 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 k33-v6si1572390pld.100.2018.04.18.09.45.43; Wed, 18 Apr 2018 09:45:58 -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 S1752093AbeDRQo3 (ORCPT + 99 others); Wed, 18 Apr 2018 12:44:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750961AbeDRQo1 (ORCPT ); Wed, 18 Apr 2018 12:44:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 587274022909; Wed, 18 Apr 2018 16:44:27 +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 300642166BB2; Wed, 18 Apr 2018 16:44:27 +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 w3IGiRtx006367; Wed, 18 Apr 2018 12:44:27 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w3IGiPRi006363; Wed, 18 Apr 2018 12:44:26 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 18 Apr 2018 12:44:25 -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 , Joby Poriyath , 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: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> Message-ID: References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@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.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 18 Apr 2018 16:44:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 18 Apr 2018 16:44:27 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 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. Mikulas