linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Joby Poriyath <joby.poriyath@citrix.com>,
	Ben Hutchings <bhutchings@solarflare.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] net: don't use kvzalloc for DMA memory
Date: Wed, 18 Apr 2018 12:44:25 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.02.1804181218270.19136@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com>



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 <mpatocka@redhat.com>
> > 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

  reply	other threads:[~2018-04-18 16:44 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18 14:34 [PATCH] net: don't use kvzalloc for DMA memory Mikulas Patocka
2018-04-18 16:05 ` Eric Dumazet
2018-04-18 16:44   ` Mikulas Patocka [this message]
2018-04-18 16:51     ` Eric Dumazet
2018-04-18 17:47       ` David Miller
2018-04-18 17:55         ` Mikulas Patocka
2018-04-18 18:00         ` Michael S. Tsirkin
2018-04-18 17:49       ` Mikulas Patocka
2018-04-18 17:46     ` David Miller
2018-04-18 17:53       ` Mikulas Patocka
2018-04-19 16:12         ` [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM Mikulas Patocka
2018-04-19 16:25           ` Eric Dumazet
2018-04-19 16:28             ` Mikulas Patocka
2018-04-19 16:43           ` Michael S. Tsirkin
2018-04-19 21:27             ` [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_SG Mikulas Patocka
2018-04-19 18:28           ` [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM Vlastimil Babka
2018-04-19 19:47           ` Andrew Morton
2018-04-19 21:19             ` Mikulas Patocka
2018-04-19 23:22               ` Andrew Morton
2018-04-20 12:16                 ` Mikulas Patocka
2018-04-20 11:47           ` Matthew Wilcox
2018-04-20 12:20             ` Mikulas Patocka
2018-04-23 15:25               ` Michael S. Tsirkin
2018-04-20 13:08           ` Michal Hocko
2018-04-20 13:41             ` Matthew Wilcox
2018-04-20 13:49               ` Michal Hocko
2018-04-20 20:56                 ` Mikulas Patocka
2018-04-20 20:54             ` Mikulas Patocka
2018-04-20 21:02               ` Matthew Wilcox
2018-04-20 21:21                 ` Mikulas Patocka
2018-04-21 14:47                   ` Matthew Wilcox
2018-04-22 13:03                     ` Michal Hocko
2018-04-23 14:24                       ` Mikulas Patocka
2018-04-23 15:10                         ` Michal Hocko
2018-04-23 23:20                           ` Mikulas Patocka
2018-04-23 14:06                     ` Mikulas Patocka
2018-04-23 15:15                       ` Michal Hocko
2018-04-24  0:06                         ` [PATCH v3] kvmalloc: always use vmalloc if CONFIG_DEBUG_SG Mikulas Patocka
2018-04-24  2:47                           ` David Rientjes
2018-04-24 11:04                             ` Mikulas Patocka
2018-04-24  3:46                           ` Matthew Wilcox
2018-04-24 12:29                             ` Mikulas Patocka
2018-04-24 17:16                               ` Matthew Wilcox
2018-04-24 18:41                                 ` Mikulas Patocka
2018-05-15  1:13                                   ` Joonsoo Kim
2018-04-24 12:51                           ` Michal Hocko
2018-04-24 15:50                             ` Mikulas Patocka
2018-04-24 16:29                               ` Michal Hocko
2018-04-24 17:00                                 ` Mikulas Patocka
2018-04-24 17:03                                   ` Michal Hocko
2018-04-24 17:28                                     ` Mikulas Patocka
2018-04-24 17:38                                       ` Michal Hocko
2018-04-25 20:02                                         ` [PATCH] fault-injection: reorder config entries Mikulas Patocka
2018-04-26  3:21                                           ` Randy Dunlap
2018-04-25 20:02                                         ` [PATCH v4] fault-injection: introduce kvmalloc fallback options Mikulas Patocka
2018-04-25 20:20                                           ` Randy Dunlap
2018-04-25 20:57                                             ` [PATCH v5] " Mikulas Patocka
2018-04-25 21:11                                               ` Randy Dunlap
2018-04-25 21:18                                               ` David Rientjes
2018-04-25 21:22                                                 ` Mikulas Patocka
2018-04-25 22:17                                                   ` [dm-devel] " James Bottomley
2018-04-25 22:42                                                     ` Mikulas Patocka
2018-04-25 22:49                                                       ` David Rientjes
2018-04-25 22:56                                                         ` Mikulas Patocka
2018-04-26 12:58                                                       ` Michal Hocko
2018-04-26 14:28                                                         ` Mikulas Patocka
2018-04-26 14:45                                                           ` James Bottomley
2018-04-26 15:05                                                             ` Mikulas Patocka
2018-04-26 15:24                                                               ` James Bottomley
2018-04-26 15:44                                                                 ` Mikulas Patocka
2018-04-26 15:59                                                                   ` Michael S. Tsirkin
2018-04-26 16:07                                                                     ` Mikulas Patocka
2018-04-26 18:49                                                                       ` Michael S. Tsirkin
2018-04-26 18:54                                                                         ` Mikulas Patocka
2018-04-26 19:14                                                                           ` Michael S. Tsirkin
2018-04-26 19:36                                                                             ` Mikulas Patocka
2018-04-26 19:45                                                                               ` Michael S. Tsirkin
2018-04-26 20:05                                                                                 ` Mikulas Patocka
2018-04-26 18:58                                                                     ` Mikulas Patocka
2018-04-26 19:05                                                                       ` Michael S. Tsirkin
2018-04-26 15:55                                                                 ` Mikulas Patocka
2018-04-25 23:00                                                     ` Mikulas Patocka
2018-04-25 23:08                                                       ` James Bottomley
2018-04-26 14:55                                                         ` Mikulas Patocka
2018-04-26 15:22                                                           ` Mikulas Patocka
2018-04-26 18:58                                                         ` John Stoffel
2018-04-26 21:50                                                           ` Mikulas Patocka
2018-04-26 22:21                                                             ` Michael S. Tsirkin
2018-04-26 22:52                                                               ` Mikulas Patocka
2018-04-27  8:25                                                                 ` Michal Hocko
2018-04-27 10:20                                                                   ` Mikulas Patocka
2018-04-27 23:20                                                               ` Mikulas Patocka
2018-04-30 18:27                                                             ` John Stoffel
2018-04-30 21:07                                                               ` Mikulas Patocka
2018-05-02 13:38                                                                 ` John Stoffel
2018-05-03 17:40                                                                   ` Mikulas Patocka
2018-04-24  0:25                         ` [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM Mikulas Patocka
2018-04-24 13:31                           ` Michal Hocko
2018-04-24 15:30                             ` Mikulas Patocka
2018-04-24 16:12                               ` Michal Hocko
2018-04-24 16:29                                 ` Michal Hocko
2018-04-24 16:33                                 ` Mikulas Patocka
2018-05-02  0:36                                   ` Andrew Morton
2018-05-02 13:33                                     ` Mike Snitzer
2018-05-02 13:40                                       ` [dm-devel] " John Stoffel
2018-05-03 17:32                                     ` [PATCH] " Mikulas Patocka
2018-04-18 17:45   ` [PATCH] net: don't use kvzalloc for DMA memory David Miller
2018-04-18 17:55   ` Michael S. Tsirkin
2018-04-18 20:38     ` Eric Dumazet
2018-04-19  4:00       ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.02.1804181218270.19136@file01.intranet.prod.int.rdu2.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=joby.poriyath@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).