Deleted Added
full compact
kern_malloc.c (193490) kern_malloc.c (209390)
1/*-
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California.
4 * Copyright (c) 2005-2009 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-2009 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 193490 2009-06-05 09:16:52Z brian $");
46__FBSDID("$FreeBSD: head/sys/kern/kern_malloc.c 209390 2010-06-21 09:55:56Z ed $");
47
48#include "opt_ddb.h"
49#include "opt_kdtrace.h"
50#include "opt_vm.h"
51
52#include <sys/param.h>
53#include <sys/systm.h>
54#include <sys/kdb.h>

--- 69 unchanged lines hidden (view full) ---

124static int kmemcount;
125
126#define KMEM_ZSHIFT 4
127#define KMEM_ZBASE 16
128#define KMEM_ZMASK (KMEM_ZBASE - 1)
129
130#define KMEM_ZMAX PAGE_SIZE
131#define KMEM_ZSIZE (KMEM_ZMAX >> KMEM_ZSHIFT)
47
48#include "opt_ddb.h"
49#include "opt_kdtrace.h"
50#include "opt_vm.h"
51
52#include <sys/param.h>
53#include <sys/systm.h>
54#include <sys/kdb.h>

--- 69 unchanged lines hidden (view full) ---

124static int kmemcount;
125
126#define KMEM_ZSHIFT 4
127#define KMEM_ZBASE 16
128#define KMEM_ZMASK (KMEM_ZBASE - 1)
129
130#define KMEM_ZMAX PAGE_SIZE
131#define KMEM_ZSIZE (KMEM_ZMAX >> KMEM_ZSHIFT)
132static u_int8_t kmemsize[KMEM_ZSIZE + 1];
132static uint8_t kmemsize[KMEM_ZSIZE + 1];
133
134/*
135 * Small malloc(9) memory allocations are allocated from a set of UMA buckets
136 * of various sizes.
137 *
138 * XXX: The comment here used to read "These won't be powers of two for
139 * long." It's possible that a significant amount of wasted memory could be
140 * recovered by tuning the sizes of these buckets.

--- 412 unchanged lines hidden (view full) ---

553
554/*
555 * Initialize the kernel memory allocator
556 */
557/* ARGSUSED*/
558static void
559kmeminit(void *dummy)
560{
133
134/*
135 * Small malloc(9) memory allocations are allocated from a set of UMA buckets
136 * of various sizes.
137 *
138 * XXX: The comment here used to read "These won't be powers of two for
139 * long." It's possible that a significant amount of wasted memory could be
140 * recovered by tuning the sizes of these buckets.

--- 412 unchanged lines hidden (view full) ---

553
554/*
555 * Initialize the kernel memory allocator
556 */
557/* ARGSUSED*/
558static void
559kmeminit(void *dummy)
560{
561 u_int8_t indx;
561 uint8_t indx;
562 u_long mem_size;
563 int i;
564
565 mtx_init(&malloc_mtx, "malloc", NULL, MTX_DEF);
566
567 /*
568 * Try to auto-tune the kernel memory size, so that it is
569 * more applicable for a wider range of machine sizes.

--- 304 unchanged lines hidden (view full) ---

874 free(bufmtp, M_TEMP);
875}
876
877#ifdef DDB
878DB_SHOW_COMMAND(malloc, db_show_malloc)
879{
880 struct malloc_type_internal *mtip;
881 struct malloc_type *mtp;
562 u_long mem_size;
563 int i;
564
565 mtx_init(&malloc_mtx, "malloc", NULL, MTX_DEF);
566
567 /*
568 * Try to auto-tune the kernel memory size, so that it is
569 * more applicable for a wider range of machine sizes.

--- 304 unchanged lines hidden (view full) ---

874 free(bufmtp, M_TEMP);
875}
876
877#ifdef DDB
878DB_SHOW_COMMAND(malloc, db_show_malloc)
879{
880 struct malloc_type_internal *mtip;
881 struct malloc_type *mtp;
882 u_int64_t allocs, frees;
883 u_int64_t alloced, freed;
882 uint64_t allocs, frees;
883 uint64_t alloced, freed;
884 int i;
885
886 db_printf("%18s %12s %12s %12s\n", "Type", "InUse", "MemUse",
887 "Requests");
888 for (mtp = kmemstatistics; mtp != NULL; mtp = mtp->ks_next) {
889 mtip = (struct malloc_type_internal *)mtp->ks_handle;
890 allocs = 0;
891 frees = 0;

--- 69 unchanged lines hidden ---
884 int i;
885
886 db_printf("%18s %12s %12s %12s\n", "Type", "InUse", "MemUse",
887 "Requests");
888 for (mtp = kmemstatistics; mtp != NULL; mtp = mtp->ks_next) {
889 mtip = (struct malloc_type_internal *)mtp->ks_handle;
890 allocs = 0;
891 frees = 0;

--- 69 unchanged lines hidden ---