From 12e4aaff567d5633f2cc0106d0f98505604188d9 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 3 Jul 2003 17:24:04 +0000 Subject: [PATCH] Split the struct vmmeter cnt structure into a global vmstats structure and a per-cpu cnt structure. Adjust the sysctls to accumulate statistics over all cpus. --- .../linux/i386/linprocfs/linprocfs_misc.c | 33 ++- sys/emulation/linux/linux_misc.c | 4 +- sys/i386/i386/exception.s | 18 +- sys/i386/i386/genassym.c | 3 +- sys/i386/i386/globals.s | 5 +- sys/i386/i386/machdep.c | 15 +- sys/i386/i386/pmap.c | 16 +- sys/i386/i386/trap.c | 4 +- sys/i386/i386/vm_machdep.c | 10 +- sys/i386/icu/icu_vector.s | 8 +- sys/i386/isa/icu_vector.s | 8 +- sys/kern/init_main.c | 4 +- sys/kern/kern_fork.c | 18 +- sys/kern/kern_malloc.c | 12 +- sys/kern/kern_synch.c | 4 +- sys/kern/vfs_bio.c | 9 +- sys/kern/vfs_cluster.c | 3 +- sys/kern/vfs_subr.c | 6 +- sys/platform/pc32/i386/exception.s | 18 +- sys/platform/pc32/i386/genassym.c | 3 +- sys/platform/pc32/i386/globals.s | 5 +- sys/platform/pc32/i386/machdep.c | 15 +- sys/platform/pc32/i386/pmap.c | 16 +- sys/platform/pc32/i386/trap.c | 4 +- sys/platform/pc32/i386/vm_machdep.c | 10 +- sys/platform/pc32/icu/icu_vector.s | 8 +- sys/platform/pc32/isa/icu_vector.s | 8 +- sys/platform/vkernel/i386/genassym.c | 3 +- sys/sys/globaldata.h | 10 +- sys/sys/vmmeter.h | 122 ++------- sys/vfs/specfs/spec_vnops.c | 6 +- sys/vfs/ufs/ffs_inode.c | 4 +- sys/vfs/ufs/ufs_readwrite.c | 4 +- sys/vm/swap_pager.c | 31 +-- sys/vm/vm_fault.c | 17 +- sys/vm/vm_glue.c | 5 +- sys/vm/vm_map.c | 18 +- sys/vm/vm_meter.c | 235 ++++++++++-------- sys/vm/vm_mmap.c | 4 +- sys/vm/vm_object.c | 4 +- sys/vm/vm_page.c | 93 +++---- sys/vm/vm_page2.h | 136 ++++++++++ sys/vm/vm_pageout.c | 91 +++---- sys/vm/vm_zone.c | 4 +- sys/vm/vnode_pager.c | 20 +- 45 files changed, 599 insertions(+), 475 deletions(-) create mode 100644 sys/vm/vm_page2.h diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c b/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c index 4e0e6e0a87..a42d8cb31d 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c +++ b/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c @@ -39,7 +39,7 @@ * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 * * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_misc.c,v 1.3.2.8 2001/06/25 19:46:47 pirzyk Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c,v 1.3 2003/06/23 17:55:40 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c,v 1.4 2003/07/03 17:24:02 dillon Exp $ */ #include @@ -105,14 +105,14 @@ linprocfs_domeminfo(curp, p, pfs, uio) /* * The correct thing here would be: * - memfree = cnt.v_free_count * PAGE_SIZE; + memfree = vmstats.v_free_count * PAGE_SIZE; memused = memtotal - memfree; * * but it might mislead linux binaries into thinking there * is very little memory left, so we cheat and tell them that * all memory that isn't wired down is free. */ - memused = cnt.v_wire_count * PAGE_SIZE; + memused = vmstats.v_wire_count * PAGE_SIZE; memfree = memtotal - memused; if (swapblist == NULL) { swaptotal = 0; @@ -137,7 +137,7 @@ linprocfs_domeminfo(curp, p, pfs, uio) * like unstaticizing it just for linprocfs's sake. */ buffers = 0; - cached = cnt.v_cache_count * PAGE_SIZE; + cached = vmstats.v_cache_count * PAGE_SIZE; ps = psbuf; ps += sprintf(ps, @@ -257,6 +257,19 @@ linprocfs_docpuinfo(curp, p, pfs, uio) return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio)); } +static unsigned int +cpucnt(int offset) +{ + int i; + int count = 0; + + for (i = 0; i < ncpus; ++i) { + struct globaldata *gd = globaldata_find(i); + count += *(unsigned int *)((char *)&gd->gd_cnt + offset); + } + return(count); +} + int linprocfs_dostat(curp, p, pfs, uio) struct proc *curp; @@ -281,12 +294,12 @@ linprocfs_dostat(curp, p, pfs, uio) T2J(cp_time[CP_NICE]), T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/), T2J(cp_time[CP_IDLE]), - cnt.v_vnodepgsin, - cnt.v_vnodepgsout, - cnt.v_swappgsin, - cnt.v_swappgsout, - cnt.v_intr, - cnt.v_swtch, + cpucnt(offsetof(struct vmmeter, v_vnodepgsin)), + cpucnt(offsetof(struct vmmeter, v_vnodepgsout)), + cpucnt(offsetof(struct vmmeter, v_swappgsin)), + cpucnt(offsetof(struct vmmeter, v_swappgsout)), + cpucnt(offsetof(struct vmmeter, v_intr)), + cpucnt(offsetof(struct vmmeter, v_swtch)), boottime.tv_sec); xlen = ps - psbuf; xlen -= uio->uio_offset; diff --git a/sys/emulation/linux/linux_misc.c b/sys/emulation/linux/linux_misc.c index bf63c55965..0f3cc33d77 100644 --- a/sys/emulation/linux/linux_misc.c +++ b/sys/emulation/linux/linux_misc.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.85.2.9 2002/09/24 08:11:41 mdodd Exp $ - * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.5 2003/06/26 05:55:10 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.6 2003/07/03 17:23:59 dillon Exp $ */ #include "opt_compat.h" @@ -137,7 +137,7 @@ linux_sysinfo(struct linux_sysinfo_args *args) sysinfo.loads[i] = averunnable.ldavg[i]; sysinfo.totalram = physmem * PAGE_SIZE; - sysinfo.freeram = sysinfo.totalram - cnt.v_wire_count * PAGE_SIZE; + sysinfo.freeram = sysinfo.totalram - vmstats.v_wire_count * PAGE_SIZE; sysinfo.sharedram = 0; for (object = TAILQ_FIRST(&vm_object_list); object != NULL; diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index 8de6ba0958..8d41ad77ca 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.9 2003/07/01 20:30:40 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.10 2003/07/03 17:24:01 dillon Exp $ */ #include "npx.h" @@ -163,14 +163,14 @@ IDTVEC(fpu) mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) movl PCPU(curthread),%ebx /* save original cpl */ movl TD_CPL(%ebx), %ebx pushl %ebx - incl cnt+V_TRAP + incl PCPU(cnt)+V_TRAP call npx_intr /* note: call might mess w/ argument */ @@ -210,12 +210,12 @@ alltraps_with_regs_pushed: mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) calltrap: FAKE_MCOUNT(btrap) /* init "from" _btrap -> calltrap */ - MPLOCKED incl cnt+V_TRAP + incl PCPU(cnt)+V_TRAP /* YYY per-cpu */ MP_LOCK movl PCPU(curthread),%eax /* keep orig cpl here during call */ movl TD_CPL(%eax),%ebx @@ -256,13 +256,13 @@ IDTVEC(syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */ movl %eax,TF_EFLAGS(%esp) movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */ FAKE_MCOUNT(13*4(%esp)) - MPLOCKED incl cnt+V_SYSCALL + incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ call syscall2 MEXITCOUNT cli /* atomic astpending access */ @@ -295,11 +295,11 @@ IDTVEC(int0x80_syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) - MPLOCKED incl cnt+V_SYSCALL + incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ call syscall2 MEXITCOUNT cli /* atomic astpending access */ diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 55c74a7f81..5108d04f0e 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.18 2003/06/29 03:28:42 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.19 2003/07/03 17:24:01 dillon Exp $ */ #include "opt_user_ldt.h" @@ -185,6 +185,7 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread)); ASSYM(GD_REQPRI, offsetof(struct mdglobaldata, mi.gd_reqpri)); ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid)); +ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt)); ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level)); ASSYM(GD_ASTPENDING, offsetof(struct mdglobaldata, mi.gd_astpending)); diff --git a/sys/i386/i386/globals.s b/sys/i386/i386/globals.s index 7dd3822827..2cdbfd9065 100644 --- a/sys/i386/i386/globals.s +++ b/sys/i386/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.13 2003/07/01 20:30:40 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.14 2003/07/03 17:24:01 dillon Exp $ */ #include "opt_user_ldt.h" @@ -84,7 +84,7 @@ .globl gd_ss_eflags, gd_intr_nesting_level .globl gd_CMAP1, gd_CMAP2, gd_CMAP3, gd_PMAP1 .globl gd_CADDR1, gd_CADDR2, gd_CADDR3, gd_PADDR1 - .globl gd_irunning, gd_ipending, gd_fpending + .globl gd_irunning, gd_ipending, gd_fpending, gd_cnt .set gd_cpuid,globaldata + GD_CPUID .set gd_cpu_lockid,globaldata + GD_CPU_LOCKID @@ -102,6 +102,7 @@ .set gd_fpending,globaldata + GD_FPENDING .set gd_ipending,globaldata + GD_IPENDING .set gd_irunning,globaldata + GD_IRUNNING + .set gd_cnt,globaldata + GD_CNT #if defined(APIC_IO) .globl lapic_eoi, lapic_svr, lapic_tpr, lapic_irr1, lapic_ver diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 8c291337ea..2230af8c24 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.19 2003/06/30 23:54:00 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.20 2003/07/03 17:24:01 dillon Exp $ */ #include "apm.h" @@ -175,7 +175,7 @@ static int sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) { int error = sysctl_handle_int(oidp, 0, - ctob(physmem - cnt.v_wire_count), req); + ctob(physmem - vmstats.v_wire_count), req); return (error); } @@ -435,8 +435,8 @@ again: cninit(); /* the preferred console may have changed */ #endif - printf("avail memory = %u (%uK bytes)\n", ptoa(cnt.v_free_count), - ptoa(cnt.v_free_count) / 1024); + printf("avail memory = %u (%uK bytes)\n", ptoa(vmstats.v_free_count), + ptoa(vmstats.v_free_count) / 1024); /* * Set up buffers, so they can be used to read disk labels. @@ -2066,6 +2066,13 @@ cpu_gdinit(struct mdglobaldata *gd, int cpu) *(void **)gd->gd_idlethread.td_sp = cpu_idle_restore; } +struct globaldata * +globaldata_find(int cpu) +{ + KKASSERT(cpu >= 0 && cpu < ncpus); + return(&CPU_prvspace[cpu].mdglobaldata.mi); +} + #if defined(I586_CPU) && !defined(NO_F00F_HACK) static void f00f_hack(void *unused); SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL); diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index fefe7e2654..3cfbf9a048 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.13 2003/06/28 04:16:02 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.14 2003/07/03 17:24:01 dillon Exp $ */ /* @@ -953,7 +953,7 @@ _pmap_unwire_pte_hold(pmap_t pmap, vm_page_t m) { vm_page_flash(m); vm_page_busy(m); vm_page_free_zero(m); - --cnt.v_wire_count; + --vmstats.v_wire_count; } return 1; } @@ -1043,7 +1043,7 @@ pmap_pinit(pmap) VM_ALLOC_NORMAL | VM_ALLOC_RETRY); ptdpg->wire_count = 1; - ++cnt.v_wire_count; + ++vmstats.v_wire_count; vm_page_flag_clear(ptdpg, PG_MAPPED | PG_BUSY); /* not usually mapped*/ @@ -1120,7 +1120,7 @@ pmap_release_free_page(pmap, p) pmap->pm_ptphint = NULL; p->wire_count--; - cnt.v_wire_count--; + vmstats.v_wire_count--; vm_page_free_zero(p); return 1; } @@ -1147,7 +1147,7 @@ _pmap_allocpte(pmap, ptepindex) ("_pmap_allocpte: %p->queue != PQ_NONE", m)); if (m->wire_count == 0) - cnt.v_wire_count++; + vmstats.v_wire_count++; m->wire_count++; /* @@ -2305,7 +2305,7 @@ retry: * free pages allocating pv entries. */ if ((limit & MAP_PREFAULT_MADVISE) && - cnt.v_free_count < cnt.v_free_reserved) { + vmstats.v_free_count < vmstats.v_free_reserved) { break; } if (((p->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) && @@ -2331,7 +2331,7 @@ retry: * free pages allocating pv entries. */ if ((limit & MAP_PREFAULT_MADVISE) && - cnt.v_free_count < cnt.v_free_reserved) { + vmstats.v_free_count < vmstats.v_free_reserved) { break; } p = vm_page_lookup(object, tmpidx + pindex); @@ -2533,7 +2533,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * way below the low water mark of free pages or way * above high water mark of used pv entries. */ - if (cnt.v_free_count < cnt.v_free_reserved || + if (vmstats.v_free_count < vmstats.v_free_reserved || pv_entry_count > pv_entry_high_water) break; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 598e5c95c9..f412d3baa8 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.15 2003/07/03 01:58:25 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.16 2003/07/03 17:24:01 dillon Exp $ */ /* @@ -434,7 +434,7 @@ restart: case T_ASTFLT: /* Allow process switch */ astoff(); - cnt.v_soft++; + mycpu->gd_cnt.v_soft++; if (p->p_flag & P_OWEUPC) { p->p_flag &= ~P_OWEUPC; addupc_task(p, p->p_stats->p_prof.pr_addr, diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 1fe7c760ed..8fbb65d626 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.15 2003/06/30 19:50:30 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.16 2003/07/03 17:24:01 dillon Exp $ */ #include "npx.h" @@ -294,7 +294,7 @@ cpu_proc_exit(void) reset_dbregs(); pcb->pcb_flags &= ~PCB_DBREGS; } - cnt.v_swtch++; + mycpu->gd_cnt.v_swtch++; crit_enter(); lwkt_deschedule_self(); @@ -560,9 +560,9 @@ vm_page_zero_idle() * pages because doing so may flush our L1 and L2 caches too much. */ - if (zero_state && vm_page_zero_count >= ZIDLE_LO(cnt.v_free_count)) + if (zero_state && vm_page_zero_count >= ZIDLE_LO(vmstats.v_free_count)) return(0); - if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count)) + if (vm_page_zero_count >= ZIDLE_HI(vmstats.v_free_count)) return(0); #ifdef SMP @@ -586,7 +586,7 @@ vm_page_zero_idle() pageq); ++vm_page_zero_count; ++cnt_prezero; - if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count)) + if (vm_page_zero_count >= ZIDLE_HI(vmstats.v_free_count)) zero_state = 1; } free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK; diff --git a/sys/i386/icu/icu_vector.s b/sys/i386/icu/icu_vector.s index 0830c0d1a7..f70abd011e 100644 --- a/sys/i386/icu/icu_vector.s +++ b/sys/i386/icu/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.10 2003/07/01 20:31:38 dillon Exp $ + * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.11 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -140,7 +140,7 @@ IDTVEC(vec_name) ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -171,7 +171,7 @@ IDTVEC(vec_name) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4, %esp ; \ - incl cnt+V_INTR ; \ + incl PCPU(cnt)+V_INTR ; \ movl intr_countp + (irq_num) * 4, %eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -238,7 +238,7 @@ IDTVEC(vec_name) ; \ call sched_ithd ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ 5: ; \ diff --git a/sys/i386/isa/icu_vector.s b/sys/i386/isa/icu_vector.s index 8342811307..4dc50c5421 100644 --- a/sys/i386/isa/icu_vector.s +++ b/sys/i386/isa/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.10 2003/07/01 20:31:38 dillon Exp $ + * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.11 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -140,7 +140,7 @@ IDTVEC(vec_name) ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -171,7 +171,7 @@ IDTVEC(vec_name) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4, %esp ; \ - incl cnt+V_INTR ; \ + incl PCPU(cnt)+V_INTR ; \ movl intr_countp + (irq_num) * 4, %eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -238,7 +238,7 @@ IDTVEC(vec_name) ; \ call sched_ithd ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ 5: ; \ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 9806e84dc3..d375827a0c 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.17 2003/06/30 23:54:02 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.18 2003/07/03 17:24:02 dillon Exp $ */ #include "opt_init_path.h" @@ -336,7 +336,7 @@ proc0_init(void *dummy __unused) limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = maxfiles; limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc; - i = ptoa(cnt.v_free_count); + i = ptoa(vmstats.v_free_count); limit0.pl_rlimit[RLIMIT_RSS].rlim_max = i; limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = i; limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 5d614845c9..583d502199 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -37,7 +37,7 @@ * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 * $FreeBSD: src/sys/kern/kern_fork.c,v 1.72.2.13 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.9 2003/06/30 19:50:31 dillon Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.10 2003/07/03 17:24:02 dillon Exp $ */ #include "opt_ktrace.h" @@ -507,17 +507,17 @@ again: vm_fork(p1, p2, flags); if (flags == (RFFDG | RFPROC)) { - cnt.v_forks++; - cnt.v_forkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + mycpu->gd_cnt.v_forks++; + mycpu->gd_cnt.v_forkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; } else if (flags == (RFFDG | RFPROC | RFPPWAIT | RFMEM)) { - cnt.v_vforks++; - cnt.v_vforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + mycpu->gd_cnt.v_vforks++; + mycpu->gd_cnt.v_vforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; } else if (p1 == &proc0) { - cnt.v_kthreads++; - cnt.v_kthreadpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + mycpu->gd_cnt.v_kthreads++; + mycpu->gd_cnt.v_kthreadpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; } else { - cnt.v_rforks++; - cnt.v_rforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + mycpu->gd_cnt.v_rforks++; + mycpu->gd_cnt.v_rforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; } /* diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 3e1b06b6b7..f4a7a07513 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -32,7 +32,7 @@ * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 * $FreeBSD: src/sys/kern/kern_malloc.c,v 1.64.2.5 2002/03/16 02:19:51 archie Exp $ - * $DragonFly: src/sys/kern/Attic/kern_malloc.c,v 1.4 2003/06/29 03:28:44 dillon Exp $ + * $DragonFly: src/sys/kern/Attic/kern_malloc.c,v 1.5 2003/07/03 17:24:02 dillon Exp $ */ #include "opt_vm.h" @@ -505,7 +505,7 @@ kmeminit(dummy) * so make sure that there is enough space. */ vm_kmem_size = VM_KMEM_SIZE; - mem_size = cnt.v_page_count * PAGE_SIZE; + mem_size = vmstats.v_page_count * PAGE_SIZE; #if defined(VM_KMEM_SIZE_SCALE) if ((mem_size / VM_KMEM_SIZE_SCALE) > vm_kmem_size) @@ -526,8 +526,8 @@ kmeminit(dummy) * to something sane. Be careful to not overflow the 32bit * ints while doing the check. */ - if ((vm_kmem_size / 2) > (cnt.v_page_count * PAGE_SIZE)) - vm_kmem_size = 2 * cnt.v_page_count * PAGE_SIZE; + if ((vm_kmem_size / 2) > (vmstats.v_page_count * PAGE_SIZE)) + vm_kmem_size = 2 * vmstats.v_page_count * PAGE_SIZE; npg = (nmbufs * MSIZE + nmbclusters * MCLBYTES + vm_kmem_size) / PAGE_SIZE; @@ -558,7 +558,7 @@ malloc_init(data) if (type->ks_limit != 0) return; - if (cnt.v_page_count == 0) + if (vmstats.v_page_count == 0) panic("malloc_init not allowed before vm init"); /* @@ -586,7 +586,7 @@ malloc_uninit(data) if (type->ks_magic != M_MAGIC) panic("malloc type lacks magic"); - if (cnt.v_page_count == 0) + if (vmstats.v_page_count == 0) panic("malloc_uninit not allowed before vm init"); if (type->ks_limit == 0) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index edbcdd8dd9..4163cbd646 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -37,7 +37,7 @@ * * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 * $FreeBSD: src/sys/kern/kern_synch.c,v 1.87.2.6 2002/10/13 07:29:53 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_synch.c,v 1.13 2003/07/01 04:37:46 dillon Exp $ + * $DragonFly: src/sys/kern/kern_synch.c,v 1.14 2003/07/03 17:24:02 dillon Exp $ */ #include "opt_ktrace.h" @@ -877,7 +877,7 @@ mi_switch() * YYY the userland scheduler should pick only one user process * at a time to run per cpu. */ - cnt.v_swtch++; + mycpu->gd_cnt.v_swtch++; lwkt_switch(); splx(x); diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 778615ba55..6b5f37c244 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -12,7 +12,7 @@ * John S. Dyson. * * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.20 2003/05/28 18:38:10 alc Exp $ - * $DragonFly: src/sys/kern/vfs_bio.c,v 1.7 2003/06/27 01:53:25 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_bio.c,v 1.8 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -54,6 +54,7 @@ #include #include #include +#include static MALLOC_DEFINE(M_BIOBUF, "BIO buffer", "BIO buffer"); @@ -426,7 +427,7 @@ bufinit(void) bogus_page = vm_page_alloc(kernel_object, ((bogus_offset - VM_MIN_KERNEL_ADDRESS) >> PAGE_SHIFT), VM_ALLOC_NORMAL); - cnt.v_wire_count++; + vmstats.v_wire_count++; } @@ -2517,8 +2518,8 @@ allocbuf(struct buf *bp, int size) */ if ((curthread != pagethread) && ((m->queue - m->pc) == PQ_CACHE) && - ((cnt.v_free_count + cnt.v_cache_count) < - (cnt.v_free_min + cnt.v_cache_min))) { + ((vmstats.v_free_count + vmstats.v_cache_count) < + (vmstats.v_free_min + vmstats.v_cache_min))) { pagedaemon_wakeup(); } vm_page_flag_clear(m, PG_ZERO); diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index d0522c3c82..9da36017cd 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -34,7 +34,7 @@ * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 * $FreeBSD: src/sys/kern/vfs_cluster.c,v 1.92.2.9 2001/11/18 07:10:59 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.6 2003/06/26 20:27:51 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.7 2003/07/03 17:24:02 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -54,6 +54,7 @@ #include #include #include +#include #if defined(CLUSTERDEBUG) #include diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ec02f91a37..dca63a6345 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -37,7 +37,7 @@ * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 * $FreeBSD: src/sys/kern/vfs_subr.c,v 1.249.2.30 2003/04/04 20:35:57 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_subr.c,v 1.8 2003/06/27 01:53:25 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_subr.c,v 1.9 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -179,7 +179,7 @@ void vntblinit() { - desiredvnodes = maxproc + cnt.v_page_count / 4; + desiredvnodes = maxproc + vmstats.v_page_count / 4; minvnodes = desiredvnodes / 4; simple_lock_init(&mntvnode_slock); simple_lock_init(&mntid_slock); @@ -474,7 +474,7 @@ vlrureclaim(struct mount *mp) usevnodes = desiredvnodes; if (usevnodes <= 0) usevnodes = 1; - trigger = cnt.v_page_count * 2 / usevnodes; + trigger = vmstats.v_page_count * 2 / usevnodes; done = 0; simple_lock(&mntvnode_slock); diff --git a/sys/platform/pc32/i386/exception.s b/sys/platform/pc32/i386/exception.s index 5b2613e499..926a71203f 100644 --- a/sys/platform/pc32/i386/exception.s +++ b/sys/platform/pc32/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.9 2003/07/01 20:30:40 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.10 2003/07/03 17:24:01 dillon Exp $ */ #include "npx.h" @@ -163,14 +163,14 @@ IDTVEC(fpu) mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) movl PCPU(curthread),%ebx /* save original cpl */ movl TD_CPL(%ebx), %ebx pushl %ebx - incl cnt+V_TRAP + incl PCPU(cnt)+V_TRAP call npx_intr /* note: call might mess w/ argument */ @@ -210,12 +210,12 @@ alltraps_with_regs_pushed: mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) calltrap: FAKE_MCOUNT(btrap) /* init "from" _btrap -> calltrap */ - MPLOCKED incl cnt+V_TRAP + incl PCPU(cnt)+V_TRAP /* YYY per-cpu */ MP_LOCK movl PCPU(curthread),%eax /* keep orig cpl here during call */ movl TD_CPL(%eax),%ebx @@ -256,13 +256,13 @@ IDTVEC(syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */ movl %eax,TF_EFLAGS(%esp) movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */ FAKE_MCOUNT(13*4(%esp)) - MPLOCKED incl cnt+V_SYSCALL + incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ call syscall2 MEXITCOUNT cli /* atomic astpending access */ @@ -295,11 +295,11 @@ IDTVEC(int0x80_syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - movl $KPSEL,%eax + mov $KPSEL,%ax mov %ax,%fs movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) - MPLOCKED incl cnt+V_SYSCALL + incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ call syscall2 MEXITCOUNT cli /* atomic astpending access */ diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index a27faf135c..d7fb5340ac 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.18 2003/06/29 03:28:42 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.19 2003/07/03 17:24:01 dillon Exp $ */ #include "opt_user_ldt.h" @@ -185,6 +185,7 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread)); ASSYM(GD_REQPRI, offsetof(struct mdglobaldata, mi.gd_reqpri)); ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid)); +ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt)); ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level)); ASSYM(GD_ASTPENDING, offsetof(struct mdglobaldata, mi.gd_astpending)); diff --git a/sys/platform/pc32/i386/globals.s b/sys/platform/pc32/i386/globals.s index 3df3dce417..a584218899 100644 --- a/sys/platform/pc32/i386/globals.s +++ b/sys/platform/pc32/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.13 2003/07/01 20:30:40 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.14 2003/07/03 17:24:01 dillon Exp $ */ #include "opt_user_ldt.h" @@ -84,7 +84,7 @@ .globl gd_ss_eflags, gd_intr_nesting_level .globl gd_CMAP1, gd_CMAP2, gd_CMAP3, gd_PMAP1 .globl gd_CADDR1, gd_CADDR2, gd_CADDR3, gd_PADDR1 - .globl gd_irunning, gd_ipending, gd_fpending + .globl gd_irunning, gd_ipending, gd_fpending, gd_cnt .set gd_cpuid,globaldata + GD_CPUID .set gd_cpu_lockid,globaldata + GD_CPU_LOCKID @@ -102,6 +102,7 @@ .set gd_fpending,globaldata + GD_FPENDING .set gd_ipending,globaldata + GD_IPENDING .set gd_irunning,globaldata + GD_IRUNNING + .set gd_cnt,globaldata + GD_CNT #if defined(APIC_IO) .globl lapic_eoi, lapic_svr, lapic_tpr, lapic_irr1, lapic_ver diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index a93192850e..ffec285e6e 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.19 2003/06/30 23:54:00 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.20 2003/07/03 17:24:01 dillon Exp $ */ #include "apm.h" @@ -175,7 +175,7 @@ static int sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) { int error = sysctl_handle_int(oidp, 0, - ctob(physmem - cnt.v_wire_count), req); + ctob(physmem - vmstats.v_wire_count), req); return (error); } @@ -435,8 +435,8 @@ again: cninit(); /* the preferred console may have changed */ #endif - printf("avail memory = %u (%uK bytes)\n", ptoa(cnt.v_free_count), - ptoa(cnt.v_free_count) / 1024); + printf("avail memory = %u (%uK bytes)\n", ptoa(vmstats.v_free_count), + ptoa(vmstats.v_free_count) / 1024); /* * Set up buffers, so they can be used to read disk labels. @@ -2066,6 +2066,13 @@ cpu_gdinit(struct mdglobaldata *gd, int cpu) *(void **)gd->gd_idlethread.td_sp = cpu_idle_restore; } +struct globaldata * +globaldata_find(int cpu) +{ + KKASSERT(cpu >= 0 && cpu < ncpus); + return(&CPU_prvspace[cpu].mdglobaldata.mi); +} + #if defined(I586_CPU) && !defined(NO_F00F_HACK) static void f00f_hack(void *unused); SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL); diff --git a/sys/platform/pc32/i386/pmap.c b/sys/platform/pc32/i386/pmap.c index 1f86acb222..8f9aa4448e 100644 --- a/sys/platform/pc32/i386/pmap.c +++ b/sys/platform/pc32/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.13 2003/06/28 04:16:02 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.14 2003/07/03 17:24:01 dillon Exp $ */ /* @@ -953,7 +953,7 @@ _pmap_unwire_pte_hold(pmap_t pmap, vm_page_t m) { vm_page_flash(m); vm_page_busy(m); vm_page_free_zero(m); - --cnt.v_wire_count; + --vmstats.v_wire_count; } return 1; } @@ -1043,7 +1043,7 @@ pmap_pinit(pmap) VM_ALLOC_NORMAL | VM_ALLOC_RETRY); ptdpg->wire_count = 1; - ++cnt.v_wire_count; + ++vmstats.v_wire_count; vm_page_flag_clear(ptdpg, PG_MAPPED | PG_BUSY); /* not usually mapped*/ @@ -1120,7 +1120,7 @@ pmap_release_free_page(pmap, p) pmap->pm_ptphint = NULL; p->wire_count--; - cnt.v_wire_count--; + vmstats.v_wire_count--; vm_page_free_zero(p); return 1; } @@ -1147,7 +1147,7 @@ _pmap_allocpte(pmap, ptepindex) ("_pmap_allocpte: %p->queue != PQ_NONE", m)); if (m->wire_count == 0) - cnt.v_wire_count++; + vmstats.v_wire_count++; m->wire_count++; /* @@ -2305,7 +2305,7 @@ retry: * free pages allocating pv entries. */ if ((limit & MAP_PREFAULT_MADVISE) && - cnt.v_free_count < cnt.v_free_reserved) { + vmstats.v_free_count < vmstats.v_free_reserved) { break; } if (((p->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) && @@ -2331,7 +2331,7 @@ retry: * free pages allocating pv entries. */ if ((limit & MAP_PREFAULT_MADVISE) && - cnt.v_free_count < cnt.v_free_reserved) { + vmstats.v_free_count < vmstats.v_free_reserved) { break; } p = vm_page_lookup(object, tmpidx + pindex); @@ -2533,7 +2533,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * way below the low water mark of free pages or way * above high water mark of used pv entries. */ - if (cnt.v_free_count < cnt.v_free_reserved || + if (vmstats.v_free_count < vmstats.v_free_reserved || pv_entry_count > pv_entry_high_water) break; diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index 89f41b7774..fc5ae3f2ab 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.15 2003/07/03 01:58:25 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.16 2003/07/03 17:24:01 dillon Exp $ */ /* @@ -434,7 +434,7 @@ restart: case T_ASTFLT: /* Allow process switch */ astoff(); - cnt.v_soft++; + mycpu->gd_cnt.v_soft++; if (p->p_flag & P_OWEUPC) { p->p_flag &= ~P_OWEUPC; addupc_task(p, p->p_stats->p_prof.pr_addr, diff --git a/sys/platform/pc32/i386/vm_machdep.c b/sys/platform/pc32/i386/vm_machdep.c index 3dee221cdd..1cf91febc9 100644 --- a/sys/platform/pc32/i386/vm_machdep.c +++ b/sys/platform/pc32/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.15 2003/06/30 19:50:30 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.16 2003/07/03 17:24:01 dillon Exp $ */ #include "npx.h" @@ -294,7 +294,7 @@ cpu_proc_exit(void) reset_dbregs(); pcb->pcb_flags &= ~PCB_DBREGS; } - cnt.v_swtch++; + mycpu->gd_cnt.v_swtch++; crit_enter(); lwkt_deschedule_self(); @@ -560,9 +560,9 @@ vm_page_zero_idle() * pages because doing so may flush our L1 and L2 caches too much. */ - if (zero_state && vm_page_zero_count >= ZIDLE_LO(cnt.v_free_count)) + if (zero_state && vm_page_zero_count >= ZIDLE_LO(vmstats.v_free_count)) return(0); - if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count)) + if (vm_page_zero_count >= ZIDLE_HI(vmstats.v_free_count)) return(0); #ifdef SMP @@ -586,7 +586,7 @@ vm_page_zero_idle() pageq); ++vm_page_zero_count; ++cnt_prezero; - if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count)) + if (vm_page_zero_count >= ZIDLE_HI(vmstats.v_free_count)) zero_state = 1; } free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK; diff --git a/sys/platform/pc32/icu/icu_vector.s b/sys/platform/pc32/icu/icu_vector.s index 246c57b681..1ae6212c11 100644 --- a/sys/platform/pc32/icu/icu_vector.s +++ b/sys/platform/pc32/icu/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.10 2003/07/01 20:31:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.11 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -140,7 +140,7 @@ IDTVEC(vec_name) ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -171,7 +171,7 @@ IDTVEC(vec_name) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4, %esp ; \ - incl cnt+V_INTR ; \ + incl PCPU(cnt)+V_INTR ; \ movl intr_countp + (irq_num) * 4, %eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -238,7 +238,7 @@ IDTVEC(vec_name) ; \ call sched_ithd ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ 5: ; \ diff --git a/sys/platform/pc32/isa/icu_vector.s b/sys/platform/pc32/isa/icu_vector.s index 9af5787ea3..a5a6a3f8e5 100644 --- a/sys/platform/pc32/isa/icu_vector.s +++ b/sys/platform/pc32/isa/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.10 2003/07/01 20:31:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.11 2003/07/03 17:24:02 dillon Exp $ */ /* @@ -140,7 +140,7 @@ IDTVEC(vec_name) ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -171,7 +171,7 @@ IDTVEC(vec_name) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; \ addl $4, %esp ; \ - incl cnt+V_INTR ; \ + incl PCPU(cnt)+V_INTR ; \ movl intr_countp + (irq_num) * 4, %eax ; \ incl (%eax) ; \ UNMASK_IRQ(icu, irq_num) ; \ @@ -238,7 +238,7 @@ IDTVEC(vec_name) ; \ call sched_ithd ; \ addl $4,%esp ; \ subl $TDPRI_CRIT,TD_PRI(%ebx) ; \ - incl cnt+V_INTR ; /* book-keeping YYY make per-cpu */ \ + incl PCPU(cnt)+V_INTR ; /* book-keeping YYY make per-cpu */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ 5: ; \ diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 64c9404606..165eb3f44a 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.18 2003/06/29 03:28:42 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.19 2003/07/03 17:24:01 dillon Exp $ */ #include "opt_user_ldt.h" @@ -185,6 +185,7 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread)); ASSYM(GD_REQPRI, offsetof(struct mdglobaldata, mi.gd_reqpri)); ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid)); +ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt)); ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level)); ASSYM(GD_ASTPENDING, offsetof(struct mdglobaldata, mi.gd_astpending)); diff --git a/sys/sys/globaldata.h b/sys/sys/globaldata.h index 18be29159d..5a3f533fc7 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.5 2003/06/30 23:54:04 dillon Exp $ + * $DragonFly: src/sys/sys/globaldata.h,v 1.6 2003/07/03 17:24:03 dillon Exp $ */ #ifndef _SYS_GLOBALDATA_H_ @@ -59,6 +59,9 @@ #ifndef _SYS_TIME_H_ #include /* struct timeval */ #endif +#ifndef _SYS_VMMETER_H_ +#include +#endif _SYS_VMMETER_H_ struct privatespace; @@ -77,7 +80,12 @@ struct globaldata { int gd_intr_nesting_level; /* (for fast interrupts) */ int gd_astpending; /* sorta MD but easier here */ int gd_uprocscheduled; + struct vmmeter gd_cnt; /* extended by */ }; +#ifdef _KERNEL +struct globaldata *globaldata_find(int cpu); +#endif + #endif diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index 65e322cbe6..2562470f65 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -32,7 +32,7 @@ * * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 * $FreeBSD: src/sys/sys/vmmeter.h,v 1.21.2.2 2002/10/10 19:28:21 dillon Exp $ - * $DragonFly: src/sys/sys/vmmeter.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/sys/vmmeter.h,v 1.3 2003/07/03 17:24:03 dillon Exp $ */ #ifndef _SYS_VMMETER_H_ @@ -74,6 +74,22 @@ struct vmmeter { u_int v_dfree; /* pages freed by daemon */ u_int v_pfree; /* pages freed by exiting processes */ u_int v_tfree; /* total pages freed */ + /* + * Fork/vfork/rfork activity. + */ + u_int v_forks; /* number of fork() calls */ + u_int v_vforks; /* number of vfork() calls */ + u_int v_rforks; /* number of rfork() calls */ + u_int v_kthreads; /* number of fork() calls by kernel */ + u_int v_forkpages; /* number of VM pages affected by fork() */ + u_int v_vforkpages; /* number of VM pages affected by vfork() */ + u_int v_rforkpages; /* number of VM pages affected by rfork() */ + u_int v_kthreadpages; /* number of VM pages affected by fork() by kernel */ + u_int v_intrans_coll; /* intransit map collisions (total) */ + u_int v_intrans_wait; /* intransit map collisions which blocked */ +}; + +struct vmstats { /* * Distribution of page usages. */ @@ -93,106 +109,12 @@ struct vmmeter { u_int v_pageout_free_min; /* min number pages reserved for kernel */ u_int v_interrupt_free_min; /* reserved number of pages for int code */ u_int v_free_severe; /* severe depletion of pages below this pt */ - /* - * Fork/vfork/rfork activity. - */ - u_int v_forks; /* number of fork() calls */ - u_int v_vforks; /* number of vfork() calls */ - u_int v_rforks; /* number of rfork() calls */ - u_int v_kthreads; /* number of fork() calls by kernel */ - u_int v_forkpages; /* number of VM pages affected by fork() */ - u_int v_vforkpages; /* number of VM pages affected by vfork() */ - u_int v_rforkpages; /* number of VM pages affected by rfork() */ - u_int v_kthreadpages; /* number of VM pages affected by fork() by kernel */ - u_int v_intrans_coll; /* intransit map collisions (total) */ - u_int v_intrans_wait; /* intransit map collisions which blocked */ }; -#ifdef _KERNEL - -extern struct vmmeter cnt; - -/* - * Return TRUE if we are under our reserved low-free-pages threshold - */ - -static __inline -int -vm_page_count_reserved(void) -{ - return (cnt.v_free_reserved > (cnt.v_free_count + cnt.v_cache_count)); -} - -/* - * Return TRUE if we are under our severe low-free-pages threshold - * - * This routine is typically used at the user<->system interface to determine - * whether we need to block in order to avoid a low memory deadlock. - */ - -static __inline -int -vm_page_count_severe(void) -{ - return (cnt.v_free_severe > (cnt.v_free_count + cnt.v_cache_count)); -} - -/* - * Return TRUE if we are under our minimum low-free-pages threshold. - * - * This routine is typically used within the system to determine whether - * we can execute potentially very expensive code in terms of memory. It - * is also used by the pageout daemon to calculate when to sleep, when - * to wake waiters up, and when (after making a pass) to become more - * desparate. - */ - -static __inline -int -vm_page_count_min(void) -{ - return (cnt.v_free_min > (cnt.v_free_count + cnt.v_cache_count)); -} - -/* - * Return TRUE if we have not reached our free page target during - * free page recovery operations. - */ - -static __inline -int -vm_page_count_target(void) -{ - return (cnt.v_free_target > (cnt.v_free_count + cnt.v_cache_count)); -} - -/* - * Return the number of pages we need to free-up or cache - * A positive number indicates that we do not have enough free pages. - */ - -static __inline -int -vm_paging_target(void) -{ - return ( - (cnt.v_free_target + cnt.v_cache_min) - - (cnt.v_free_count + cnt.v_cache_count) - ); -} -/* - * Return a positive number if the pagedaemon needs to be woken up. - */ +#ifdef _KERNEL -static __inline -int -vm_paging_needed(void) -{ - return ( - (cnt.v_free_reserved + cnt.v_cache_min) > - (cnt.v_free_count + cnt.v_cache_count) - ); -} +/* note: vmmeter 'cnt' structure is now per-cpu */ +extern struct vmstats vmstats; #endif @@ -215,10 +137,10 @@ struct vmtotal int32_t t_free; /* free memory pages */ }; +#ifdef PGINPROF /* * Optional instrumentation. */ -#ifdef PGINPROF #define NDMON 128 #define NSMON 128 @@ -251,6 +173,6 @@ int rres; u_int rectime; /* accumulator for reclaim times */ u_int pgintime; /* accumulator for page in times */ -#endif +#endif /* PGINPROF */ #endif diff --git a/sys/vfs/specfs/spec_vnops.c b/sys/vfs/specfs/spec_vnops.c index 3f297b5604..a9a89e5670 100644 --- a/sys/vfs/specfs/spec_vnops.c +++ b/sys/vfs/specfs/spec_vnops.c @@ -32,7 +32,7 @@ * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 * $FreeBSD: src/sys/miscfs/specfs/spec_vnops.c,v 1.131.2.4 2001/02/26 04:23:20 jlemon Exp $ - * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.8 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.9 2003/07/03 17:24:03 dillon Exp $ */ #include @@ -713,8 +713,8 @@ spec_getpages(ap) bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; - cnt.v_vnodein++; - cnt.v_vnodepgsin += pcount; + mycpu->gd_cnt.v_vnodein++; + mycpu->gd_cnt.v_vnodepgsin += pcount; /* Do the input. */ VOP_STRATEGY(bp->b_vp, bp); diff --git a/sys/vfs/ufs/ffs_inode.c b/sys/vfs/ufs/ffs_inode.c index 734524b307..6aa201a612 100644 --- a/sys/vfs/ufs/ffs_inode.c +++ b/sys/vfs/ufs/ffs_inode.c @@ -32,7 +32,7 @@ * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 * $FreeBSD: src/sys/ufs/ffs/ffs_inode.c,v 1.56.2.5 2002/02/05 18:35:03 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.5 2003/06/26 20:27:52 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.6 2003/07/03 17:24:03 dillon Exp $ */ #include "opt_quota.h" @@ -59,6 +59,8 @@ #include #include +#include + static int ffs_indirtrunc __P((struct inode *, ufs_daddr_t, ufs_daddr_t, ufs_daddr_t, int, long *)); diff --git a/sys/vfs/ufs/ufs_readwrite.c b/sys/vfs/ufs/ufs_readwrite.c index aac5466764..66afd8693b 100644 --- a/sys/vfs/ufs/ufs_readwrite.c +++ b/sys/vfs/ufs/ufs_readwrite.c @@ -32,7 +32,7 @@ * * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 * $FreeBSD: src/sys/ufs/ufs/ufs_readwrite.c,v 1.65.2.14 2003/04/04 22:21:29 tegge Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_readwrite.c,v 1.6 2003/06/26 19:24:50 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_readwrite.c,v 1.7 2003/07/03 17:24:04 dillon Exp $ */ #define BLKSIZE(a, b, c) blksize(a, b, c) @@ -46,6 +46,8 @@ #include #include #include +#include + #include "opt_directio.h" #define VN_KNOTE(vp, b) \ diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 90e6eae58b..4f0f2e3502 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -65,7 +65,7 @@ * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 * * $FreeBSD: src/sys/vm/swap_pager.c,v 1.130.2.12 2002/08/31 21:15:55 dillon Exp $ - * $DragonFly: src/sys/vm/swap_pager.c,v 1.6 2003/06/26 05:55:21 dillon Exp $ + * $DragonFly: src/sys/vm/swap_pager.c,v 1.7 2003/07/03 17:24:04 dillon Exp $ */ #include @@ -99,6 +99,7 @@ #include #include +#include #define SWM_FREE 0x02 /* free, period */ #define SWM_POP 0x04 /* pop out */ @@ -306,7 +307,7 @@ swap_pager_swap_init() * can hold 16 pages, so this is probably overkill. This reservation * is typically limited to around 32MB by default. */ - n = cnt.v_page_count / 2; + n = vmstats.v_page_count / 2; if (maxswzone && n > maxswzone / sizeof(struct swblock)) n = maxswzone / sizeof(struct swblock); n2 = n; @@ -920,11 +921,11 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) ) { splx(s); if (bp->b_flags & B_READ) { - ++cnt.v_swapin; - cnt.v_swappgsin += btoc(nbp->b_bcount); + ++mycpu->gd_cnt.v_swapin; + mycpu->gd_cnt.v_swappgsin += btoc(nbp->b_bcount); } else { - ++cnt.v_swapout; - cnt.v_swappgsout += btoc(nbp->b_bcount); + ++mycpu->gd_cnt.v_swapout; + mycpu->gd_cnt.v_swappgsout += btoc(nbp->b_bcount); nbp->b_dirtyend = nbp->b_bcount; } flushchainbuf(nbp); @@ -969,11 +970,11 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) if ((bp->b_flags & B_ASYNC) == 0) nbp->b_flags &= ~B_ASYNC; if (nbp->b_flags & B_READ) { - ++cnt.v_swapin; - cnt.v_swappgsin += btoc(nbp->b_bcount); + ++mycpu->gd_cnt.v_swapin; + mycpu->gd_cnt.v_swappgsin += btoc(nbp->b_bcount); } else { - ++cnt.v_swapout; - cnt.v_swappgsout += btoc(nbp->b_bcount); + ++mycpu->gd_cnt.v_swapout; + mycpu->gd_cnt.v_swappgsout += btoc(nbp->b_bcount); nbp->b_dirtyend = nbp->b_bcount; } flushchainbuf(nbp); @@ -1128,8 +1129,8 @@ swap_pager_getpages(object, m, count, reqpage) pbgetvp(swapdev_vp, bp); - cnt.v_swapin++; - cnt.v_swappgsin += bp->b_npages; + mycpu->gd_cnt.v_swapin++; + mycpu->gd_cnt.v_swappgsin += bp->b_npages; /* * We still hold the lock on mreq, and our automatic completion routine @@ -1164,7 +1165,7 @@ swap_pager_getpages(object, m, count, reqpage) while ((mreq->flags & PG_SWAPINPROG) != 0) { vm_page_flag_set(mreq, PG_WANTED | PG_REFERENCED); - cnt.v_intrans++; + mycpu->gd_cnt.v_intrans++; if (tsleep(mreq, PSWP, "swread", hz*20)) { printf( "swap_pager: indefinite wait buffer: device:" @@ -1384,8 +1385,8 @@ swap_pager_putpages(object, m, count, sync, rtvals) bp->b_dirtyoff = 0; bp->b_dirtyend = bp->b_bcount; - cnt.v_swapout++; - cnt.v_swappgsout += bp->b_npages; + mycpu->gd_cnt.v_swapout++; + mycpu->gd_cnt.v_swappgsout += bp->b_npages; swapdev_vp->v_numoutput++; splx(s); diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 2497c4755f..1c572b4af7 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -67,7 +67,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_fault.c,v 1.108.2.8 2002/02/26 05:49:27 silby Exp $ - * $DragonFly: src/sys/vm/vm_fault.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ + * $DragonFly: src/sys/vm/vm_fault.c,v 1.4 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -93,6 +93,7 @@ #include #include #include +#include static int vm_fault_additional_pages __P((vm_page_t, int, int, vm_page_t *, int *)); @@ -194,7 +195,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags) int faultcount; struct faultstate fs; - cnt.v_vm_faults++; /* needs lock XXX */ + mycpu->gd_cnt.v_vm_faults++; hardfault = 0; RetryFault:; @@ -312,7 +313,7 @@ RetryFault:; if ((fs.m->flags & PG_BUSY) || fs.m->busy) { unlock_things(&fs); (void)vm_page_sleep_busy(fs.m, TRUE, "vmpfw"); - cnt.v_intrans++; + mycpu->gd_cnt.v_intrans++; vm_object_deallocate(fs.first_object); goto RetryFault; } @@ -576,9 +577,9 @@ readrest: if ((fs.m->flags & PG_ZERO) == 0) { vm_page_zero_fill(fs.m); } else { - cnt.v_ozfod++; + mycpu->gd_cnt.v_ozfod++; } - cnt.v_zfod++; + mycpu->gd_cnt.v_zfod++; fs.m->valid = VM_PAGE_BITS_ALL; break; /* break to PAGE HAS BEEN FOUND */ } else { @@ -668,7 +669,7 @@ readrest: fs.first_m = fs.m; vm_page_busy(fs.first_m); fs.m = NULL; - cnt.v_cow_optim++; + mycpu->gd_cnt.v_cow_optim++; } else { /* * Oh, well, lets copy it. @@ -694,7 +695,7 @@ readrest: * Only use the new page below... */ - cnt.v_cow_faults++; + mycpu->gd_cnt.v_cow_faults++; fs.m = fs.first_m; fs.object = fs.first_object; fs.pindex = fs.first_pindex; @@ -1166,7 +1167,7 @@ vm_fault_additional_pages(m, rbehind, rahead, marray, reqpage) * try to do any readahead that we might have free pages for. */ if ((rahead + rbehind) > - ((cnt.v_free_count + cnt.v_cache_count) - cnt.v_free_reserved)) { + ((vmstats.v_free_count + vmstats.v_cache_count) - vmstats.v_free_reserved)) { pagedaemon_wakeup(); marray[0] = m; *reqpage = 0; diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index dc3f634575..868ddb39a5 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -60,7 +60,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_glue.c,v 1.94.2.4 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_glue.c,v 1.9 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/vm/vm_glue.c,v 1.10 2003/07/03 17:24:04 dillon Exp $ */ #include "opt_vm.h" @@ -90,6 +90,7 @@ #include #include +#include /* * System initialization @@ -313,7 +314,7 @@ vm_init_limits(udata) p->p_rlimit[RLIMIT_DATA].rlim_cur = dfldsiz; p->p_rlimit[RLIMIT_DATA].rlim_max = maxdsiz; /* limit the limit to no less than 2MB */ - rss_limit = max(cnt.v_free_count, 512); + rss_limit = max(vmstats.v_free_count, 512); p->p_rlimit[RLIMIT_RSS].rlim_cur = ptoa(rss_limit); p->p_rlimit[RLIMIT_RSS].rlim_max = RLIM_INFINITY; } diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 8e01abfb4f..abc2a3cc63 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_map.c,v 1.187.2.19 2003/05/27 00:47:02 alc Exp $ - * $DragonFly: src/sys/vm/vm_map.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ + * $DragonFly: src/sys/vm/vm_map.c,v 1.4 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -188,7 +188,7 @@ void vm_init2(void) { zinitna(kmapentzone, &kmapentobj, NULL, 0, lmin((VM_MAX_KERNEL_ADDRESS - KERNBASE) / PAGE_SIZE, - cnt.v_page_count) / 8, ZONE_INTERRUPT, 1); + vmstats.v_page_count) / 8, ZONE_INTERRUPT, 1); zinitna(mapentzone, &mapentobj, NULL, 0, 0, 0, 1); zinitna(mapzone, &mapobj, @@ -779,7 +779,7 @@ vm_map_simplify_entry(map, entry) vm_size_t prevsize, esize; if (entry->eflags & (MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_IS_SUB_MAP)) { - ++cnt.v_intrans_coll; + ++mycpu->gd_cnt.v_intrans_coll; return; } @@ -1050,8 +1050,8 @@ again: entry = start_entry; if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { entry->eflags |= MAP_ENTRY_NEEDS_WAKEUP; - ++cnt.v_intrans_coll; - ++cnt.v_intrans_wait; + ++mycpu->gd_cnt.v_intrans_coll; + ++mycpu->gd_cnt.v_intrans_wait; vm_map_transition_wait(map); /* * entry and/or start_entry may have been clipped while @@ -1089,8 +1089,8 @@ again: if (next->eflags & MAP_ENTRY_IN_TRANSITION) { vm_offset_t save_end = entry->end; next->eflags |= MAP_ENTRY_NEEDS_WAKEUP; - ++cnt.v_intrans_coll; - ++cnt.v_intrans_wait; + ++mycpu->gd_cnt.v_intrans_coll; + ++mycpu->gd_cnt.v_intrans_wait; vm_map_transition_wait(map); /* @@ -2121,8 +2121,8 @@ again: if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { entry->eflags |= MAP_ENTRY_NEEDS_WAKEUP; start = entry->start; - ++cnt.v_intrans_coll; - ++cnt.v_intrans_wait; + ++mycpu->gd_cnt.v_intrans_coll; + ++mycpu->gd_cnt.v_intrans_wait; vm_map_transition_wait(map); goto again; } diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index e0a4391827..da596bee64 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -32,7 +32,7 @@ * * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 * $FreeBSD: src/sys/vm/vm_meter.c,v 1.34.2.7 2002/10/10 19:28:22 dillon Exp $ - * $DragonFly: src/sys/vm/vm_meter.c,v 1.3 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/vm/vm_meter.c,v 1.4 2003/07/03 17:24:04 dillon Exp $ */ #include @@ -52,30 +52,26 @@ #include #include -struct vmmeter cnt; +struct vmstats vmstats; static int maxslp = MAXSLP; SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min, - CTLFLAG_RW, &cnt.v_free_min, 0, ""); + CTLFLAG_RW, &vmstats.v_free_min, 0, ""); SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target, - CTLFLAG_RW, &cnt.v_free_target, 0, ""); + CTLFLAG_RW, &vmstats.v_free_target, 0, ""); SYSCTL_UINT(_vm, VM_V_FREE_RESERVED, v_free_reserved, - CTLFLAG_RW, &cnt.v_free_reserved, 0, ""); + CTLFLAG_RW, &vmstats.v_free_reserved, 0, ""); SYSCTL_UINT(_vm, VM_V_INACTIVE_TARGET, v_inactive_target, - CTLFLAG_RW, &cnt.v_inactive_target, 0, ""); + CTLFLAG_RW, &vmstats.v_inactive_target, 0, ""); SYSCTL_UINT(_vm, VM_V_CACHE_MIN, v_cache_min, - CTLFLAG_RW, &cnt.v_cache_min, 0, ""); + CTLFLAG_RW, &vmstats.v_cache_min, 0, ""); SYSCTL_UINT(_vm, VM_V_CACHE_MAX, v_cache_max, - CTLFLAG_RW, &cnt.v_cache_max, 0, ""); + CTLFLAG_RW, &vmstats.v_cache_max, 0, ""); SYSCTL_UINT(_vm, VM_V_PAGEOUT_FREE_MIN, v_pageout_free_min, - CTLFLAG_RW, &cnt.v_pageout_free_min, 0, ""); + CTLFLAG_RW, &vmstats.v_pageout_free_min, 0, ""); SYSCTL_UINT(_vm, OID_AUTO, v_free_severe, - CTLFLAG_RW, &cnt.v_free_severe, 0, ""); -SYSCTL_UINT(_vm, OID_AUTO, v_intrans_coll, - CTLFLAG_RW, &cnt.v_intrans_coll, 0, ""); -SYSCTL_UINT(_vm, OID_AUTO, v_intrans_wait, - CTLFLAG_RW, &cnt.v_intrans_wait, 0, ""); + CTLFLAG_RW, &vmstats.v_free_severe, 0, ""); SYSCTL_STRUCT(_vm, VM_LOADAVG, loadavg, CTLFLAG_RD, &averunnable, loadavg, "Machine loadaverage history"); @@ -175,10 +171,37 @@ vmtotal(SYSCTL_HANDLER_ARGS) } } } - totalp->t_free = cnt.v_free_count + cnt.v_cache_count; + totalp->t_free = vmstats.v_free_count + vmstats.v_cache_count; return (sysctl_handle_opaque(oidp, totalp, sizeof total, req)); } +/* + * vcnt() - accumulate statistics from the cnt structure for each cpu + * + * The vmmeter structure is now per-cpu as well as global. Those + * statistics which can be kept on a per-cpu basis (to avoid cache + * stalls between cpus) can be moved to the per-cpu vmmeter. Remaining + * statistics, such as v_free_reserved, are left in the global + * structure. + * + * (sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req) + */ +static int +vcnt(SYSCTL_HANDLER_ARGS) +{ + int i; + int count = 0; + int offset = (int)arg1; + + for (i = 0; i < ncpus; ++i) { + struct globaldata *gd = globaldata_find(i); + count += *(int *)((char *)&gd->gd_cnt + offset); + } + return(SYSCTL_OUT(req, &count, sizeof(int))); +} + +#define VMMETEROFF(var) (void *)offsetof(struct vmmeter, var) + SYSCTL_PROC(_vm, VM_METER, vmmeter, CTLTYPE_OPAQUE|CTLFLAG_RD, 0, sizeof(struct vmtotal), vmtotal, "S,vmtotal", "System virtual memory statistics"); @@ -186,115 +209,107 @@ SYSCTL_NODE(_vm, OID_AUTO, stats, CTLFLAG_RW, 0, "VM meter stats"); SYSCTL_NODE(_vm_stats, OID_AUTO, sys, CTLFLAG_RW, 0, "VM meter sys stats"); SYSCTL_NODE(_vm_stats, OID_AUTO, vm, CTLFLAG_RW, 0, "VM meter vm stats"); SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW, 0, "VM meter misc stats"); -SYSCTL_UINT(_vm_stats_sys, OID_AUTO, - v_swtch, CTLFLAG_RD, &cnt.v_swtch, 0, "Context switches"); -SYSCTL_UINT(_vm_stats_sys, OID_AUTO, - v_trap, CTLFLAG_RD, &cnt.v_trap, 0, "Traps"); -SYSCTL_UINT(_vm_stats_sys, OID_AUTO, - v_syscall, CTLFLAG_RD, &cnt.v_syscall, 0, "Syscalls"); -SYSCTL_UINT(_vm_stats_sys, OID_AUTO, v_intr, CTLFLAG_RD, - &cnt.v_intr, 0, "Hardware interrupts"); -SYSCTL_UINT(_vm_stats_sys, OID_AUTO, v_soft, CTLFLAG_RD, - &cnt.v_soft, 0, "Software interrupts"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vm_faults, CTLFLAG_RD, &cnt.v_vm_faults, 0, "VM faults"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_cow_faults, CTLFLAG_RD, &cnt.v_cow_faults, 0, "COW faults"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_cow_optim, CTLFLAG_RD, &cnt.v_cow_optim, 0, "Optimized COW faults"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_zfod, CTLFLAG_RD, &cnt.v_zfod, 0, "Zero fill"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_ozfod, CTLFLAG_RD, &cnt.v_ozfod, 0, "Optimized zero fill"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_swapin, CTLFLAG_RD, &cnt.v_swapin, 0, "Swapin operations"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_swapout, CTLFLAG_RD, &cnt.v_swapout, 0, "Swapout operations"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_swappgsin, CTLFLAG_RD, &cnt.v_swappgsin, 0, "Swapin pages"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_swappgsout, CTLFLAG_RD, &cnt.v_swappgsout, 0, "Swapout pages"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vnodein, CTLFLAG_RD, &cnt.v_vnodein, 0, "Vnodein operations"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vnodeout, CTLFLAG_RD, &cnt.v_vnodeout, 0, "Vnodeout operations"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vnodepgsin, CTLFLAG_RD, &cnt.v_vnodepgsin, 0, "Vnodein pages"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vnodepgsout, CTLFLAG_RD, &cnt.v_vnodepgsout, 0, "Vnodeout pages"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_intrans, CTLFLAG_RD, &cnt.v_intrans, 0, "In transit page blocking"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_reactivated, CTLFLAG_RD, &cnt.v_reactivated, 0, "Reactivated pages"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_pdwakeups, CTLFLAG_RD, &cnt.v_pdwakeups, 0, "Pagedaemon wakeups"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_pdpages, CTLFLAG_RD, &cnt.v_pdpages, 0, "Pagedaemon page scans"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_dfree, CTLFLAG_RD, &cnt.v_dfree, 0, ""); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_pfree, CTLFLAG_RD, &cnt.v_pfree, 0, ""); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_tfree, CTLFLAG_RD, &cnt.v_tfree, 0, ""); + +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_swtch, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_swtch), 0, vcnt, "IU", "Context switches"); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intrans_coll, CTLTYPE_UINT|CTLFLAG_RW, + VMMETEROFF(v_intrans_coll), 0, vcnt, "IU", ""); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intrans_wait, CTLTYPE_UINT|CTLFLAG_RW, + VMMETEROFF(v_intrans_wait), 0, vcnt, "IU", ""); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_trap, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_trap), 0, vcnt, "IU", "Traps"); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_syscall, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_syscall), 0, vcnt, "IU", "Syscalls"); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intr, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_intr), 0, vcnt, "IU", "Hardware interrupts"); +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_soft, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_soft), 0, vcnt, "IU", "Software interrupts"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vm_faults, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vm_faults), 0, vcnt, "IU", "VM faults"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_faults, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_cow_faults), 0, vcnt, "IU", "COW faults"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_optim, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_cow_optim), 0, vcnt, "IU", "Optimized COW faults"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_zfod, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_zfod), 0, vcnt, "IU", "Zero fill"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_ozfod, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_ozfod), 0, vcnt, "IU", "Optimized zero fill"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapin, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_swapin), 0, vcnt, "IU", "Swapin operations"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapout, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_swapout), 0, vcnt, "IU", "Swapout operations"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsin, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_swappgsin), 0, vcnt, "IU", "Swapin pages"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsout, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_swappgsout), 0, vcnt, "IU", "Swapout pages"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodein, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vnodein), 0, vcnt, "IU", "Vnodein operations"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodeout, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vnodeout), 0, vcnt, "IU", "Vnodeout operations"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsin, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vnodepgsin), 0, vcnt, "IU", "Vnodein pages"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsout, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vnodepgsout), 0, vcnt, "IU", "Vnodeout pages"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_intrans, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_intrans), 0, vcnt, "IU", "In transit page blocking"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_reactivated, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_reactivated), 0, vcnt, "IU", "Reactivated pages"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdwakeups, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_pdwakeups), 0, vcnt, "IU", "Pagedaemon wakeups"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_pdpages), 0, vcnt, "IU", "Pagedaemon page scans"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_dfree, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_dfree), 0, vcnt, "IU", ""); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pfree, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_pfree), 0, vcnt, "IU", ""); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tfree, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_tfree), 0, vcnt, "IU", ""); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forks, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_forks), 0, vcnt, "IU", "Number of fork() calls"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforks, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vforks), 0, vcnt, "IU", "Number of vfork() calls"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforks, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_rforks), 0, vcnt, "IU", "Number of rfork() calls"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreads, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_kthreads), 0, vcnt, "IU", "Number of fork() calls by kernel"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forkpages, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_forkpages), 0, vcnt, "IU", "VM pages affected by fork()"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforkpages, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_vforkpages), 0, vcnt, "IU", "VM pages affected by vfork()"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforkpages, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_rforkpages), 0, vcnt, "IU", "VM pages affected by rfork()"); +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreadpages, CTLTYPE_UINT|CTLFLAG_RD, + VMMETEROFF(v_kthreadpages), 0, vcnt, "IU", "VM pages affected by fork() by kernel"); + SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_page_size, CTLFLAG_RD, &cnt.v_page_size, 0, ""); + v_page_size, CTLFLAG_RD, &vmstats.v_page_size, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_page_count, CTLFLAG_RD, &cnt.v_page_count, 0, ""); + v_page_count, CTLFLAG_RD, &vmstats.v_page_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_free_reserved, CTLFLAG_RD, &cnt.v_free_reserved, 0, ""); + v_free_reserved, CTLFLAG_RD, &vmstats.v_free_reserved, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_free_target, CTLFLAG_RD, &cnt.v_free_target, 0, ""); + v_free_target, CTLFLAG_RD, &vmstats.v_free_target, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_free_min, CTLFLAG_RD, &cnt.v_free_min, 0, ""); + v_free_min, CTLFLAG_RD, &vmstats.v_free_min, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_free_count, CTLFLAG_RD, &cnt.v_free_count, 0, ""); + v_free_count, CTLFLAG_RD, &vmstats.v_free_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_wire_count, CTLFLAG_RD, &cnt.v_wire_count, 0, ""); + v_wire_count, CTLFLAG_RD, &vmstats.v_wire_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_active_count, CTLFLAG_RD, &cnt.v_active_count, 0, ""); + v_active_count, CTLFLAG_RD, &vmstats.v_active_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_inactive_target, CTLFLAG_RD, &cnt.v_inactive_target, 0, ""); + v_inactive_target, CTLFLAG_RD, &vmstats.v_inactive_target, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_inactive_count, CTLFLAG_RD, &cnt.v_inactive_count, 0, ""); + v_inactive_count, CTLFLAG_RD, &vmstats.v_inactive_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_cache_count, CTLFLAG_RD, &cnt.v_cache_count, 0, ""); + v_cache_count, CTLFLAG_RD, &vmstats.v_cache_count, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_cache_min, CTLFLAG_RD, &cnt.v_cache_min, 0, ""); + v_cache_min, CTLFLAG_RD, &vmstats.v_cache_min, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_cache_max, CTLFLAG_RD, &cnt.v_cache_max, 0, ""); + v_cache_max, CTLFLAG_RD, &vmstats.v_cache_max, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_pageout_free_min, CTLFLAG_RD, &cnt.v_pageout_free_min, 0, ""); + v_pageout_free_min, CTLFLAG_RD, &vmstats.v_pageout_free_min, 0, ""); SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_interrupt_free_min, CTLFLAG_RD, &cnt.v_interrupt_free_min, 0, ""); + v_interrupt_free_min, CTLFLAG_RD, &vmstats.v_interrupt_free_min, 0, ""); SYSCTL_INT(_vm_stats_misc, OID_AUTO, zero_page_count, CTLFLAG_RD, &vm_page_zero_count, 0, ""); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_forks, CTLFLAG_RD, &cnt.v_forks, 0, "Number of fork() calls"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vforks, CTLFLAG_RD, &cnt.v_vforks, 0, "Number of vfork() calls"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_rforks, CTLFLAG_RD, &cnt.v_rforks, 0, "Number of rfork() calls"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_kthreads, CTLFLAG_RD, &cnt.v_kthreads, 0, "Number of fork() calls by kernel"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_forkpages, CTLFLAG_RD, &cnt.v_forkpages, 0, "VM pages affected by fork()"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_vforkpages, CTLFLAG_RD, &cnt.v_vforkpages, 0, "VM pages affected by vfork()"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_rforkpages, CTLFLAG_RD, &cnt.v_rforkpages, 0, "VM pages affected by rfork()"); -SYSCTL_UINT(_vm_stats_vm, OID_AUTO, - v_kthreadpages, CTLFLAG_RD, &cnt.v_kthreadpages, 0, "VM pages affected by fork() by kernel"); -#if 0 -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - page_mask, CTLFLAG_RD, &page_mask, 0, ""); -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - page_shift, CTLFLAG_RD, &page_shift, 0, ""); -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - first_page, CTLFLAG_RD, &first_page, 0, ""); -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - last_page, CTLFLAG_RD, &last_page, 0, ""); -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - vm_page_bucket_count, CTLFLAG_RD, &vm_page_bucket_count, 0, ""); -SYSCTL_INT(_vm_stats_misc, OID_AUTO, - vm_page_hash_mask, CTLFLAG_RD, &vm_page_hash_mask, 0, ""); -#endif diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 6f143dbabd..8a313e4235 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -39,7 +39,7 @@ * * @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94 * $FreeBSD: src/sys/vm/vm_mmap.c,v 1.108.2.6 2002/07/02 20:06:19 dillon Exp $ - * $DragonFly: src/sys/vm/vm_mmap.c,v 1.5 2003/06/26 05:55:21 dillon Exp $ + * $DragonFly: src/sys/vm/vm_mmap.c,v 1.6 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -889,7 +889,7 @@ mlock(struct mlock_args *uap) if (addr + size < addr) return (EINVAL); - if (atop(size) + cnt.v_wire_count > vm_page_max_wired) + if (atop(size) + vmstats.v_wire_count > vm_page_max_wired) return (EAGAIN); #ifdef pmap_wired_count diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index fc4b1a1fd8..374743c172 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_object.c,v 1.171.2.8 2003/05/26 19:17:56 alc Exp $ - * $DragonFly: src/sys/vm/vm_object.c,v 1.4 2003/06/26 05:55:21 dillon Exp $ + * $DragonFly: src/sys/vm/vm_object.c,v 1.5 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -471,7 +471,7 @@ vm_object_terminate(object) if (p->wire_count == 0) { vm_page_busy(p); vm_page_free(p); - cnt.v_pfree++; + mycpu->gd_cnt.v_pfree++; } else { vm_page_busy(p); vm_page_remove(p); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 6a147f78b6..1d8b7fbd1c 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -35,7 +35,7 @@ * * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91 * $FreeBSD: src/sys/vm/vm_page.c,v 1.147.2.18 2002/03/10 05:03:19 alc Exp $ - * $DragonFly: src/sys/vm/vm_page.c,v 1.5 2003/06/25 03:56:13 dillon Exp $ + * $DragonFly: src/sys/vm/vm_page.c,v 1.6 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -87,6 +87,7 @@ #include #include #include +#include static void vm_page_queue_init (void); static vm_page_t vm_page_select_cache (vm_object_t, vm_pindex_t); @@ -108,14 +109,14 @@ vm_page_queue_init(void) { int i; for(i=0;iphys_addr = pa; m->flags = 0; @@ -308,8 +309,8 @@ vm_page_startup(vm_offset_t starta, vm_offset_t enda, vm_offset_t vaddr) * last rather than first. On large-memory machines, this avoids * the exhaustion of low physical memory before isa_dmainit has run. */ - cnt.v_page_count = 0; - cnt.v_free_count = 0; + vmstats.v_page_count = 0; + vmstats.v_free_count = 0; for (i = 0; phys_avail[i + 1] && npages > 0; i += 2) { pa = phys_avail[i]; if (i == biggestone) @@ -752,7 +753,7 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int page_req) s = splvm(); loop: - if (cnt.v_free_count > cnt.v_free_reserved) { + if (vmstats.v_free_count > vmstats.v_free_reserved) { /* * Allocate from the free queue if there are plenty of pages * in it. @@ -763,9 +764,9 @@ loop: m = vm_page_select_free(object, pindex, FALSE); } else if ( (page_req == VM_ALLOC_SYSTEM && - cnt.v_cache_count == 0 && - cnt.v_free_count > cnt.v_interrupt_free_min) || - (page_req == VM_ALLOC_INTERRUPT && cnt.v_free_count > 0) + vmstats.v_cache_count == 0 && + vmstats.v_free_count > vmstats.v_interrupt_free_min) || + (page_req == VM_ALLOC_INTERRUPT && vmstats.v_free_count > 0) ) { /* * Interrupt or system, dig deeper into the free list. @@ -775,14 +776,14 @@ loop: /* * Allocatable from cache (non-interrupt only). On success, * we must free the page and try again, thus ensuring that - * cnt.v_*_free_min counters are replenished. + * vmstats.v_*_free_min counters are replenished. */ m = vm_page_select_cache(object, pindex); if (m == NULL) { splx(s); #if defined(DIAGNOSTIC) - if (cnt.v_cache_count > 0) - printf("vm_page_alloc(NORMAL): missing pages on cache queue: %d\n", cnt.v_cache_count); + if (vmstats.v_cache_count > 0) + printf("vm_page_alloc(NORMAL): missing pages on cache queue: %d\n", vmstats.v_cache_count); #endif vm_pageout_deficit++; pagedaemon_wakeup(); @@ -877,7 +878,7 @@ vm_wait(void) vm_pages_needed = 1; wakeup(&vm_pages_needed); } - tsleep(&cnt.v_free_count, PVM, "vmwait", 0); + tsleep(&vmstats.v_free_count, PVM, "vmwait", 0); } splx(s); } @@ -903,7 +904,7 @@ vm_waitpfault(void) vm_pages_needed = 1; wakeup(&vm_pages_needed); } - tsleep(&cnt.v_free_count, PUSER, "pfault", 0); + tsleep(&vmstats.v_free_count, PUSER, "pfault", 0); splx(s); } @@ -925,7 +926,7 @@ vm_page_activate(vm_page_t m) s = splvm(); if (m->queue != PQ_ACTIVE) { if ((m->queue - m->pc) == PQ_CACHE) - cnt.v_reactivated++; + mycpu->gd_cnt.v_reactivated++; vm_page_unqueue(m); @@ -935,7 +936,7 @@ vm_page_activate(vm_page_t m) TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); if (m->act_count < ACT_INIT) m->act_count = ACT_INIT; - cnt.v_active_count++; + vmstats.v_active_count++; } } else { if (m->act_count < ACT_INIT) @@ -963,7 +964,7 @@ vm_page_free_wakeup(void) * some free. */ if (vm_pageout_pages_needed && - cnt.v_cache_count + cnt.v_free_count >= cnt.v_pageout_free_min) { + vmstats.v_cache_count + vmstats.v_free_count >= vmstats.v_pageout_free_min) { wakeup(&vm_pageout_pages_needed); vm_pageout_pages_needed = 0; } @@ -974,7 +975,7 @@ vm_page_free_wakeup(void) */ if (vm_pages_needed && !vm_page_count_min()) { vm_pages_needed = 0; - wakeup(&cnt.v_free_count); + wakeup(&vmstats.v_free_count); } } @@ -997,7 +998,7 @@ vm_page_free_toq(vm_page_t m) s = splvm(); - cnt.v_tfree++; + mycpu->gd_cnt.v_tfree++; if (m->busy || ((m->queue - m->pc) == PQ_FREE)) { printf( @@ -1151,7 +1152,7 @@ vm_page_wire(vm_page_t m) if (m->wire_count == 0) { if ((m->flags & PG_UNMANAGED) == 0) vm_page_unqueue(m); - cnt.v_wire_count++; + vmstats.v_wire_count++; } m->wire_count++; KASSERT(m->wire_count != 0, @@ -1199,20 +1200,20 @@ vm_page_unwire(vm_page_t m, int activate) if (m->wire_count > 0) { m->wire_count--; if (m->wire_count == 0) { - cnt.v_wire_count--; + vmstats.v_wire_count--; if (m->flags & PG_UNMANAGED) { ; } else if (activate) { TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); m->queue = PQ_ACTIVE; vm_page_queues[PQ_ACTIVE].lcnt++; - cnt.v_active_count++; + vmstats.v_active_count++; } else { vm_page_flag_clear(m, PG_WINATCFLS); TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); m->queue = PQ_INACTIVE; vm_page_queues[PQ_INACTIVE].lcnt++; - cnt.v_inactive_count++; + vmstats.v_inactive_count++; } } } else { @@ -1246,7 +1247,7 @@ _vm_page_deactivate(vm_page_t m, int athead) s = splvm(); if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) { if ((m->queue - m->pc) == PQ_CACHE) - cnt.v_reactivated++; + mycpu->gd_cnt.v_reactivated++; vm_page_flag_clear(m, PG_WINATCFLS); vm_page_unqueue(m); if (athead) @@ -1255,7 +1256,7 @@ _vm_page_deactivate(vm_page_t m, int athead) TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); m->queue = PQ_INACTIVE; vm_page_queues[PQ_INACTIVE].lcnt++; - cnt.v_inactive_count++; + vmstats.v_inactive_count++; } splx(s); } @@ -1343,7 +1344,7 @@ vm_page_cache(vm_page_t m) m->queue = PQ_CACHE + m->pc; vm_page_queues[m->queue].lcnt++; TAILQ_INSERT_TAIL(&vm_page_queues[m->queue].pl, m, pageq); - cnt.v_cache_count++; + vmstats.v_cache_count++; vm_page_free_wakeup(); splx(s); } @@ -1729,7 +1730,7 @@ again: * Find first page in array that is free, within range, aligned, and * such that the boundary won't be crossed. */ - for (i = start; i < cnt.v_page_count; i++) { + for (i = start; i < vmstats.v_page_count; i++) { int pqtype; phys = VM_PAGE_TO_PHYS(&pga[i]); pqtype = pga[i].queue - pga[i].pc; @@ -1743,7 +1744,7 @@ again: /* * If the above failed or we will exceed the upper bound, fail. */ - if ((i == cnt.v_page_count) || + if ((i == vmstats.v_page_count) || ((VM_PAGE_TO_PHYS(&pga[i]) + size) > high)) { vm_page_t m, next; @@ -1917,16 +1918,16 @@ vm_page_alloc_contig( DB_SHOW_COMMAND(page, vm_page_print_page_info) { - db_printf("cnt.v_free_count: %d\n", cnt.v_free_count); - db_printf("cnt.v_cache_count: %d\n", cnt.v_cache_count); - db_printf("cnt.v_inactive_count: %d\n", cnt.v_inactive_count); - db_printf("cnt.v_active_count: %d\n", cnt.v_active_count); - db_printf("cnt.v_wire_count: %d\n", cnt.v_wire_count); - db_printf("cnt.v_free_reserved: %d\n", cnt.v_free_reserved); - db_printf("cnt.v_free_min: %d\n", cnt.v_free_min); - db_printf("cnt.v_free_target: %d\n", cnt.v_free_target); - db_printf("cnt.v_cache_min: %d\n", cnt.v_cache_min); - db_printf("cnt.v_inactive_target: %d\n", cnt.v_inactive_target); + db_printf("vmstats.v_free_count: %d\n", vmstats.v_free_count); + db_printf("vmstats.v_cache_count: %d\n", vmstats.v_cache_count); + db_printf("vmstats.v_inactive_count: %d\n", vmstats.v_inactive_count); + db_printf("vmstats.v_active_count: %d\n", vmstats.v_active_count); + db_printf("vmstats.v_wire_count: %d\n", vmstats.v_wire_count); + db_printf("vmstats.v_free_reserved: %d\n", vmstats.v_free_reserved); + db_printf("vmstats.v_free_min: %d\n", vmstats.v_free_min); + db_printf("vmstats.v_free_target: %d\n", vmstats.v_free_target); + db_printf("vmstats.v_cache_min: %d\n", vmstats.v_cache_min); + db_printf("vmstats.v_inactive_target: %d\n", vmstats.v_inactive_target); } DB_SHOW_COMMAND(pageq, vm_page_print_pageq_info) diff --git a/sys/vm/vm_page2.h b/sys/vm/vm_page2.h new file mode 100644 index 0000000000..8e5bdbe4ff --- /dev/null +++ b/sys/vm/vm_page2.h @@ -0,0 +1,136 @@ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 + * $FreeBSD: src/sys/sys/vmmeter.h,v 1.21.2.2 2002/10/10 19:28:21 dillon Exp $ + * $DragonFly: src/sys/vm/vm_page2.h,v 1.1 2003/07/03 17:24:04 dillon Exp $ + */ + +#ifndef _VM_VMPAGE2_H_ +#define _VM_VMPAGE2_H_ + +#ifndef _SYS_VMMETER_H_ +#include +#endif + +#ifdef _KERNEL + +/* + * Return TRUE if we are under our reserved low-free-pages threshold + */ + +static __inline +int +vm_page_count_reserved(void) +{ + return (vmstats.v_free_reserved > + (vmstats.v_free_count + vmstats.v_cache_count)); +} + +/* + * Return TRUE if we are under our severe low-free-pages threshold + * + * This routine is typically used at the user<->system interface to determine + * whether we need to block in order to avoid a low memory deadlock. + */ + +static __inline +int +vm_page_count_severe(void) +{ + return (vmstats.v_free_severe > + (vmstats.v_free_count + vmstats.v_cache_count)); +} + +/* + * Return TRUE if we are under our minimum low-free-pages threshold. + * + * This routine is typically used within the system to determine whether + * we can execute potentially very expensive code in terms of memory. It + * is also used by the pageout daemon to calculate when to sleep, when + * to wake waiters up, and when (after making a pass) to become more + * desparate. + */ + +static __inline +int +vm_page_count_min(void) +{ + return (vmstats.v_free_min > + (vmstats.v_free_count + vmstats.v_cache_count)); +} + +/* + * Return TRUE if we have not reached our free page target during + * free page recovery operations. + */ + +static __inline +int +vm_page_count_target(void) +{ + return (vmstats.v_free_target > + (vmstats.v_free_count + vmstats.v_cache_count)); +} + +/* + * Return the number of pages we need to free-up or cache + * A positive number indicates that we do not have enough free pages. + */ + +static __inline +int +vm_paging_target(void) +{ + return ( + (vmstats.v_free_target + vmstats.v_cache_min) - + (vmstats.v_free_count + vmstats.v_cache_count) + ); +} + +/* + * Return a positive number if the pagedaemon needs to be woken up. + */ + +static __inline +int +vm_paging_needed(void) +{ + return ( + (vmstats.v_free_reserved + vmstats.v_cache_min) > + (vmstats.v_free_count + vmstats.v_cache_count) + ); +} + +#endif /* _KERNEL */ +#endif + diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 8652bc2b35..d5ed1bbe1c 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -66,7 +66,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_pageout.c,v 1.151.2.15 2002/12/29 18:21:04 dillon Exp $ - * $DragonFly: src/sys/vm/vm_pageout.c,v 1.4 2003/06/25 03:56:13 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pageout.c,v 1.5 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -95,6 +95,7 @@ #include #include #include +#include /* * System initialization @@ -478,7 +479,7 @@ vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only) if (pmap_resident_count(vm_map_pmap(map)) <= desired) return; next = TAILQ_NEXT(p, listq); - cnt.v_pdpages++; + mycpu->gd_cnt.v_pdpages++; if (p->wire_count != 0 || p->hold_count != 0 || p->busy != 0 || @@ -685,12 +686,12 @@ vm_pageout_scan(int pass) rescan0: addl_page_shortage = addl_page_shortage_init; - maxscan = cnt.v_inactive_count; + maxscan = vmstats.v_inactive_count; for (m = TAILQ_FIRST(&vm_page_queues[PQ_INACTIVE].pl); m != NULL && maxscan-- > 0 && page_shortage > 0; m = next) { - cnt.v_pdpages++; + mycpu->gd_cnt.v_pdpages++; if (m->queue != PQ_INACTIVE) { goto rescan0; @@ -779,7 +780,7 @@ rescan0: */ if (m->valid == 0) { vm_pageout_page_free(m); - cnt.v_dfree++; + mycpu->gd_cnt.v_dfree++; --page_shortage; /* @@ -952,7 +953,7 @@ rescan0: * active queue to the inactive queue. */ page_shortage = vm_paging_target() + - cnt.v_inactive_target - cnt.v_inactive_count; + vmstats.v_inactive_target - vmstats.v_inactive_count; page_shortage += addl_page_shortage; /* @@ -961,7 +962,7 @@ rescan0: * deactivation candidates. */ - pcount = cnt.v_active_count; + pcount = vmstats.v_active_count; m = TAILQ_FIRST(&vm_page_queues[PQ_ACTIVE].pl); while ((m != NULL) && (pcount-- > 0) && (page_shortage > 0)) { @@ -993,7 +994,7 @@ rescan0: * The count for pagedaemon pages is done after checking the * page for eligibility... */ - cnt.v_pdpages++; + mycpu->gd_cnt.v_pdpages++; /* * Check to see "how much" the page has been used. @@ -1059,7 +1060,7 @@ rescan0: * does not effect other calculations. */ - while (cnt.v_free_count < cnt.v_free_reserved) { + while (vmstats.v_free_count < vmstats.v_free_reserved) { static int cache_rover = 0; m = vm_page_list_find(PQ_CACHE, cache_rover, FALSE); if (!m) @@ -1076,7 +1077,7 @@ rescan0: } cache_rover = (cache_rover + PQ_PRIME2) & PQ_L2_MASK; vm_pageout_page_free(m); - cnt.v_dfree++; + mycpu->gd_cnt.v_dfree++; } splx(s); @@ -1155,7 +1156,7 @@ rescan0: bigproc->p_estcpu = 0; bigproc->p_nice = PRIO_MIN; resetpriority(bigproc); - wakeup(&cnt.v_free_count); + wakeup(&vmstats.v_free_count); } } } @@ -1177,18 +1178,18 @@ vm_pageout_page_stats() int s0; page_shortage = - (cnt.v_inactive_target + cnt.v_cache_max + cnt.v_free_min) - - (cnt.v_free_count + cnt.v_inactive_count + cnt.v_cache_count); + (vmstats.v_inactive_target + vmstats.v_cache_max + vmstats.v_free_min) - + (vmstats.v_free_count + vmstats.v_inactive_count + vmstats.v_cache_count); if (page_shortage <= 0) return; s0 = splvm(); - pcount = cnt.v_active_count; + pcount = vmstats.v_active_count; fullintervalcount += vm_pageout_stats_interval; if (fullintervalcount < vm_pageout_full_stats_interval) { - tpcount = (vm_pageout_stats_max * cnt.v_active_count) / cnt.v_page_count; + tpcount = (vm_pageout_stats_max * vmstats.v_active_count) / vmstats.v_page_count; if (pcount > tpcount) pcount = tpcount; } else { @@ -1264,23 +1265,23 @@ static int vm_pageout_free_page_calc(count) vm_size_t count; { - if (count < cnt.v_page_count) + if (count < vmstats.v_page_count) return 0; /* * free_reserved needs to include enough for the largest swap pager * structures plus enough for any pv_entry structs when paging. */ - if (cnt.v_page_count > 1024) - cnt.v_free_min = 4 + (cnt.v_page_count - 1024) / 200; + if (vmstats.v_page_count > 1024) + vmstats.v_free_min = 4 + (vmstats.v_page_count - 1024) / 200; else - cnt.v_free_min = 4; - cnt.v_pageout_free_min = (2*MAXBSIZE)/PAGE_SIZE + - cnt.v_interrupt_free_min; - cnt.v_free_reserved = vm_pageout_page_count + - cnt.v_pageout_free_min + (count / 768) + PQ_L2_SIZE; - cnt.v_free_severe = cnt.v_free_min / 2; - cnt.v_free_min += cnt.v_free_reserved; - cnt.v_free_severe += cnt.v_free_reserved; + vmstats.v_free_min = 4; + vmstats.v_pageout_free_min = (2*MAXBSIZE)/PAGE_SIZE + + vmstats.v_interrupt_free_min; + vmstats.v_free_reserved = vm_pageout_page_count + + vmstats.v_pageout_free_min + (count / 768) + PQ_L2_SIZE; + vmstats.v_free_severe = vmstats.v_free_min / 2; + vmstats.v_free_min += vmstats.v_free_reserved; + vmstats.v_free_severe += vmstats.v_free_reserved; return 1; } @@ -1297,11 +1298,11 @@ vm_pageout() * Initialize some paging parameters. */ - cnt.v_interrupt_free_min = 2; - if (cnt.v_page_count < 2000) + vmstats.v_interrupt_free_min = 2; + if (vmstats.v_page_count < 2000) vm_pageout_page_count = 8; - vm_pageout_free_page_calc(cnt.v_page_count); + vm_pageout_free_page_calc(vmstats.v_page_count); /* * v_free_target and v_cache_min control pageout hysteresis. Note * that these are more a measure of the VM cache queue hysteresis @@ -1313,29 +1314,29 @@ vm_pageout() * be big enough to handle memory needs while the pageout daemon * is signalled and run to free more pages. */ - if (cnt.v_free_count > 6144) - cnt.v_free_target = 4 * cnt.v_free_min + cnt.v_free_reserved; + if (vmstats.v_free_count > 6144) + vmstats.v_free_target = 4 * vmstats.v_free_min + vmstats.v_free_reserved; else - cnt.v_free_target = 2 * cnt.v_free_min + cnt.v_free_reserved; + vmstats.v_free_target = 2 * vmstats.v_free_min + vmstats.v_free_reserved; - if (cnt.v_free_count > 2048) { - cnt.v_cache_min = cnt.v_free_target; - cnt.v_cache_max = 2 * cnt.v_cache_min; - cnt.v_inactive_target = (3 * cnt.v_free_target) / 2; + if (vmstats.v_free_count > 2048) { + vmstats.v_cache_min = vmstats.v_free_target; + vmstats.v_cache_max = 2 * vmstats.v_cache_min; + vmstats.v_inactive_target = (3 * vmstats.v_free_target) / 2; } else { - cnt.v_cache_min = 0; - cnt.v_cache_max = 0; - cnt.v_inactive_target = cnt.v_free_count / 4; + vmstats.v_cache_min = 0; + vmstats.v_cache_max = 0; + vmstats.v_inactive_target = vmstats.v_free_count / 4; } - if (cnt.v_inactive_target > cnt.v_free_count / 3) - cnt.v_inactive_target = cnt.v_free_count / 3; + if (vmstats.v_inactive_target > vmstats.v_free_count / 3) + vmstats.v_inactive_target = vmstats.v_free_count / 3; /* XXX does not really belong here */ if (vm_page_max_wired == 0) - vm_page_max_wired = cnt.v_free_count / 3; + vm_page_max_wired = vmstats.v_free_count / 3; if (vm_pageout_stats_max == 0) - vm_pageout_stats_max = cnt.v_free_target; + vm_pageout_stats_max = vmstats.v_free_target; /* * Set interval in seconds for stats scan. @@ -1370,7 +1371,7 @@ vm_pageout() if (vm_pages_needed && !vm_page_count_min()) { if (vm_paging_needed() <= 0) vm_pages_needed = 0; - wakeup(&cnt.v_free_count); + wakeup(&vmstats.v_free_count); } if (vm_pages_needed) { /* @@ -1401,7 +1402,7 @@ vm_pageout() } if (vm_pages_needed) - cnt.v_pdwakeups++; + mycpu->gd_cnt.v_pdwakeups++; splx(s); vm_pageout_scan(pass); vm_pageout_deficit = 0; diff --git a/sys/vm/vm_zone.c b/sys/vm/vm_zone.c index 206d6e4c3b..564ab5caca 100644 --- a/sys/vm/vm_zone.c +++ b/sys/vm/vm_zone.c @@ -12,7 +12,7 @@ * John S. Dyson. * * $FreeBSD: src/sys/vm/vm_zone.c,v 1.30.2.6 2002/10/10 19:50:16 dillon Exp $ - * $DragonFly: src/sys/vm/vm_zone.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_zone.c,v 1.3 2003/07/03 17:24:04 dillon Exp $ */ #include @@ -387,7 +387,7 @@ _zget(vm_zone_t z) bzero((caddr_t) zkva, PAGE_SIZE); z->zpagecount++; zone_kmem_pages++; - cnt.v_wire_count++; + vmstats.v_wire_count++; } nitems = ((z->zpagecount * PAGE_SIZE) - nbytes) / z->zsize; } else { diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index ec2876210f..7cdd7aa8f9 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -39,7 +39,7 @@ * * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91 * $FreeBSD: src/sys/vm/vnode_pager.c,v 1.116.2.7 2002/12/31 09:34:51 dillon Exp $ - * $DragonFly: src/sys/vm/vnode_pager.c,v 1.5 2003/06/26 05:55:21 dillon Exp $ + * $DragonFly: src/sys/vm/vnode_pager.c,v 1.6 2003/07/03 17:24:04 dillon Exp $ */ /* @@ -650,8 +650,8 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) vnode_pager_freepage(m[i]); } } - cnt.v_vnodein++; - cnt.v_vnodepgsin++; + mycpu->gd_cnt.v_vnodein++; + mycpu->gd_cnt.v_vnodepgsin++; return vnode_pager_input_old(object, m[reqpage]); /* @@ -666,8 +666,8 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) vnode_pager_freepage(m[i]); } } - cnt.v_vnodein++; - cnt.v_vnodepgsin++; + mycpu->gd_cnt.v_vnodein++; + mycpu->gd_cnt.v_vnodepgsin++; return vnode_pager_input_smlfs(object, m[reqpage]); } @@ -782,8 +782,8 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; - cnt.v_vnodein++; - cnt.v_vnodepgsin += count; + mycpu->gd_cnt.v_vnodein++; + mycpu->gd_cnt.v_vnodepgsin += count; /* do the input */ VOP_STRATEGY(bp->b_vp, bp); @@ -903,7 +903,7 @@ vnode_pager_putpages(object, m, count, sync, rtvals) * daemon up. This should be probably be addressed XXX. */ - if ((cnt.v_free_count + cnt.v_cache_count) < cnt.v_pageout_free_min) + if ((vmstats.v_free_count + vmstats.v_cache_count) < vmstats.v_pageout_free_min) sync |= OBJPC_SYNC; /* @@ -1023,8 +1023,8 @@ vnode_pager_generic_putpages(vp, m, bytecount, flags, rtvals) auio.uio_resid = maxsize; auio.uio_td = NULL; error = VOP_WRITE(vp, &auio, ioflags, curproc->p_ucred); - cnt.v_vnodeout++; - cnt.v_vnodepgsout += ncount; + mycpu->gd_cnt.v_vnodeout++; + mycpu->gd_cnt.v_vnodepgsout += ncount; if (error) { printf("vnode_pager_putpages: I/O error %d\n", error); -- 2.41.0