lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1272951180.2407.188.camel@edumazet-laptop>
Date:	Tue, 04 May 2010 07:33:00 +0200
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Changli Gao <xiaosuo@...il.com>
Cc:	Avi Kivity <avi@...hat.com>,
	Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
	jslaby@...e.cz, akpm@...ux-foundation.org,
	paulmck@...ux.vnet.ibm.com, adobriyan@...il.com, mingo@...e.hu,
	peterz@...radead.org, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: use kmalloc() to allocate fdmem if possible

Le mardi 04 mai 2010 à 12:20 +0800, Changli Gao a écrit :

> we can use alloc_pages_exact()/free_pages_exact() when size is larger
> than PAGE_SIZE, then size isn't needed to be a power of two.
> 
> void *kvmalloc(size_t size)
> {
>       void *ptr;
> 
>       if (size < PAGE_SIZE)
>           return kmalloc(size, GFP_KERNEL);
>       ptr = alloc_pages_exact(size, GFP_KERNEL | __GFP_NOWARN);
>       if (ptr)
>           return ptr;
>       return vmalloc(size);
> }
> 
> void *kvfree(void *ptr, size_t size)
> {
>        BUG_ON(in_interrupt());
>        if (size < PAGE_SIZE)
>             kfree(ptr);
>        else if (is_vmalloc_addr(ptr))
>             vfree(ptr);
>        else
>             free_pages_exact(ptr, size);
> }

Yes, this has the drawback to need 'size' in kvfree(), but it should not
be a problem for users of this code.

alloc_pages_exact() also fragments high order page, but I guess it's not
worse than kmalloc() in this context.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ