Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Feb 1999 09:44:28 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Tor.Egge@fast.no
Cc:        hackers@freebsd.org
Subject:   Re: Problems in VM structure ?
Message-ID:  <199902171744.JAA06913@apollo.backplane.com>

next in thread | raw e-mail | index | archive | help
    This is what the system appears to do:

    ( kern/kern_malloc.c )


        vm_kmem_size = VM_KMEM_SIZE;
        mem_size = cnt.v_page_count * PAGE_SIZE;

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

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


    npg = (nmbufs * MSIZE + nmbclusters * MCLBYTES + vm_kmem_size) / PAGE_SIZE;

    kmemusage = (struct kmemusage *) kmem_alloc(kernel_map,
	(vm_size_t)(npg * sizeof(struct kmemusage)));

    kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase,
	(vm_offset_t *)&kmemlimit, (vm_size_t)(npg * PAGE_SIZE));

    ...

    ( i386/i386/machdep.c )

        clean_map = kmem_suballoc(kernel_map, &clean_sva, &clean_eva,
                        (nbuf*BKVASIZE) + (nswbuf*MAXPHYS) + pager_map_size);
        buffer_map = kmem_suballoc(clean_map, &buffer_sva, &buffer_eva,
                                (nbuf*BKVASIZE));
        pager_map = kmem_suballoc(clean_map, &pager_sva, &pager_eva,
                                (nswbuf*MAXPHYS) + pager_map_size);
        pager_map->system_map = 1;
        exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
                                (16*(ARG_MAX+(PAGE_SIZE*3))));

	mb_map_size = nmbufs * MSIZE + nmbclusters * MCLBYTES;
	mb_map_size = roundup2(mb_map_size, max(MCLBYTES, PAGE_SIZE));
	...
	mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, mb_map_size);

    ...

    The MAXUSERS calculation does this:

#ifndef NMBCLUSTERS
#define NMBCLUSTERS (512 + MAXUSERS * 16)
#endif
#ifndef NSFBUFS
#define NSFBUFS (512 + MAXUSERS * 16)
#endif  
#define NPROC (20 + 16 * MAXUSERS)
#define MAXFILES (NPROC*2)

    Ok, so if we have 512MB of main memory and maxusers set to 256.

    NMBCLUSTRS = 4608
    NSFBUFS    = 4608
    NPROC      = 4116
    MAXFILES   = 8232

    ( MCLBYTES   = 2048 )

	mem_size is 512MB
	vm_kmem_size = VM_KMEM_SIZE_MAX	( 80 MB )

	kmem_map  is 2.3 + 9.4 + 80  = around 90 MB.
	clean_map is 68MB + 4.1MB + 8.3MB = around 80 MB
	exec_map is 1.2MB

    So the total KVM allocated is 170MB.

    Starting at F0100000 we should have around 256MB of KVM.

    So why doesn't this work?

    I see a couple of problems right off the bat.  If there is more then 2G
    of memory, mem_size being a signed int will screw things up.

    If mem_size is > 1G, the final-override-calculation will be wrong:

	   if (vm_kmem_size > 2 * (cnt.v_page_count * PAGE_SIZE))
		   vm_kmem_size = 2 * (cnt.v_page_count * PAGE_SIZE);

    But if mem_size is 512MB, everything should work fine.  Why doesn't it?

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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