kern_malloc.c (170016) | kern_malloc.c (170170) |
---|---|
1/*- 2 * Copyright (c) 1987, 1991, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2005-2006 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 29 unchanged lines hidden (view full) --- 38 * and a special UMA allocation interface is used for larger allocations. 39 * Callers declare memory types, and statistics are maintained independently 40 * for each memory type. Statistics are maintained per-CPU for performance 41 * reasons. See malloc(9) and comments in malloc.h for a detailed 42 * description. 43 */ 44 45#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1987, 1991, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2005-2006 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 29 unchanged lines hidden (view full) --- 38 * and a special UMA allocation interface is used for larger allocations. 39 * Callers declare memory types, and statistics are maintained independently 40 * for each memory type. Statistics are maintained per-CPU for performance 41 * reasons. See malloc(9) and comments in malloc.h for a detailed 42 * description. 43 */ 44 45#include <sys/cdefs.h> |
46__FBSDID("$FreeBSD: head/sys/kern/kern_malloc.c 170016 2007-05-27 13:13:46Z rwatson $"); | 46__FBSDID("$FreeBSD: head/sys/kern/kern_malloc.c 170170 2007-05-31 22:52:15Z attilio $"); |
47 48#include "opt_ddb.h" 49#include "opt_vm.h" 50 51#include <sys/param.h> 52#include <sys/systm.h> 53#include <sys/kdb.h> 54#include <sys/kernel.h> --- 487 unchanged lines hidden (view full) --- 542 * VM_KMEM_SIZE_MAX is dependent on the maximum KVA space 543 * available, and on an X86 with a total KVA space of 256MB, 544 * try to keep VM_KMEM_SIZE_MAX at 80MB or below. 545 * 546 * Note that the kmem_map is also used by the zone allocator, 547 * so make sure that there is enough space. 548 */ 549 vm_kmem_size = VM_KMEM_SIZE + nmbclusters * PAGE_SIZE; | 47 48#include "opt_ddb.h" 49#include "opt_vm.h" 50 51#include <sys/param.h> 52#include <sys/systm.h> 53#include <sys/kdb.h> 54#include <sys/kernel.h> --- 487 unchanged lines hidden (view full) --- 542 * VM_KMEM_SIZE_MAX is dependent on the maximum KVA space 543 * available, and on an X86 with a total KVA space of 256MB, 544 * try to keep VM_KMEM_SIZE_MAX at 80MB or below. 545 * 546 * Note that the kmem_map is also used by the zone allocator, 547 * so make sure that there is enough space. 548 */ 549 vm_kmem_size = VM_KMEM_SIZE + nmbclusters * PAGE_SIZE; |
550 mem_size = VMCNT_GET(page_count); | 550 mem_size = cnt.v_page_count; |
551 552#if defined(VM_KMEM_SIZE_SCALE) 553 vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; 554#endif 555 TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale); 556 if (vm_kmem_size_scale > 0 && 557 (mem_size / vm_kmem_size_scale) > (vm_kmem_size / PAGE_SIZE)) 558 vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; --- 21 unchanged lines hidden (view full) --- 580 TUNABLE_INT_FETCH("vm.kmem_size", &vm_kmem_size); 581 582 /* 583 * Limit kmem virtual size to twice the physical memory. 584 * This allows for kmem map sparseness, but limits the size 585 * to something sane. Be careful to not overflow the 32bit 586 * ints while doing the check. 587 */ | 551 552#if defined(VM_KMEM_SIZE_SCALE) 553 vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; 554#endif 555 TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale); 556 if (vm_kmem_size_scale > 0 && 557 (mem_size / vm_kmem_size_scale) > (vm_kmem_size / PAGE_SIZE)) 558 vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; --- 21 unchanged lines hidden (view full) --- 580 TUNABLE_INT_FETCH("vm.kmem_size", &vm_kmem_size); 581 582 /* 583 * Limit kmem virtual size to twice the physical memory. 584 * This allows for kmem map sparseness, but limits the size 585 * to something sane. Be careful to not overflow the 32bit 586 * ints while doing the check. 587 */ |
588 if (((vm_kmem_size / 2) / PAGE_SIZE) > VMCNT_GET(page_count)) 589 vm_kmem_size = 2 * VMCNT_GET(page_count) * PAGE_SIZE; | 588 if (((vm_kmem_size / 2) / PAGE_SIZE) > cnt.v_page_count) 589 vm_kmem_size = 2 * cnt.v_page_count * PAGE_SIZE; |
590 591 /* 592 * Tune settings based on the kernel map's size at this time. 593 */ 594 init_param3(vm_kmem_size / PAGE_SIZE); 595 596 kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase, 597 (vm_offset_t *)&kmemlimit, vm_kmem_size); --- 43 unchanged lines hidden (view full) --- 641} 642 643void 644malloc_init(void *data) 645{ 646 struct malloc_type_internal *mtip; 647 struct malloc_type *mtp; 648 | 590 591 /* 592 * Tune settings based on the kernel map's size at this time. 593 */ 594 init_param3(vm_kmem_size / PAGE_SIZE); 595 596 kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase, 597 (vm_offset_t *)&kmemlimit, vm_kmem_size); --- 43 unchanged lines hidden (view full) --- 641} 642 643void 644malloc_init(void *data) 645{ 646 struct malloc_type_internal *mtip; 647 struct malloc_type *mtp; 648 |
649 KASSERT(VMCNT_GET(page_count) != 0, 650 ("malloc_register before vm_init")); | 649 KASSERT(cnt.v_page_count != 0, ("malloc_register before vm_init")); |
651 652 mtp = data; 653 mtip = uma_zalloc(mt_zone, M_WAITOK | M_ZERO); 654 mtp->ks_handle = mtip; 655 656 mtx_lock(&malloc_mtx); 657 mtp->ks_next = kmemstatistics; 658 kmemstatistics = mtp; --- 233 unchanged lines hidden --- | 650 651 mtp = data; 652 mtip = uma_zalloc(mt_zone, M_WAITOK | M_ZERO); 653 mtp->ks_handle = mtip; 654 655 mtx_lock(&malloc_mtx); 656 mtp->ks_next = kmemstatistics; 657 kmemstatistics = mtp; --- 233 unchanged lines hidden --- |