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] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 16 Nov 2008 07:49:01 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Lai Jiangshan <laijs@...fujitsu.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Paul Menage <menage@...gle.com>,
	kamezawa.hiroyu@...fujitsu.com,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	Jens Axboe <jens.axboe@...cle.com>,
	"David S. Miller" <davem@...emloft.net>, Jan Kara <jack@...e.cz>,
	Jes Sorensen <jes@....com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/7] mm: introduce simple_malloc()/simple_free()

On Sun, Nov 16, 2008 at 12:33:15PM +0800, Lai Jiangshan wrote:
> some subsystem needs vmalloc() when required memory is large.
> but current kernel has not APIs for this requirement.

It doesn't mean there should be such an API.

> this patch introduces simple_malloc() and simple_free().

Grossly misnamed. It should be kvmalloc/kvfree, at least.

> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -278,6 +279,36 @@ static inline int is_vmalloc_addr(const void *x)
>  #endif
>  }
>  
> +static inline void *__simple_malloc(unsigned long size, int pages_hint)
> +{
> +	if (size <= PAGE_SIZE * pages_hint)
> +		return kmalloc(size, GFP_KERNEL);
> +	else
> +		return vmalloc(size);
> +}
> +
> +/**
> + * simple_malloc - allocate memory by kmalloc() or vmalloc()
> + *
> + * if @size <= PAGE_SIZE, memory is allocated by kmalloc(),
> + * otherwise by vmalloc()
> + */
> +static inline void *simple_malloc(unsigned long size)
> +{
> +	return __simple_malloc(size, 1);
> +}
> +
> +/**
> + * simple_free - free the memory by kfree(), or vfree() if it is vmalloc addr
> + */
> +static inline void simple_free(void *ptr)
> +{
> +	if (is_vmalloc_addr(ptr))
> +		vfree(ptr);
> +	else
> +		kfree(ptr);
> +}
--
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