From: Matthew Dillon Date: Fri, 21 Nov 2003 22:46:15 +0000 (+0000) Subject: Do some fairly major include file cleanups to further separate kernelland X-Git-Tag: v2.0.1~12570 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/052206136f5f7e5905f77007870975ddf8ab2572?hp=7a2b92371ae5858e97c740602beb699813a755a8 Do some fairly major include file cleanups to further separate kernelland from userland. * Do not allow userland to include sys/proc.h directly, it must use sys/user.h instead. This is because sys/proc.h has a huge number of kernel header file dependancies. * Do cleanups and work in lwkt_thread.c and lwkt_msgport.c to allow these files to be directly compiled in an upcoming userland thread support library. * sys/lock.h is inappropriately included by a number of third party programs so we can't disallow its inclusion, but do not include any kernel structures unless _KERNEL or _KERNEL_STRUCTURES are defined. * is often included by userland to get at the on-disk inode structure. Only include the on-disk components and do not include kernel structural components unless _KERNEL or _KERNEL_STRUCTURES is defined * Various usr.bin programs include sys/proc.h unnecessarily. * The slab allocator has no concept of malloc buckets. Remove malloc buckets structures and VMSTAT support from the system. * Make adjustments to sys/thread.h and sys/msgport.h such that the upcoming userland thread support library can include these files directly rather then copy them. * Use low level __int types in sys/globaldata.h, sys/msgport.h, sys/slaballoc.h, sys/thread.h, and sys/malloc.h, instead of high level sys/types.h types, reducing include dependancies. --- diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index a15786c303..ed20736d87 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -32,13 +32,12 @@ * * @(#)keyword.c 8.5 (Berkeley) 4/2/94 * $FreeBSD: src/bin/ps/keyword.c,v 1.24.2.3 2002/10/10 20:05:32 jmallett Exp $ - * $DragonFly: src/bin/ps/keyword.c,v 1.8 2003/09/28 14:39:15 hmp Exp $ + * $DragonFly: src/bin/ps/keyword.c,v 1.9 2003/11/21 22:46:10 dillon Exp $ */ #include #include #include -#include #include #include #include diff --git a/bin/ps/print.c b/bin/ps/print.c index 5ff25cceed..6b239ec32d 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -32,13 +32,12 @@ * * @(#)print.c 8.6 (Berkeley) 4/16/94 * $FreeBSD: src/bin/ps/print.c,v 1.36.2.4 2002/11/30 13:00:14 tjr Exp $ - * $DragonFly: src/bin/ps/print.c,v 1.8 2003/09/28 14:39:15 hmp Exp $ + * $DragonFly: src/bin/ps/print.c,v 1.9 2003/11/21 22:46:10 dillon Exp $ */ #include #include #include -#include #include #include diff --git a/lib/libkvm/kvm_getloadavg.c b/lib/libkvm/kvm_getloadavg.c index 18bbbeb803..34eeb9170c 100644 --- a/lib/libkvm/kvm_getloadavg.c +++ b/lib/libkvm/kvm_getloadavg.c @@ -32,13 +32,12 @@ * * @(#)kvm_getloadavg.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libkvm/kvm_getloadavg.c,v 1.3 1999/12/27 07:14:57 peter Exp $ - * $DragonFly: src/lib/libkvm/kvm_getloadavg.c,v 1.2 2003/06/17 04:26:49 dillon Exp $ + * $DragonFly: src/lib/libkvm/kvm_getloadavg.c,v 1.3 2003/11/21 22:46:11 dillon Exp $ */ #include #include #include -#include #include #include diff --git a/sbin/vinum/commands.c b/sbin/vinum/commands.c index a1004be302..de4dec0e62 100644 --- a/sbin/vinum/commands.c +++ b/sbin/vinum/commands.c @@ -38,9 +38,11 @@ * * $Id: commands.c,v 1.14 2000/11/14 20:01:23 grog Exp grog $ * $FreeBSD: src/sbin/vinum/commands.c,v 1.31.2.6 2003/06/06 05:13:29 grog Exp $ - * $DragonFly: src/sbin/vinum/commands.c,v 1.3 2003/08/08 04:18:41 dillon Exp $ + * $DragonFly: src/sbin/vinum/commands.c,v 1.4 2003/11/21 22:46:13 dillon Exp $ */ +#define _KERNEL_STRUCTURES + #include #include #include diff --git a/sbin/vinum/list.c b/sbin/vinum/list.c index 782fed41c6..bf98a29762 100644 --- a/sbin/vinum/list.c +++ b/sbin/vinum/list.c @@ -41,9 +41,11 @@ * * $Id: list.c,v 1.25 2000/12/20 03:38:43 grog Exp grog $ * $FreeBSD: src/sbin/vinum/list.c,v 1.25.2.4 2001/05/28 05:58:04 grog Exp $ - * $DragonFly: src/sbin/vinum/list.c,v 1.3 2003/08/08 04:18:41 dillon Exp $ + * $DragonFly: src/sbin/vinum/list.c,v 1.4 2003/11/21 22:46:13 dillon Exp $ */ +#define _KERNEL_STRUCTURES + #include #include #include diff --git a/sys/bus/cam/scsi/scsi_da.c b/sys/bus/cam/scsi/scsi_da.c index 6442ad0f48..8b74f52ac4 100644 --- a/sys/bus/cam/scsi/scsi_da.c +++ b/sys/bus/cam/scsi/scsi_da.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.42.2.36 2003/05/17 21:48:30 njl Exp $ - * $DragonFly: src/sys/bus/cam/scsi/scsi_da.c,v 1.9 2003/09/07 17:43:12 asmodai Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_da.c,v 1.10 2003/11/21 22:46:13 dillon Exp $ */ #ifdef _KERNEL @@ -47,15 +47,19 @@ #include #include #include +#ifdef _KERNEL #include #include #include +#endif #include #include +#ifdef _KERNEL #include #include +#endif #ifndef _KERNEL #include diff --git a/sys/bus/cam/scsi/scsi_sa.c b/sys/bus/cam/scsi/scsi_sa.c index 158e98bdc4..4a789fd267 100644 --- a/sys/bus/cam/scsi/scsi_sa.c +++ b/sys/bus/cam/scsi/scsi_sa.c @@ -1,6 +1,6 @@ /* * $FreeBSD: src/sys/cam/scsi/scsi_sa.c,v 1.45.2.13 2002/12/17 17:08:50 trhodes Exp $ - * $DragonFly: src/sys/bus/cam/scsi/scsi_sa.c,v 1.7 2003/08/07 21:16:45 dillon Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_sa.c,v 1.8 2003/11/21 22:46:13 dillon Exp $ * * Implementation of SCSI Sequential Access Peripheral driver for CAM. * @@ -37,12 +37,16 @@ #include #endif #include +#ifdef _KERNEL #include #include +#endif #include #include +#ifdef _KERNEL #include #include +#endif #include #include diff --git a/sys/dev/raid/vinum/vinumhdr.h b/sys/dev/raid/vinum/vinumhdr.h index 0af022a341..694c40a294 100644 --- a/sys/dev/raid/vinum/vinumhdr.h +++ b/sys/dev/raid/vinum/vinumhdr.h @@ -38,7 +38,7 @@ /* * $Id: vinumhdr.h,v 1.18 2001/01/04 00:14:14 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumhdr.h,v 1.16.2.1 2001/03/13 02:59:43 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumhdr.h,v 1.6 2003/08/07 21:54:29 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumhdr.h,v 1.7 2003/11/21 22:46:13 dillon Exp $ */ #include @@ -53,8 +53,10 @@ #endif #include #include +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) #include #include +#endif #include #include #include diff --git a/sys/kern/lwkt_msgport.c b/sys/kern/lwkt_msgport.c index d8e1001c26..7c3721fb73 100644 --- a/sys/kern/lwkt_msgport.c +++ b/sys/kern/lwkt_msgport.c @@ -26,7 +26,7 @@ * NOTE! This file may be compiled for userland libraries as well as for * the kernel. * - * $DragonFly: src/sys/kern/lwkt_msgport.c,v 1.8 2003/11/20 06:05:30 dillon Exp $ + * $DragonFly: src/sys/kern/lwkt_msgport.c,v 1.9 2003/11/21 22:46:08 dillon Exp $ */ #ifdef _KERNEL @@ -63,7 +63,13 @@ #else +#include +#include +#include #include +#include +#include +#include #include #endif /* _KERNEL */ diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index 2357372e90..6b69b03368 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/lwkt_thread.c,v 1.41 2003/11/09 02:22:36 dillon Exp $ + * $DragonFly: src/sys/kern/lwkt_thread.c,v 1.42 2003/11/21 22:46:08 dillon Exp $ */ /* @@ -38,6 +38,8 @@ * early boot (primarily interrupt and network thread initialization). */ +#ifdef _KERNEL + #include #include #include @@ -64,25 +66,48 @@ #include #include +#define THREAD_STACK (UPAGES * PAGE_SIZE) + +#else + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif + static int untimely_switch = 0; -SYSCTL_INT(_lwkt, OID_AUTO, untimely_switch, CTLFLAG_RW, &untimely_switch, 0, ""); #ifdef INVARIANTS static int token_debug = 0; +#endif +static __int64_t switch_count = 0; +static __int64_t preempt_hit = 0; +static __int64_t preempt_miss = 0; +static __int64_t preempt_weird = 0; +static __int64_t ipiq_count = 0; +static __int64_t ipiq_fifofull = 0; + +#ifdef _KERNEL + +SYSCTL_INT(_lwkt, OID_AUTO, untimely_switch, CTLFLAG_RW, &untimely_switch, 0, ""); +#ifdef INVARIANTS SYSCTL_INT(_lwkt, OID_AUTO, token_debug, CTLFLAG_RW, &token_debug, 0, ""); #endif -static quad_t switch_count = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, switch_count, CTLFLAG_RW, &switch_count, 0, ""); -static quad_t preempt_hit = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, preempt_hit, CTLFLAG_RW, &preempt_hit, 0, ""); -static quad_t preempt_miss = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, preempt_miss, CTLFLAG_RW, &preempt_miss, 0, ""); -static quad_t preempt_weird = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, preempt_weird, CTLFLAG_RW, &preempt_weird, 0, ""); -static quad_t ipiq_count = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, ipiq_count, CTLFLAG_RW, &ipiq_count, 0, ""); -static quad_t ipiq_fifofull = 0; SYSCTL_QUAD(_lwkt, OID_AUTO, ipiq_fifofull, CTLFLAG_RW, &ipiq_fifofull, 0, ""); +#endif + /* * These helper procedures handle the runq, they can only be called from * within a critical section. @@ -181,13 +206,21 @@ lwkt_alloc_thread(struct thread *td, int cpu) flags = td->td_flags & (TDF_ALLOCATED_STACK|TDF_ALLOCATED_THREAD); } else { crit_exit(); +#ifdef _KERNEL td = zalloc(thread_zone); +#else + td = malloc(sizeof(struct thread)); +#endif td->td_kstack = NULL; flags |= TDF_ALLOCATED_THREAD; } } if ((stack = td->td_kstack) == NULL) { - stack = (void *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); +#ifdef _KERNEL + stack = (void *)kmem_alloc(kernel_map, THREAD_STACK); +#else + stack = liblwkt_alloc_stack(THREAD_STACK); +#endif flags |= TDF_ALLOCATED_STACK; } if (cpu < 0) @@ -287,13 +320,21 @@ lwkt_free_thread(thread_t td) } else { crit_exit(); if (td->td_kstack && (td->td_flags & TDF_ALLOCATED_STACK)) { - kmem_free(kernel_map, - (vm_offset_t)td->td_kstack, UPAGES * PAGE_SIZE); +#ifdef _KERNEL + kmem_free(kernel_map, (vm_offset_t)td->td_kstack, THREAD_STACK); +#else + liblwkt_free_stack(td->td_kstack, THREAD_STACK); +#endif /* gd invalid */ td->td_kstack = NULL; } - if (td->td_flags & TDF_ALLOCATED_THREAD) + if (td->td_flags & TDF_ALLOCATED_THREAD) { +#ifdef _KERNEL zfree(thread_zone, td); +#else + free(td); +#endif + } } } @@ -694,8 +735,10 @@ lwkt_schedule_self(void) crit_enter(); KASSERT(td->td_wait == NULL, ("lwkt_schedule_self(): td_wait not NULL!")); _lwkt_enqueue(td); +#ifdef _KERNEL if (td->td_proc && td->td_proc->p_stat == SSLEEP) panic("SCHED SELF PANIC"); +#endif crit_exit(); } @@ -1247,6 +1290,7 @@ lwkt_exit(void) cpu_thread_exit(); } +#ifdef _KERNEL /* * Create a kernel process/thread/whatever. It shares it's address space * with proc0 - ie: kernel only. 5.x compatible. @@ -1285,6 +1329,8 @@ kthread_create(void (*func)(void *), void *arg, return 0; } +#endif + void crit_panic(void) { diff --git a/sys/sys/globaldata.h b/sys/sys/globaldata.h index 4edc0e97bd..3f47e59db3 100644 --- a/sys/sys/globaldata.h +++ b/sys/sys/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/sys/globaldata.h,v 1.20 2003/11/21 05:29:02 dillon Exp $ + * $DragonFly: src/sys/sys/globaldata.h,v 1.21 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_GLOBALDATA_H_ @@ -32,6 +32,9 @@ #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) +#ifndef _SYS_STDINT_H_ +#include /* __int types */ +#endif #ifndef _SYS_TIME_H_ #include /* struct timeval */ #endif @@ -80,14 +83,14 @@ struct globaldata { struct privatespace *gd_prvspace; /* self-reference */ struct thread *gd_curthread; int gd_tdfreecount; /* new thread cache */ - u_int32_t gd_reqflags; /* (see note above) */ + __uint32_t gd_reqflags; /* (see note above) */ union sysunion *gd_freesysun; /* free syscall messages */ TAILQ_HEAD(,thread) gd_tdallq; /* all threads */ TAILQ_HEAD(,thread) gd_tdfreeq; /* new thread cache */ TAILQ_HEAD(,thread) gd_tdrunq[32]; /* runnable threads */ - u_int32_t gd_runqmask; /* which queues? */ - u_int gd_cpuid; - u_int gd_other_cpus; /* mask of 'other' cpus */ + __uint32_t gd_runqmask; /* which queues? */ + __uint32_t gd_cpuid; + __uint32_t gd_other_cpus; /* mask of 'other' cpus */ struct timeval gd_stattv; int gd_intr_nesting_level; /* (for interrupts) */ int gd_psticks; /* profile kern/kern_clock.c */ diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 51237890be..20000c9bab 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -36,11 +36,17 @@ * * @(#)lock.h 8.12 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/lock.h,v 1.17.2.3 2001/12/25 01:44:44 dillon Exp $ - * $DragonFly: src/sys/sys/lock.h,v 1.6 2003/08/20 07:31:21 rob Exp $ + * $DragonFly: src/sys/sys/lock.h,v 1.7 2003/11/21 22:46:13 dillon Exp $ */ -#ifndef _LOCK_H_ -#define _LOCK_H_ +#ifndef _SYS_LOCK_H_ +#define _SYS_LOCK_H_ + +/* + * A number of third party programs #include for no good + * reason. Don't actually include anything unless we are the kernel. + */ +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) #include #ifndef _SYS_THREAD_H_ @@ -178,6 +184,8 @@ struct lock { #define LK_KERNTHREAD ((struct thread *)-2) #define LK_NOTHREAD ((struct thread *)-1) +#ifdef _KERNEL + void dumplockinfo(struct lock *lkp); struct proc; @@ -200,4 +208,7 @@ void lockmgr_printinfo (struct lock *); int lockstatus (struct lock *, struct thread *); int lockcount (struct lock *); -#endif /* !_LOCK_H_ */ +#endif /* _KERNEL */ +#endif /* _KERNEL || _KERNEL_STRUCTURES */ +#endif /* _SYS_LOCK_H_ */ + diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 9e2a590bc4..edcc3470ae 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -32,7 +32,7 @@ * * @(#)malloc.h 8.5 (Berkeley) 5/3/95 * $FreeBSD: src/sys/sys/malloc.h,v 1.48.2.2 2002/03/16 02:19:16 archie Exp $ - * $DragonFly: src/sys/sys/malloc.h,v 1.14 2003/11/09 02:22:37 dillon Exp $ + * $DragonFly: src/sys/sys/malloc.h,v 1.15 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_MALLOC_H_ @@ -42,7 +42,7 @@ #include /* for SMP_MAXCPU */ #endif -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) #ifndef _MACHINE_VMPARAM_H_ #include /* for VM_MIN_KERNEL_ADDRESS */ @@ -50,14 +50,12 @@ #define splmem splhigh -#endif - -#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) - #ifndef _MACHINE_TYPES_H_ #include /* vm_paddr_t */ #endif +#endif /* _KERNEL */ + /* * flags to malloc. */ @@ -86,37 +84,46 @@ struct malloc_type { long ks_limit; /* most that are allowed to exist */ long ks_size; /* sizes of this thing that are allocated */ long ks_inuse[SMP_MAXCPU]; /* # of allocs currently in use */ - int64_t ks_calls; /* total packets of this type ever allocated */ + __int64_t ks_calls; /* total packets of this type ever allocated */ long ks_maxused; /* maximum number ever used */ - u_long ks_magic; /* if it's not magic, don't touch it */ + __uint32_t ks_magic; /* if it's not magic, don't touch it */ const char *ks_shortdesc; /* short description */ - u_short ks_limblocks; /* number of times blocked for hitting limit */ - u_short ks_mapblocks; /* number of times blocked for kernel map */ + __uint16_t ks_limblocks; /* number of times blocked for hitting limit */ + __uint16_t ks_mapblocks; /* number of times blocked for kernel map */ long ks_reserved[4]; /* future use (module compatibility) */ }; -#endif +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) -#ifdef _KERNEL -#define MALLOC_DEFINE(type, shortdesc, longdesc) \ - struct malloc_type type[1] = { \ - { NULL, { 0 }, 0, 0, 0, { 0 }, 0, 0, M_MAGIC, shortdesc, 0, 0 } \ - }; \ +#define MALLOC_DEFINE(type, shortdesc, longdesc) \ + struct malloc_type type[1] = { \ + { NULL, { 0 }, 0, 0, 0, { 0 }, 0, 0, M_MAGIC, shortdesc, 0, 0 } \ + }; \ SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_ANY, malloc_init, type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, malloc_uninit, type) +#else + +#define MALLOC_DEFINE(type, shortdesc, longdesc) \ + struct malloc_type type[1] = { \ + { NULL, { 0 }, 0, 0, 0, { 0 }, 0, 0, M_MAGIC, shortdesc, 0, 0 } \ + }; + +#endif + #define MALLOC_DECLARE(type) \ extern struct malloc_type type[1] +#ifdef _KERNEL + MALLOC_DECLARE(M_CACHE); MALLOC_DECLARE(M_DEVBUF); MALLOC_DECLARE(M_TEMP); MALLOC_DECLARE(M_IP6OPT); /* for INET6 */ MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ -#endif /* _KERNEL */ -#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) +#endif /* _KERNEL */ /* * Array of descriptors that describe the contents of each page @@ -124,65 +131,17 @@ MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ struct kmemusage { short ku_cpu; /* cpu index */ union { - u_short freecnt;/* for small allocations, free pieces in page */ - u_short pagecnt;/* for large allocations, pages alloced */ + __int16_t freecnt;/* for small allocations, free pieces in page */ + __int16_t pagecnt;/* for large allocations, pages alloced */ } ku_un; }; #define ku_freecnt ku_un.freecnt #define ku_pagecnt ku_un.pagecnt -/* - * Set of buckets for each size of memory block that is retained - */ -struct kmembuckets { - caddr_t kb_next; /* list of free blocks */ - caddr_t kb_last; /* last free block */ - int64_t kb_calls; /* total calls to allocate this size */ - long kb_total; /* total number of blocks allocated */ - long kb_elmpercl; /* # of elements in this sized allocation */ - long kb_totalfree; /* # of free elements in this bucket */ - long kb_highwat; /* high water mark */ - long kb_couldfree; /* over high water mark and could free */ -}; - -#define MINALLOCSIZE (1 << MINBUCKET) -#define BUCKETINDX(size) \ - ((size) <= (MINALLOCSIZE * 128) \ - ? (size) <= (MINALLOCSIZE * 8) \ - ? (size) <= (MINALLOCSIZE * 2) \ - ? (size) <= (MINALLOCSIZE * 1) \ - ? (MINBUCKET + 0) \ - : (MINBUCKET + 1) \ - : (size) <= (MINALLOCSIZE * 4) \ - ? (MINBUCKET + 2) \ - : (MINBUCKET + 3) \ - : (size) <= (MINALLOCSIZE* 32) \ - ? (size) <= (MINALLOCSIZE * 16) \ - ? (MINBUCKET + 4) \ - : (MINBUCKET + 5) \ - : (size) <= (MINALLOCSIZE * 64) \ - ? (MINBUCKET + 6) \ - : (MINBUCKET + 7) \ - : (size) <= (MINALLOCSIZE * 2048) \ - ? (size) <= (MINALLOCSIZE * 512) \ - ? (size) <= (MINALLOCSIZE * 256) \ - ? (MINBUCKET + 8) \ - : (MINBUCKET + 9) \ - : (size) <= (MINALLOCSIZE * 1024) \ - ? (MINBUCKET + 10) \ - : (MINBUCKET + 11) \ - : (size) <= (MINALLOCSIZE * 8192) \ - ? (size) <= (MINALLOCSIZE * 4096) \ - ? (MINBUCKET + 12) \ - : (MINBUCKET + 13) \ - : (size) <= (MINALLOCSIZE * 16384) \ - ? (MINBUCKET + 14) \ - : (MINBUCKET + 15)) - -#endif - #ifdef _KERNEL +#define MINALLOCSIZE sizeof(void *) + /* * Turn virtual addresses into kmem map indices */ diff --git a/sys/sys/msgport.h b/sys/sys/msgport.h index 75d973c748..b9b3a0fa90 100644 --- a/sys/sys/msgport.h +++ b/sys/sys/msgport.h @@ -3,7 +3,7 @@ * * Implements LWKT messages and ports. * - * $DragonFly: src/sys/sys/msgport.h,v 1.9 2003/11/20 06:05:31 dillon Exp $ + * $DragonFly: src/sys/sys/msgport.h,v 1.10 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_MSGPORT_H_ @@ -12,6 +12,9 @@ #ifndef _SYS_QUEUE_H_ #include /* TAILQ_* macros */ #endif +#ifndef _SYS_STDINT_H_ +#include +#endif struct lwkt_msg; struct lwkt_port; @@ -49,9 +52,9 @@ typedef struct lwkt_msg { int ms_result; /* standard 'int'eger result */ long ms_lresult; /* long result */ int ms_fds[2]; /* two int bit results */ - int32_t ms_result32; /* 32 bit result */ - int64_t ms_result64; /* 64 bit result */ - off_t ms_offset; /* off_t result */ + __int32_t ms_result32; /* 32 bit result */ + __int64_t ms_result64; /* 64 bit result */ + __off_t ms_offset; /* off_t result */ } u; #define ms_copyout_end ms_pad[0] int ms_pad[2]; /* future use */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 55c8602eac..224a79e560 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,12 +37,16 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.36 2003/11/21 05:29:02 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.37 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_PROC_H_ #define _SYS_PROC_H_ +#if !defined(_KERNEL) && !defined(_KERNEL_STRUCTURES) +#error "Userland must include sys/user.h instead of sys/proc.h" +#endif + #include /* For struct callout_handle. */ #include #include diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index af738b29dc..cc2c8e7cde 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -32,15 +32,22 @@ * * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 * $FreeBSD: src/sys/sys/signalvar.h,v 1.34.2.1 2000/05/16 06:58:05 dillon Exp $ - * $DragonFly: src/sys/sys/signalvar.h,v 1.9 2003/11/21 08:32:46 dillon Exp $ + * $DragonFly: src/sys/sys/signalvar.h,v 1.10 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ #define _SYS_SIGNALVAR_H_ +/* + * Don't bring in the entire bleeding include set if we aren't the kernel. + * Userland is not allowed to bring in sys/proc.h except under special + * circumstances (e.g. sys/user.h) + */ #include +#ifdef _KERNEL #include #include +#endif /* * Kernel signal definitions and data structures, @@ -66,11 +73,15 @@ struct sigacts { #define SIG_CATCH ((__sighandler_t *)2) #define SIG_HOLD ((__sighandler_t *)3) +#ifdef _KERNEL + /* * get signal action for process and signal; currently only for current process */ #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) +#endif + /* * sigset_t manipulation macros */ diff --git a/sys/sys/slaballoc.h b/sys/sys/slaballoc.h index 138e124717..c56de23f8e 100644 --- a/sys/sys/slaballoc.h +++ b/sys/sys/slaballoc.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/sys/slaballoc.h,v 1.4 2003/10/02 22:27:00 dillon Exp $ + * $DragonFly: src/sys/sys/slaballoc.h,v 1.5 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_SLABALLOC_H_ @@ -33,6 +33,9 @@ #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) +#ifndef _SYS_STDINT_H_ +#include +#endif #ifndef _SYS_MALLOC_H_ #include #endif @@ -68,7 +71,7 @@ typedef struct SLChunk { * The IN-BAND zone header is placed at the beginning of each zone. */ typedef struct SLZone { - int32_t z_Magic; /* magic number for sanity check */ + __int32_t z_Magic; /* magic number for sanity check */ int z_Cpu; /* which cpu owns this zone? */ int z_NFree; /* total free chunks / ualloc space in zone */ struct SLZone *z_Next; /* ZoneAry[] link if z_NFree non-zero */ @@ -94,15 +97,7 @@ typedef struct SLGlobalData { struct malloc_type ZoneInfo; /* stats on meta-zones allocated */ } SLGlobalData; -#endif - -#ifdef _KERNEL - -void slab_init(void); -void *slab_alloc(struct malloc_type *info, uintptr_t bytes, int flags); -void slab_free(void *ptr, struct malloc_type *info); - #endif /* _KERNEL */ -#endif +#endif /* _SYS_SLABALLOC_H_ */ diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 541430da3a..b03d1f201f 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -3,16 +3,28 @@ * * Implements the architecture independant portion of the LWKT * subsystem. + * + * Types which must already be defined when this header is included by + * userland: struct md_thread * - * $DragonFly: src/sys/sys/thread.h,v 1.36 2003/11/03 02:08:36 dillon Exp $ + * $DragonFly: src/sys/sys/thread.h,v 1.37 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_THREAD_H_ #define _SYS_THREAD_H_ +#ifndef _SYS_STDINT_H_ +#include /* __int types */ +#endif +#ifndef _SYS_PARAM_H_ +#include /* MAXCOMLEN */ +#endif #ifndef _SYS_QUEUE_H_ #include /* TAILQ_* macros */ #endif +#ifndef _SYS_MSGPORT_H_ +#include /* lwkt_port */ +#endif struct globaldata; struct proc; @@ -39,11 +51,17 @@ typedef struct thread *thread_t; typedef TAILQ_HEAD(lwkt_queue, thread) lwkt_queue; +/* + * Differentiation between kernel threads and user threads. Userland + * programs which want to access to kernel structures have to define + * _KERNEL_STRUCTURES. This is a kinda safety valve to prevent badly + * written user programs from getting an LWKT thread that is neither the + * kernel nor the user version. + */ +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) #ifndef _MACHINE_THREAD_H_ #include /* md_thread */ #endif -#ifndef _SYS_MSGPORT_H_ -#include #endif /* @@ -56,9 +74,6 @@ typedef struct lwkt_token { int t_cpu; /* the current owner of the token */ int t_reqcpu; /* return ownership to this cpu on release */ int t_gen; /* generation number */ -#if 0 - int t_pri; /* raise thread priority to hold token */ -#endif } lwkt_token; /* @@ -144,9 +159,9 @@ struct thread { char *td_sp; /* kernel stack pointer for LWKT restore */ void (*td_switch)(struct thread *ntd); lwkt_wait_t td_wait; /* thread sitting on wait structure */ - u_int64_t td_uticks; /* Statclock hits in user mode (uS) */ - u_int64_t td_sticks; /* Statclock hits in system mode (uS) */ - u_int64_t td_iticks; /* Statclock hits processing intr (uS) */ + __uint64_t td_uticks; /* Statclock hits in user mode (uS) */ + __uint64_t td_sticks; /* Statclock hits in system mode (uS) */ + __uint64_t td_iticks; /* Statclock hits processing intr (uS) */ int td_locks; /* lockmgr lock debugging YYY */ int td_refs; /* hold position in gd_tdallq / hold free */ int td_nest_count; /* prevent splz nesting */ @@ -222,6 +237,11 @@ struct thread { extern struct vm_zone *thread_zone; +#endif + +/* + * Applies both to the kernel and to liblwkt. + */ extern struct thread *lwkt_alloc_thread(struct thread *template, int cpu); extern void lwkt_init_thread(struct thread *td, void *stack, int flags, struct globaldata *gd); @@ -272,5 +292,3 @@ extern void lwkt_exit (void) __dead2; #endif -#endif - diff --git a/sys/sys/thread2.h b/sys/sys/thread2.h index 4af4e1893a..e0c0cada48 100644 --- a/sys/sys/thread2.h +++ b/sys/sys/thread2.h @@ -8,12 +8,21 @@ * on a different cpu will not be immediately scheduled by a yield() on * this cpu. * - * $DragonFly: src/sys/sys/thread2.h,v 1.9 2003/07/25 05:51:19 dillon Exp $ + * $DragonFly: src/sys/sys/thread2.h,v 1.10 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_THREAD2_H_ #define _SYS_THREAD2_H_ +/* + * Userland will have its own globaldata which it includes prior to this. + */ +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) +#ifndef _SYS_GLOBALDATA_H_ +#include +#endif +#endif + /* * Critical sections prevent preemption by raising a thread's priority * above the highest possible interrupting priority. Additionally, the diff --git a/sys/sys/user.h b/sys/sys/user.h index 436a2395c8..944f5165ac 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -32,14 +32,26 @@ * * @(#)user.h 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/sys/sys/user.h,v 1.24.2.1 2001/10/11 08:20:18 peter Exp $ - * $DragonFly: src/sys/sys/user.h,v 1.11 2003/08/20 07:31:22 rob Exp $ + * $DragonFly: src/sys/sys/user.h,v 1.12 2003/11/21 22:46:13 dillon Exp $ */ #ifndef _SYS_USER_H_ #define _SYS_USER_H_ #ifndef _KERNEL -/* stuff that *used* to be included by user.h, or is now needed */ + +/* + * stuff that *used* to be included by user.h, or is now needed. The + * expectation here is that the user program wants to mess with kernel + * structures. To be sure we get kernel structures we have to define + * _KERNEL_STRUCTURES. Otherwise we might get the user version. + * + * This is a really aweful hack. Fortunately nobody includes sys/user.h + * unless they really, really, really need kinfo_proc. + */ +#ifndef _KERNEL_STRUCTURES +#define _KERNEL_STRUCTURES +#endif #include #include #include diff --git a/sys/vfs/ufs/inode.h b/sys/vfs/ufs/inode.h index 4fc00ebc62..a4f5317b03 100644 --- a/sys/vfs/ufs/inode.h +++ b/sys/vfs/ufs/inode.h @@ -37,14 +37,18 @@ * * @(#)inode.h 8.9 (Berkeley) 5/14/95 * $FreeBSD: src/sys/ufs/ufs/inode.h,v 1.28.2.2 2001/09/29 12:52:52 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/inode.h,v 1.4 2003/08/27 02:03:23 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/inode.h,v 1.5 2003/11/21 22:46:14 dillon Exp $ */ #ifndef _UFS_UFS_INODE_H_ #define _UFS_UFS_INODE_H_ +#ifndef _SYS_LOCK_H_ #include +#endif +#ifndef _SYS_QUEUE_H_ #include +#endif #include "dinode.h" /* @@ -57,6 +61,8 @@ typedef long ufs_lbn_t; */ #define doff_t int32_t +#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) + /* * The inode is used to describe each active (or recently active) file in the * UFS filesystem. It is composed of two types of information. The first part @@ -122,6 +128,8 @@ struct inode { #define i_size i_din.di_size #define i_uid i_din.di_uid +#endif + /* These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ #define IN_CHANGE 0x0002 /* Inode change time update request. */ diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 5887a910e1..c1b366dceb 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -30,7 +30,7 @@ * BSDI doscmd.c,v 2.3 1996/04/08 19:32:30 bostic Exp * * $FreeBSD: src/usr.bin/doscmd/doscmd.c,v 1.13.2.6 2002/04/25 11:04:51 tg Exp $ - * $DragonFly: src/usr.bin/doscmd/doscmd.c,v 1.2 2003/06/17 04:29:26 dillon Exp $ + * $DragonFly: src/usr.bin/doscmd/doscmd.c,v 1.3 2003/11/21 22:46:14 dillon Exp $ */ #include @@ -50,7 +50,6 @@ #include #include -#include #include #include diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 9cbaa05861..a99fdc0cd8 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -33,14 +33,13 @@ * @(#) Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved. * @(#)fstat.c 8.3 (Berkeley) 5/2/95 * $FreeBSD: src/usr.bin/fstat/fstat.c,v 1.21.2.7 2001/11/21 10:49:37 dwmalone Exp $ - * $DragonFly: src/usr.bin/fstat/fstat.c,v 1.6 2003/10/04 20:36:44 hmp Exp $ + * $DragonFly: src/usr.bin/fstat/fstat.c,v 1.7 2003/11/21 22:46:14 dillon Exp $ */ #define _KERNEL_STRUCTURES #include #include -#include #include #include #include diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 9c4354a29d..d44c191f09 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -24,9 +24,11 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.bin/gcore/elfcore.c,v 1.5.2.3 2001/07/11 23:59:11 obrien Exp $ - * $DragonFly: src/usr.bin/gcore/elfcore.c,v 1.2 2003/06/17 04:29:26 dillon Exp $ + * $DragonFly: src/usr.bin/gcore/elfcore.c,v 1.3 2003/11/21 22:46:14 dillon Exp $ */ +#define _KERNEL_STRUCTURES + #include #include #include diff --git a/usr.bin/gcore/gcore.c b/usr.bin/gcore/gcore.c index 21995e4415..db36ece063 100644 --- a/usr.bin/gcore/gcore.c +++ b/usr.bin/gcore/gcore.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1992, 1993 The Regents of the University of California. All rights reserved. * @(#)gcore.c 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/usr.bin/gcore/gcore.c,v 1.15.2.2 2001/08/17 20:56:22 mikeh Exp $ - * $DragonFly: src/usr.bin/gcore/gcore.c,v 1.5 2003/11/03 19:31:29 eirikn Exp $ + * $DragonFly: src/usr.bin/gcore/gcore.c,v 1.6 2003/11/21 22:46:14 dillon Exp $ */ /* @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include diff --git a/usr.bin/gcore/md-sparc.c b/usr.bin/gcore/md-sparc.c index 633eb5def7..9905fbe557 100644 --- a/usr.bin/gcore/md-sparc.c +++ b/usr.bin/gcore/md-sparc.c @@ -36,14 +36,13 @@ * * @(#)md-sparc.c 8.1 (Berkeley) 6/6/93 * - * $DragonFly: src/usr.bin/gcore/md-sparc.c,v 1.3 2003/10/04 20:36:45 hmp Exp $ + * $DragonFly: src/usr.bin/gcore/md-sparc.c,v 1.4 2003/11/21 22:46:14 dillon Exp $ */ #include #include #include #include -#include #include #include #include diff --git a/usr.bin/ipcs/ipcs.c b/usr.bin/ipcs/ipcs.c index 69be01a72e..cb22d29f0a 100644 --- a/usr.bin/ipcs/ipcs.c +++ b/usr.bin/ipcs/ipcs.c @@ -25,7 +25,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/usr.bin/ipcs/ipcs.c,v 1.12.2.4 2003/04/08 11:01:34 tjr Exp $ - * $DragonFly: src/usr.bin/ipcs/ipcs.c,v 1.4 2003/10/04 20:36:46 hmp Exp $ + * $DragonFly: src/usr.bin/ipcs/ipcs.c,v 1.5 2003/11/21 22:46:14 dillon Exp $ */ #define _KERNEL_STRUCTURES @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c index 289c53a21c..d5770cee39 100644 --- a/usr.bin/ktrace/subr.c +++ b/usr.bin/ktrace/subr.c @@ -32,7 +32,7 @@ * * @(#)subr.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/ktrace/subr.c,v 1.6 1999/08/28 01:02:34 peter Exp $ - * $DragonFly: src/usr.bin/ktrace/subr.c,v 1.4 2003/10/04 20:36:46 hmp Exp $ + * $DragonFly: src/usr.bin/ktrace/subr.c,v 1.5 2003/11/21 22:46:14 dillon Exp $ */ #define _KERNEL_STRUCTURES @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c index d89444d403..4ccc74a515 100644 --- a/usr.bin/systat/pigs.c +++ b/usr.bin/systat/pigs.c @@ -32,17 +32,17 @@ * * @(#)pigs.c 8.2 (Berkeley) 9/23/93 * - * $DragonFly: src/usr.bin/systat/pigs.c,v 1.7 2003/10/04 20:36:51 hmp Exp $ + * $DragonFly: src/usr.bin/systat/pigs.c,v 1.8 2003/11/21 22:46:14 dillon Exp $ */ /* * Pigs display from Bill Reeves at Lucasfilm */ +#define _KERNEL_STRUCTURES #include #include #include -#include #include #include diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 6bed3a4fa4..292266c368 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -32,17 +32,18 @@ * * @(#)vmstat.c 8.2 (Berkeley) 1/12/94 * $FreeBSD: src/usr.bin/systat/vmstat.c,v 1.38.2.4 2002/03/12 19:50:23 phantom Exp $ - * $DragonFly: src/usr.bin/systat/vmstat.c,v 1.5 2003/10/04 20:36:51 hmp Exp $ + * $DragonFly: src/usr.bin/systat/vmstat.c,v 1.6 2003/11/21 22:46:14 dillon Exp $ */ /* * Cursed vmstat -- from Robert Elz. */ +#define _KERNEL_STRUCTURES #include #include #include -#include +#include #include #include #include diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 3c8d7c2de5..ac42e7a0b3 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -20,7 +20,7 @@ * Wolfram Schneider * * $FreeBSD: src/usr.bin/top/machine.c,v 1.29.2.2 2001/07/31 20:27:05 tmm Exp $ - * $DragonFly: src/usr.bin/top/machine.c,v 1.9 2003/10/04 20:36:53 hmp Exp $ + * $DragonFly: src/usr.bin/top/machine.c,v 1.10 2003/11/21 22:46:14 dillon Exp $ */ @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 8a5d957242..818024c345 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -33,13 +33,14 @@ * @(#) Copyright (c) 1980, 1986, 1991, 1993 The Regents of the University of California. All rights reserved. * @(#)vmstat.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/vmstat/vmstat.c,v 1.38.2.4 2001/07/31 19:52:41 tmm Exp $ - * $DragonFly: src/usr.bin/vmstat/vmstat.c,v 1.8 2003/10/18 19:59:45 dillon Exp $ + * $DragonFly: src/usr.bin/vmstat/vmstat.c,v 1.9 2003/11/21 22:46:15 dillon Exp $ */ #define _KERNEL_STRUCTURES + #include #include -#include +#include #include #include #include @@ -88,28 +89,22 @@ static struct nlist namelist[] = { { "_eintrcnt" }, #define X_KMEMSTATISTICS 9 { "_kmemstatistics" }, -#if 0 -#define X_KMEMBUCKETS 10 - { "_bucket" }, -#else - { "_kmemstatistics" }, -#endif -#define X_ZLIST 11 +#define X_ZLIST 10 { "_zlist" }, #ifdef notyet -#define X_DEFICIT 12 +#define X_DEFICIT 11 { "_deficit" }, -#define X_FORKSTAT 13 +#define X_FORKSTAT 12 { "_forkstat" }, -#define X_REC 14 +#define X_REC 13 { "_rectime" }, -#define X_PGIN 15 +#define X_PGIN 14 { "_pgintime" }, -#define X_XSTATS 16 +#define X_XSTATS 15 { "_xstats" }, -#define X_END 17 +#define X_END 16 #else -#define X_END 12 +#define X_END 11 #endif { "" }, }; @@ -751,7 +746,6 @@ cpuagg(long *ary) void domem(void) { - register struct kmembuckets *kp; register struct malloc_type *ks; register int i, j; int len, size, first, nkms; @@ -759,13 +753,7 @@ domem(void) const char *name; struct malloc_type kmemstats[MAX_KMSTATS], *kmsp; char buf[1024]; - struct kmembuckets buckets[MINBUCKET + 16]; -#ifdef X_KMEMBUCKETS - kread(X_KMEMBUCKETS, buckets, sizeof(buckets)); -#else - bzero(buckets, sizeof(buckets)); -#endif kread(X_KMEMSTATISTICS, &kmsp, sizeof(kmsp)); for (nkms = 0; nkms < MAX_KMSTATS && kmsp != NULL; nkms++) { if (sizeof(kmemstats[0]) != kvm_read(kd, (u_long)kmsp, @@ -781,55 +769,6 @@ domem(void) } if (kmsp != NULL) warnx("truncated to the first %d memory types", nkms); - (void)printf("Memory statistics by bucket size\n"); - (void)printf( - "Size In Use Free Requests HighWater Couldfree\n"); - for (i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16; i++, kp++) { - if (kp->kb_calls == 0) - continue; - size = 1 << i; - if(size < 1024) - (void)printf("%4d",size); - else - (void)printf("%3dK",size>>10); - (void)printf(" %8ld %6ld %10lld %7ld %10ld\n", - kp->kb_total - kp->kb_totalfree, - kp->kb_totalfree, kp->kb_calls, - kp->kb_highwat, kp->kb_couldfree); - totfree += size * kp->kb_totalfree; - } - - (void)printf("\nMemory usage type by bucket size\n"); - (void)printf("Size Type(s)\n"); - kp = &buckets[MINBUCKET]; - for (j = 1 << MINBUCKET; j < 1 << (MINBUCKET + 16); j <<= 1, kp++) { - if (kp->kb_calls == 0) - continue; - first = 1; - len = 8; - for (i = 0, ks = &kmemstats[0]; i < nkms; i++, ks++) { - if (ks->ks_calls == 0) - continue; - if ((ks->ks_size & j) == 0) - continue; - name = ks->ks_shortdesc; - len += 2 + strlen(name); - if (first && j < 1024) - printf("%4d %s", j, name); - else if (first) - printf("%3dK %s", j>>10, name); - else - printf(","); - if (len >= 79) { - printf("\n\t "); - len = 10 + strlen(name); - } - if (!first) - printf(" %s", name); - first = 0; - } - printf("\n"); - } (void)printf( "\nMemory statistics by type Type Kern\n"); diff --git a/usr.bin/w/proc_compare.c b/usr.bin/w/proc_compare.c index 4216c5be58..d4ab3e66bb 100644 --- a/usr.bin/w/proc_compare.c +++ b/usr.bin/w/proc_compare.c @@ -32,12 +32,12 @@ * * @(#)proc_compare.c 8.2 (Berkeley) 9/23/93 * - * $DragonFly: src/usr.bin/w/proc_compare.c,v 1.3 2003/10/04 20:36:54 hmp Exp $ + * $DragonFly: src/usr.bin/w/proc_compare.c,v 1.4 2003/11/21 22:46:15 dillon Exp $ */ #include #include -#include +#include #include "extern.h" diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index efb83ce453..e322f495b8 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1980, 1991, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)w.c 8.4 (Berkeley) 4/16/94 * $FreeBSD: src/usr.bin/w/w.c,v 1.38.2.6 2002/03/12 19:51:51 phantom Exp $ - * $DragonFly: src/usr.bin/w/w.c,v 1.4 2003/10/04 20:36:54 hmp Exp $ + * $DragonFly: src/usr.bin/w/w.c,v 1.5 2003/11/21 22:46:15 dillon Exp $ */ /* @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include