linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* a little improvement  for vmalloc
@ 2005-01-06  3:18 Zhonglin Zhang
  2005-01-06  3:38 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Zhonglin Zhang @ 2005-01-06  3:18 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hello,

In FUNCTION __vmalloc ,

There is a statement;

if (!size || (size >> PAGE_SHIFT) > num_physpages)
        return NULL;

I think the condition (num_phypages >>PAGE_SHIFT) > num_physpages 
is not very accurate. As we all know, linux kernel and other stuff
occupy some memory,so it is better to express like below, I think. 

if (!size || size > max_vmalloc_size)
	return NULL;

max_vmalloc_size = (num_physpages >> PAGE_SHIFT) - kernel_size          
                             -reserved_space_for_emergence_use


BTW, I would like to know whether there are reserved physical memory for
emergence use.

Thanks in advance!

Milo



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a little improvement  for vmalloc
  2005-01-06  3:18 a little improvement for vmalloc Zhonglin Zhang
@ 2005-01-06  3:38 ` Andrew Morton
  2005-01-06  9:26   ` Anton Altaparmakov
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2005-01-06  3:38 UTC (permalink / raw)
  To: Zhonglin Zhang; +Cc: linux-kernel

Zhonglin Zhang <zhonglinzh@mobilesoft.com.cn> wrote:
>
> In FUNCTION __vmalloc ,
> 
>  There is a statement;
> 
>  if (!size || (size >> PAGE_SHIFT) > num_physpages)
>          return NULL;

Probably the second part of the test should be removed.  If the requested
area size is

a) less than the size of the vmalloc arena and

b) more than the number of allocatable pages

then yes, the machine will have a ton of trouble allocating the memory and
will actually lock up.

But the only way that will happen is if some code is made to do a large
number of smaller vmallocs.  Nobody does a huge single vmalloc like that.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a little improvement  for vmalloc
  2005-01-06  3:38 ` Andrew Morton
@ 2005-01-06  9:26   ` Anton Altaparmakov
  0 siblings, 0 replies; 3+ messages in thread
From: Anton Altaparmakov @ 2005-01-06  9:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Zhonglin Zhang, lkml

On Wed, 2005-01-05 at 19:38 -0800, Andrew Morton wrote:
> Zhonglin Zhang <zhonglinzh@mobilesoft.com.cn> wrote:
> >
> > In FUNCTION __vmalloc ,
> > 
> >  There is a statement;
> > 
> >  if (!size || (size >> PAGE_SHIFT) > num_physpages)
> >          return NULL;
> 
> Probably the second part of the test should be removed.  If the requested
> area size is
> 
> a) less than the size of the vmalloc arena and
> 
> b) more than the number of allocatable pages
> 
> then yes, the machine will have a ton of trouble allocating the memory and
> will actually lock up.
> 
> But the only way that will happen is if some code is made to do a large
> number of smaller vmallocs.  Nobody does a huge single vmalloc like that.

I thought that second test was to avoid stupid bugs that may exist in
some random (perhaps ex-tree) modules that would otherwise cause the
machine to lockup...

Best regards,

        Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-06  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-06  3:18 a little improvement for vmalloc Zhonglin Zhang
2005-01-06  3:38 ` Andrew Morton
2005-01-06  9:26   ` Anton Altaparmakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).