From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: Re: [PATCH] vhost-net: fall back to vmalloc if high-order allocation fails Date: Fri, 25 Jan 2013 03:03:13 +0000 (UTC) Message-ID: References: <87k3r31vbc.fsf@silenus.orebokech.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: kvm@vger.kernel.org Return-path: Received: from plane.gmane.org ([80.91.229.3]:44245 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755890Ab3AYDDj (ORCPT ); Thu, 24 Jan 2013 22:03:39 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TyZa4-0001Il-3u for kvm@vger.kernel.org; Fri, 25 Jan 2013 04:03:52 +0100 Received: from 180.129.247.108 ([180.129.247.108]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Jan 2013 04:03:52 +0100 Received: from xiyou.wangcong by 180.129.247.108 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Jan 2013 04:03:52 +0100 Sender: kvm-owner@vger.kernel.org List-ID: ["Followup-To:" header set to gmane.linux.network.] On Wed, 23 Jan 2013 at 20:46 GMT, Romain Francoise wrote: > Creating a vhost-net device allocates an object large enough (34320 bytes > on x86-64) to trigger an order-4 allocation, which may fail if memory if > fragmented: > > libvirtd: page allocation failure: order:4, mode:0x2000d0 > ... > SLAB: Unable to allocate memory on node 0 (gfp=0xd0) > cache: size-65536, object size: 65536, order: 4 > node 0: slabs: 8/8, objs: 8/8, free: 0 > > In that situation, rather than forcing the caller to use regular > virtio-net, try to allocate the descriptor with vmalloc(). > The real problem is vhost_net struct is really big, it should be reduced rather than workarounded like this. > +static void vhost_net_kvfree(void *addr) > +{ > + if (is_vmalloc_addr(addr)) > + vfree(addr); > + else > + kfree(addr); > +} > + This kind of stuff should really go to mm, not netdev.