From mboxrd@z Thu Jan 1 00:00:00 1970 From: KOSAKI Motohiro Subject: Re: [RFC] mm: generic adaptive large memory allocation APIs Date: Thu, 13 May 2010 18:05:25 +0900 (JST) Message-ID: <20100513174512.2179.A69D9226@jp.fujitsu.com> References: <20100513134124.2164.A69D9226@jp.fujitsu.com> <4BEBBBBB.3050201@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Cc: kosaki.motohiro@jp.fujitsu.com, Changli Gao , akpm@linux-foundation.org, Eric Dumazet , Alexander Viro , "Paul E. McKenney" , Alexey Dobriyan , Ingo Molnar , Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Avi Kivity , Tetsuo Handa To: Jiri Slaby Return-path: Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:42100 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754287Ab0EMJF3 (ORCPT ); Thu, 13 May 2010 05:05:29 -0400 In-Reply-To: <4BEBBBBB.3050201@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi > > Hi > > > >> void *kvmalloc(size_t size) > >> { > >> void *ptr; > >> > >> if (size < PAGE_SIZE) > >> return kmalloc(PAGE_SIZE, GFP_KERNEL); > >> ptr = alloc_pages_exact(size, GFP_KERNEL | __GFP_NOWARN); > > > > low order GFP_KERNEL allocation never fail. then, this doesn't works > > as you expected. > > Hi, I suppose you mean the kmalloc allocation -- so kmalloc should fail > iff alloc_pages_exact (unless somebody frees a heap of memory indeed)? I mean, if size of alloc_pages_exact() argument is less than 8 pages, alloc_pages_exact() never fail. see __alloc_pages_slowpath(). > > >> if (ptr != NULL) > >> return ptr; > >> > >> return vmalloc(size); > > > > On x86, vmalloc area is only 128MB address space. it is very rare > > resource than physical ram. vmalloc fallback is not good idea. > > These functions are a replacement for explicit > if (!(x = kmalloc())) > x = vmalloc(); > ... > if (is_vmalloc(x)) > vfree(x); > else > kfree(x); > in the code (like fdtable does this). > > The 128M limit on x86_32 for vmalloc is configurable so if drivers in > sum need more on some specific hardware, it can be increased on the > command line (I had to do this on one machine in the past). Right, but 99% end user don't do this. I don't think this is effective advise. > Anyway as this is a replacement for explicit tests, it shouldn't change > the behaviour in any way. Obviously when a user doesn't need virtually > contiguous space, he shouldn't use this interface at all. Why can't we make fdtable virtually contiguous free? Anyway, alloc_fdmem() also don't works as author expected.