summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* KSE Milestone 2julian2001-09-121-1/+1
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* - Remove asleep(), await(), and M_ASLEEP.jhb2001-08-101-9/+0
| | | | | | | | | - Callers of asleep() and await() have been converted to calling tsleep(). The only caller outside of M_ASLEEP was the ata driver, which called both asleep() and await() with spl-raised, so there was no need for the asleep() and await() pair. M_ASLEEP was unused. Reviewed by: jasone, peter
* Rename mb_init() mbuf subsystem initialization routine to mbuf_init(), inbmilekic2001-08-031-1/+1
| | | | | | | | order to avoid namespace collision with subr_mchain.c's mb_init(). This wasn't "fatal" as the mbuf initialization routine mb_init() was local to subr_mbuf.c which in turn didn't pull in subr_mchain.c's mb_init() declaration, but it should deffinately be changed now before it creates headache.
* Remove some code that appears to have endian problems with INVARIANTS.jake2001-08-031-5/+0
| | | | | This is #if BIG_ENDIAN, but is only necessary if malloc types are shorts, not struct malloc_type * like they are now.
* Introduce numerous SMP friendly changes to the mbuf allocator. Namely,bmilekic2001-06-221-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | introduce a modified allocation mechanism for mbufs and mbuf clusters; one which can scale under SMP and which offers the possibility of resource reclamation to be implemented in the future. Notable advantages: o Reduce contention for SMP by offering per-CPU pools and locks. o Better use of data cache due to per-CPU pools. o Much less code cache pollution due to excessively large allocation macros. o Framework for `grouping' objects from same page together so as to be able to possibly free wired-down pages back to the system if they are no longer needed by the network stacks. Additional things changed with this addition: - Moved some mbuf specific declarations and initializations from sys/conf/param.c into mbuf-specific code where they belong. - m_getclr() has been renamed to m_get_clrd() because the old name is really confusing. m_getclr() HAS been preserved though and is defined to the new name. No tree sweep has been done "to change the interface," as the old name will continue to be supported and is not depracated. The change was merely done because m_getclr() sounds too much like "m_get a cluster." - TEMPORARILY disabled mbtypes statistics displaying in netstat(1) and systat(1) (see TODO below). - Fixed systat(1) to display number of "free mbufs" based on new per-CPU stat structures. - Fixed netstat(1) to display new per-CPU stats based on sysctl-exported per-CPU stat structures. All infos are fetched via sysctl. TODO (in order of priority): - Re-enable mbtypes statistics in both netstat(1) and systat(1) after introducing an SMP friendly way to collect the mbtypes stats under the already introduced per-CPU locks (i.e. hopefully don't use atomic() - it seems too costly for a mere stat update, especially when other locks are already present). - Optionally have systat(1) display not only "total free mbufs" but also "total free mbufs per CPU pool." - Fix minor length-fetching issues in netstat(1) related to recently re-enabled option to read mbuf stats from a core file. - Move reference counters at least for mbuf clusters into an unused portion of the cluster itself, to save space and need to allocate a counter. - Look into introducing resource freeing possibly from a kproc. Reviewed by (in parts): jlemon, jake, silby, terry Tested by: jlemon (Intel & Alpha), mjacob (Intel & Alpha) Preliminary performance measurements: jlemon (and me, obviously) URL: http://people.freebsd.org/~bmilekic/mb_alloc/
* "Fix" the previous initial attempt at fixing TUNABLE_INT(). This timepeter2001-06-081-1/+1
| | | | | | | around, use a common function for looking up and extracting the tunables from the kernel environment. This saves duplicating the same function over and over again. This way typically has an overhead of 8 bytes + the path string, versus about 26 bytes + the path string.
* Back out part of my previous commit. This was a last minute changepeter2001-06-071-1/+1
| | | | | and I botched testing. This is a perfect example of how NOT to do this sort of thing. :-(
* Make the TUNABLE_*() macros look and behave more consistantly like thepeter2001-06-061-7/+6
| | | | | SYSCTL_*() macros. TUNABLE_INT_DECL() was an odd name because it didn't actually declare the int, which is what the name suggests it would do.
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-1/+1
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Fix inconsistency in setup of kernel_map: we need to make sure thatbmilekic2001-04-181-2/+2
| | | | | | | | we also reserve _adequate_ space for the mb_map submap; i.e. we need space for nmbclusters, nmbufs, _and_ nmbcnt. Furthermore, we need to rounddown, and not roundup, so that we are consistent. Pointed out by: bde
* Change and clean the mutex lock interface.bmilekic2001-02-091-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Let M_PANIC go back to the private tree as its intention isn't understood wellbp2001-01-311-6/+2
| | | | for now.
* Add M_PANIC flag to the list of available flags passed to malloc().bp2001-01-291-2/+6
| | | | | | | With this flag set malloc() will panic if memory allocation failed. This usable only in critical places where failed allocation is fatal. Reviewed by: peter
* p->p_intr_nesting_level is MI now and initialized to 0 in kern_fork.c,peter2001-01-271-1/+1
| | | | | so it should be save to KASSERT() on it even on an arch that may not use it.
* Don't grab Giant when calling kmem_alloc/kmem_free as this is justjhb2001-01-241-4/+0
| | | | | encouraging other people to follow the same practice. If this is going to be done, then it should be done inside of those two functions instead.
* Make intr_nesting_level per-process, rather than per-cpu. Setupjake2001-01-211-1/+2
| | | | | | | | interrupt threads to run with it always >= 1, so that malloc can detect M_WAITOK from "interrupt" context. This is also necessary in order to context switch from sched_ithd() directly. Reviewed By: peter
* Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutexjasone2001-01-211-2/+2
| | | | | | | | initialization until after malloc() is safe to call, then iterate through all mutexes and complete their initialization. This change is necessary in order to avoid some circular bootstrapping dependencies.
* Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variablesjake2001-01-101-1/+1
| | | | other then curproc.
* Introduce the M_ZERO flag to malloc(9)phk2000-10-201-0/+3
| | | | | | | | | | | | | | Instead of: foo = malloc(sizeof(foo), M_WAIT); bzero(foo, sizeof(foo)); You can now (and please do) use: foo = malloc(sizeof(foo), M_WAIT | M_ZERO); In the future this will enable us to do idle-time pre-zeroing of malloc-space.
* - machine/mutex.h -> sys/mutex.hjhb2000-10-201-4/+3
| | | | - Use MUTEX_DECLARE() and MTX_COLD for the malloc_mtx mutex
* Don't #include <sys/proc.h>, since machine/mutex.h does it now.jasone2000-09-231-1/+1
|
* Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, justjhb2000-09-141-1/+1
| | | | | | use struct mtx, struct witness, and struct witness_blessed. Requested by: bde
* Add malloc_mtx to protect malloc and friends, so that they're thread-safe.jasone2000-09-111-1/+30
| | | | Reviewed by: peter
* Back out the addition of malloc_mtx. It was incompletely conceived, andjasone2000-09-101-13/+0
| | | | will be done correctly in the future.
* Add a mutex to the malloc interfaces so that it can safely be calledjasone2000-09-091-0/+15
| | | | without owning the Giant lock.
* Move #ifdef to the right place.bp2000-06-291-1/+1
|
* If kernel compiled with INVARIANTS:bp2000-06-291-0/+24
| | | | | | | | On unload, remove references from freelist to memory type defined by module. Print a warning if module defines and allocate its own memory type, but didn't free it all on unload. Reviewed by: peter
* sys/malloc.h:bde2000-06-141-14/+1
| | | | | | | | | | | | Order the SYSINIT() for MALLOC_DEFINE() correctly so that malloc() doesn't have to waste time initializing itself. The (SI_SUB_KMEM, SI_ORDER_ANY) order was shared with syscons' SYSINIT() for scmeminit(), and scmeminit() calls malloc(), so malloc() initialization was not always complete on the first call to malloc(). kern/kern_malloc.c: - Removed self-initialization in malloc(). - Removed half-baked sanity check in free(). Trust MALLOC_DEFINE().
* Print "previous type" correctly when INVARIANTS is defined.kuriyama2000-03-141-1/+1
| | | | Reviewed by: current@FreeBSD.org
* Fix null-pointer dereference crash when the system is intentionallydillon2000-02-161-1/+2
| | | | | | | | | | | | | | | | run out of KVM through a mmap()/fork() bomb that allocates hundreds of thousands of vm_map_entry structures. Add panic to make null-pointer dereference crash a little more verbose. Add a new sysctl, vm.max_proc_mmap, which specifies the maximum number of mmap()'d spaces (discrete vm_map_entry's in the process). The value defaults to around 9000 for a 128MB machine. The test is scaled for the number of processes sharing a vmspace (aka linux threads). Setting the value to 0 disables the feature. PR: kern/16573 Approved by: jkh
* Fixed sign and overflow bugs that caused the allocation size of the kerneldg2000-01-281-6/+12
| | | | | | | | | | | | malloc region (kmem_map) to be wrong and semi-random on systems with more than 1GB of RAM. This is not a complete fix, but is sufficient for machines with 4GB or less of memory. A complete fix will require some changes to the getenv stuff so that 64bit values can be passed around. NOT FIXED: machines with more than 4GB of RAM (e.g. some large Alphas) since we're still using ints to hold some of the values. Reviewed by: bde
* KAME netinet6 basic part(no IPsec,no V6 Multicast Forwarding, no UDP/TCPshin1999-11-221-2/+5
| | | | | | | | | | for IPv6 yet) With this patch, you can assigne IPv6 addr automatically, and can reply to IPv6 ping. Reviewed by: freebsd-arch, cvs-committers Obtained from: KAME project
* Before we start to mess with the VFS name-cache clean things up a little bit:phk1999-10-031-1/+1
| | | | Isolate the namecache in its own file, and give it a dedicated malloc type.
* KASSERT that we cannot use M_WAITOK in interrupt context.phk1999-09-191-0/+9
| | | | Reviewed by: bde
* Get rid of MALLOC_INSTANTIATE and MALLOC_MAKE_TYPE(). Just handle the 3bde1999-09-111-1/+4
| | | | malloc types declared in <sys/malloc.h> like other global malloc types.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Move the initialisation/tuning of nmbclusters from param.c/machdep.cmsmith1999-07-051-8/+7
| | | | | | | | | | | | | | | into uipc_mbuf.c. This reduces three sets of identical tunable code to one set, and puts the initialisation with the mbuf code proper. Make NMBUFs tunable as well. Move the nmbclusters sysctl here as well. Move the initialisation of maxsockets from param.c to uipc_socket2.c, next to its corresponding sysctl. Use the new tunable macros for the kern.vm.kmem.size tunable (this should have been in a separate commit, whoops).
* Fixed corruption of the kmemstatistcs list. The first malloc()bde1999-05-121-5/+9
| | | | | | | | | | | | with malloc type at the tail of the list changed the list from linear to circular. This seemed to cause surprisingly few problems, but it now causes weird output from `vmstat -m', probably because a more important malloc type is now at the tail of the list. Fix it by abusing ks_limit instead of ks_next as a flag for being on the list. Don't forget to clear the flag when a malloc type is uninit'ed. Uninit'ing is still fundamentally broken -- it loses history.
* Add sufficient braces to keep egcs happy about potentially ambiguouspeter1999-05-061-2/+3
| | | | if/else nesting.
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-271-3/+3
| | | | kernel compile
* Allow VM_KMEM_SIZE to be tuned from the kernel environment. This tuningmsmith1999-01-211-1/+6
| | | | value *completely* overrides any value precalculated by the kernel.
* This is a rather large commit that encompasses the new swapper,dillon1999-01-211-5/+31
| | | | | | | | | | changes to the VM system to support the new swapper, VM bug fixes, several VM optimizations, and some additional revamping of the VM code. The specific bug fixes will be documented with additional forced commits. This commit is somewhat rough in regards to code cleanup issues. Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>
* KNFize, by bde.eivind1999-01-101-6/+5
|
* Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT aseivind1999-01-081-24/+19
| | | | | | | | | discussed on -hackers. Introduce 'KASSERT(assertion, ("panic message", args))' for simple check + panic. Reviewed by: msmith
* Have MALLOC_DECLARE() initialize malloc types explicitly, and have thempeter1998-11-101-6/+34
| | | | | | | | removed at module unload (if in a module of course). However; this introduces a new dependency on <sys/kernel.h> for things that use MALLOC_DECLARE(). Bruce told me it is better to add sys/kernel.h to the handful of files that need it rather than add an extra include to sys/malloc.h for kernel compiles. Updates to follow in subsequent commits.
* Nitpicking and dusting performed on a train. Removes trivial warningsphk1998-10-251-3/+1
| | | | about unused variables, labels and other lint.
* Use [u]intptr_t instead of [u_]long for casts between pointers andbde1998-08-161-3/+3
| | | | integers. Don't forget to cast to (void *) as well.
* Fixed printf format errors.bde1998-07-291-7/+8
|
* Reviewed by: dyson@freebsd.org (john Dyson), dg@root.com (david greenman)julian1998-03-081-3/+3
| | | | | Submitted by: Kirk McKusick (mcKusick@mckusick.com) Obtained from: WHistle development tree
* Try to dynamically size the VM_KMEM_SIZE (but is still able to be overriddendyson1998-02-231-10/+39
| | | | | | | | in a way identically as before.) I had problems with the system properly handling the number of vnodes when there is alot of system memory, and the default VM_KMEM_SIZE. Two new options "VM_KMEM_SIZE_SCALE" and "VM_KMEM_SIZE_MAX" have been added to support better auto-sizing for systems with greater than 128MB.
OpenPOWER on IntegriCloud