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:	Mon, 3 May 2010 09:15:25 +0900
From:	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To:	avi@...hat.com, xiaosuo@...il.com
Cc:	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

Avi Kivity wrote:
> On 05/02/2010 07:46 PM, Changli Gao wrote:
> > use kmalloc() to allocate fdmem if possible.
> >
> > vmalloc() is used as a fallback solution for fdmem allocation. Two members are
> > added into the hole of the structure fdtable to indicate if vmalloc() is used
> > or not.
> >
> >
> > diff --git a/fs/file.c b/fs/file.c
> > index 34bb7f7..f71dd85 100644
> > --- a/fs/file.c
> > +++ b/fs/file.c
> > @@ -39,28 +39,34 @@ int sysctl_nr_open_max = 1024 * 1024; /* raised later */
> >    */
> >   static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list);
> >
> > -static inline void * alloc_fdmem(unsigned int size)
> > +static inline void *alloc_fdmem(unsigned int size, unsigned short *use_vmalloc)
> >   {
> > -	if (size<= PAGE_SIZE)
> > -		return kmalloc(size, GFP_KERNEL);
> > -	else
> > -		return vmalloc(size);
> > +	void *data;
> > +
> > +	data = kmalloc(size, GFP_KERNEL);
> > +	if (data != NULL) {
> > +		*use_vmalloc = 0;
> > +		return data;
> > +	}
> > +	*use_vmalloc = 1;
> > +
> > +	return vmalloc(size);
> >   }
> >    
> 
> Perhaps vmalloc() should do this by itself?  vfree() can examine the 
> pointer and call kfree() if it isn't within the vmalloc address range.

You can use is_vmalloc_addr().

	if (is_vmalloc_addr(p))
		vfree(p);
	else
		kfree(p);
--
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