Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Mar 2004 01:02:46 -0600
From:      Jon Noack <noackjr@alumni.rice.edu>
To:        Vincent Poy <vince@oahu.WURLDLINK.NET>
Cc:        current@freebsd.org
Subject:   Re: -CURRENT kernel panic
Message-ID:  <40482616.1000309@alumni.rice.edu>
In-Reply-To: <20040304120548.U8264-100000@oahu.WURLDLINK.NET>
References:  <20040304120548.U8264-100000@oahu.WURLDLINK.NET>

next in thread | previous in thread | raw e-mail | index | archive | help
On 3/4/2004 4:13 PM, Vincent Poy wrote:
> On Thu, 4 Mar 2004, Andrew Gallatin wrote:
>> Vincent Poy writes:
>>> On Thu, 4 Mar 2004, Andrew Gallatin wrote:
>>>
>>> 	Interesting.  I'm still wondering what the VM_KMEM_SIZE_SCALE 
>>> number represents.
>>
>> It tries to autoscale the kmem size, so that you don't need to hard 
>> code it.  Hardcoding it could be bad if you change the amount of ram 
>> in the box.
> 
> 	That part I understand but what exactly does the number 2 and 3 
> mean?

VM_KMEM_SIZE_SCALE:
How many physical pages per KVA page allocated.

The method I used to find this information:
$ cd /usr/src/sys; grep -r VM_KMEM_SIZE_SCALE *

src/sys/<arch>/include/vmparam.h (this is for 'i386'):
**********************************************************************
/* virtual sizes (bytes) for various kernel submaps */
#ifndef VM_KMEM_SIZE
#define VM_KMEM_SIZE            (12 * 1024 * 1024)
#endif

/*
  * How many physical pages per KVA page allocated.
  * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), 
VM_KMEM_SIZE_MAX)
  * is the total KVA space allocated for kmem_map.
  */
#ifndef VM_KMEM_SIZE_SCALE
#define VM_KMEM_SIZE_SCALE      (3)
#endif

/*
  * Ceiling on amount of kmem_map kva space.
  */
#ifndef VM_KMEM_SIZE_MAX
#define VM_KMEM_SIZE_MAX        (200 * 1024 * 1024)
#endif
**********************************************************************

src/sys/kern/kern_malloc.c:
**********************************************************************
/*
  * Try to auto-tune the kernel memory size, so that it is
  * more applicable for a wider range of machine sizes.
  * On an X86, a VM_KMEM_SIZE_SCALE value of 4 is good, while
  * a VM_KMEM_SIZE of 12MB is a fair compromise.  The
  * VM_KMEM_SIZE_MAX is dependent on the maximum KVA space
  * available, and on an X86 with a total KVA space of 256MB,
  * try to keep VM_KMEM_SIZE_MAX at 80MB or below.
  *
  * Note that the kmem_map is also used by the zone allocator,
  * so make sure that there is enough space.
  */
vm_kmem_size = VM_KMEM_SIZE;
mem_size = cnt.v_page_count;

#if defined(VM_KMEM_SIZE_SCALE)
     if ((mem_size / VM_KMEM_SIZE_SCALE) > (vm_kmem_size / PAGE_SIZE))
         vm_kmem_size = (mem_size / VM_KMEM_SIZE_SCALE) * PAGE_SIZE;
#endif

#if defined(VM_KMEM_SIZE_MAX)
     if (vm_kmem_size >= VM_KMEM_SIZE_MAX)
         vm_kmem_size = VM_KMEM_SIZE_MAX;
#endif
**********************************************************************

Jon Noack



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40482616.1000309>