From owner-p4-projects Tue Apr 2 12:38:17 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E184737B417; Tue, 2 Apr 2002 12:35:41 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 842C137B420 for ; Tue, 2 Apr 2002 12:35:25 -0800 (PST) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g32KZPJ12224 for perforce@freebsd.org; Tue, 2 Apr 2002 12:35:25 -0800 (PST) (envelope-from jhb@freebsd.org) Date: Tue, 2 Apr 2002 12:35:25 -0800 (PST) Message-Id: <200204022035.g32KZPJ12224@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 8913 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=8913 Change 8913 by jhb@jhb_laptop on 2002/04/02 12:35:11 Integ from jhb_lock: MI mutex_init() function for early mutex initialization. Affected files ... ... //depot/projects/smpng/sys/alpha/alpha/machdep.c#33 edit ... //depot/projects/smpng/sys/i386/i386/machdep.c#29 integrate ... //depot/projects/smpng/sys/ia64/ia64/machdep.c#30 integrate ... //depot/projects/smpng/sys/kern/kern_mutex.c#23 edit ... //depot/projects/smpng/sys/pc98/i386/machdep.c#24 integrate ... //depot/projects/smpng/sys/powerpc/powerpc/machdep.c#19 integrate ... //depot/projects/smpng/sys/sparc64/sparc64/machdep.c#21 integrate ... //depot/projects/smpng/sys/sys/mutex.h#22 integrate Differences ... ==== //depot/projects/smpng/sys/alpha/alpha/machdep.c#33 (text+ko) ==== @@ -154,8 +154,6 @@ alpha_chipset_t chipset; struct bootinfo_kernel bootinfo; -struct mtx sched_lock; -struct mtx Giant; struct mtx icu_lock; struct user *proc0uarea; @@ -916,6 +914,7 @@ pcpu_init(pcpup, alpha_pal_whami(), sz); alpha_pal_wrval((u_int64_t) pcpup); PCPU_GET(next_asn) = 1; /* 0 used for proc0 pmap */ + PCPU_SET(curthread, &thread0); #ifdef SMP thread0.td_md.md_kernnest = 1; #endif @@ -945,20 +944,9 @@ thread0.td_frame = (struct trapframe *)thread0.td_pcb - 1; thread0.td_pcb->pcb_hw.apcb_ksp = (u_int64_t)thread0.td_frame; - /* Setup curthread so that mutexes work */ - PCPU_SET(curthread, &thread0); - - LIST_INIT(&thread0.td_contested); - - /* - * Initialise mutexes. - */ - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); + mutex_init(); mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE); mtx_init(&icu_lock, "icu", MTX_SPIN); - mtx_lock(&Giant); /* * Look at arguments passed to us and compute boothowto. ==== //depot/projects/smpng/sys/i386/i386/machdep.c#29 (text+ko) ==== @@ -210,8 +210,6 @@ static struct pcpu __pcpu; #endif -struct mtx sched_lock; -struct mtx Giant; struct mtx icu_lock; static void @@ -1693,12 +1691,8 @@ pcpu_init(pc, 0, sizeof(struct pcpu)); PCPU_SET(prvspace, pc); - - /* setup curproc so that mutexes work */ PCPU_SET(curthread, &thread0); - LIST_INIT(&thread0.td_contested); - /* * Initialize mutexes. * @@ -1707,12 +1701,9 @@ * must be able to get the icu lock, so it can't be * under witness. */ - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); + mutex_init(); mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE); mtx_init(&icu_lock, "icu", MTX_SPIN | MTX_NOWITNESS); - mtx_lock(&Giant); /* make ldt memory segments */ /* ==== //depot/projects/smpng/sys/ia64/ia64/machdep.c#30 (text+ko) ==== @@ -96,9 +96,6 @@ struct bootinfo bootinfo; int bootinfo_error; /* XXX temporary ad-hoc error mask to help debugging */ -struct mtx sched_lock; -struct mtx Giant; - extern char kstack[]; struct user *proc0uarea; vm_offset_t proc0kstack; @@ -688,6 +685,7 @@ pcpu_init(pcpup, 0, PAGE_SIZE); pcpup->pc_current_pmap = kernel_pmap; ia64_set_k4((u_int64_t) pcpup); + PCPU_SET(curthread, &thread0); /* * Initialize the rest of proc 0's PCB. @@ -702,21 +700,7 @@ thread0.td_pcb->pcb_sp = (u_int64_t)thread0.td_frame - 16; thread0.td_pcb->pcb_bspstore = (u_int64_t)proc0kstack; - /* Setup curproc so that mutexes work */ - PCPU_SET(curthread, &thread0); - - /* We pretend to own FP state so that ia64_fpstate_check() works */ - PCPU_SET(fpcurthread, &thread0); - - LIST_INIT(&thread0.td_contested); - - /* - * Initialise mutexes. - */ - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); - mtx_lock(&Giant); + mutex_init(); /* * Initialize the virtual memory system. ==== //depot/projects/smpng/sys/kern/kern_mutex.c#23 (text+ko) ==== @@ -81,6 +81,12 @@ }; /* + * System-wide mutexes + */ +struct mtx sched_lock; +struct mtx Giant; + +/* * Prototypes for non-exported routines. */ static void propagate_priority(struct thread *); @@ -863,6 +869,27 @@ } /* + * Intialize the mutex code and system mutexes. This is called from the MD + * startup code prior to mi_startup(). The per-CPU data space needs to be + * setup before this is called. + */ +void +mutex_init(void) +{ + + /* Setup thread0 so that mutexes work. */ + LIST_INIT(&thread0.td_contested); + + /* + * Initialize mutexes. + */ + mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); + mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); + mtx_init(&proc0.p_mtx, "process lock", MTX_DEF | MTX_DUPOK); + mtx_lock(&Giant); +} + +/* * Encapsulated Giant mutex routines. These routines provide encapsulation * control for the Giant mutex, allowing sysctls to be used to turn on and * off Giant around certain subsystems. The default value for the sysctls ==== //depot/projects/smpng/sys/pc98/i386/machdep.c#24 (text+ko) ==== @@ -1771,12 +1771,9 @@ * must be able to get the icu lock, so it can't be * under witness. */ - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); + mutex_init(); mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE); mtx_init(&icu_lock, "icu", MTX_SPIN | MTX_NOWITNESS); - mtx_lock(&Giant); /* make ldt memory segments */ /* ==== //depot/projects/smpng/sys/powerpc/powerpc/machdep.c#19 (text+ko) ==== @@ -114,9 +114,6 @@ int physmem = 0; int cold = 1; -struct mtx sched_lock; -struct mtx Giant; - char pcpu0[PAGE_SIZE]; char uarea0[UAREA_PAGES * PAGE_SIZE]; struct trapframe frame0; @@ -373,7 +370,6 @@ proc0.p_uarea = (struct user *)uarea0; proc0.p_stats = &proc0.p_uarea->u_stats; thread0.td_frame = &frame0; - LIST_INIT(&thread0.td_contested); /* * Set up per-cpu data. @@ -387,13 +383,7 @@ __asm __volatile("mtsprg 0, %0" :: "r"(pc)); - /* - * Initialize mutexes. - */ - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); - mtx_lock(&Giant); + mutex_init(); /* * Initialise virtual memory. @@ -514,24 +504,14 @@ init_param1(); init_param2(physmem); - /* setup curproc so the mutexes work */ - PCPU_SET(curthread, &thread0); - LIST_INIT(&thread0.td_contested); - /* XXX: NetBSDism I _think_. Not sure yet. */ #if 0 curpm = PCPU_GET(curpcb)->pcb_pmreal = PCPU_GET(curpcb)->pcb_pm = kernel_pmap; #endif - - /* - * Initialise some mutexes. - */ - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF); - mtx_lock(&Giant); + + mutex_init(); /* * Initialise console. ==== //depot/projects/smpng/sys/sparc64/sparc64/machdep.c#21 (text+ko) ==== @@ -115,9 +115,6 @@ long dumplo; int Maxmem; -struct mtx Giant; -struct mtx sched_lock; - char pcpu0[PCPU_PAGES * PAGE_SIZE]; char uarea0[UAREA_PAGES * PAGE_SIZE]; struct trapframe frame0; @@ -294,7 +291,6 @@ (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; frame0.tf_tstate = TSTATE_IE | TSTATE_PEF; thread0.td_frame = &frame0; - LIST_INIT(&thread0.td_contested); /* * Prime our per-cpu data page for use. Note, we are using it for our @@ -323,15 +319,8 @@ pmap_kenter((vm_offset_t)msgbufp + off, msgbuf_phys + off); msgbufinit(msgbufp, MSGBUF_SIZE); - /* - * Initialize mutexes. - */ - mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE); - mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE); - mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK); + mutex_init(); intr_init2(); - - mtx_lock(&Giant); } void ==== //depot/projects/smpng/sys/sys/mutex.h#22 (text+ko) ==== @@ -97,9 +97,10 @@ * [See below for descriptions] * */ -void mtx_sysinit(void *arg); void mtx_init(struct mtx *m, const char *description, int opts); void mtx_destroy(struct mtx *m); +void mtx_sysinit(void *arg); +void mutex_init(void); void _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line); void _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line); void _mtx_lock_spin(struct mtx *m, int opts, const char *file, int line); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message