From owner-p4-projects@FreeBSD.ORG Mon Jan 7 19:39:56 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2BD0216A474; Mon, 7 Jan 2008 19:39:56 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D38016A421 for ; Mon, 7 Jan 2008 19:39:55 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7F48B13C46B for ; Mon, 7 Jan 2008 19:39:55 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m07JdtsU010241 for ; Mon, 7 Jan 2008 19:39:55 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m07Jdsi3010238 for perforce@freebsd.org; Mon, 7 Jan 2008 19:39:54 GMT (envelope-from gonzo@FreeBSD.org) Date: Mon, 7 Jan 2008 19:39:54 GMT Message-Id: <200801071939.m07Jdsi3010238@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 132729 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jan 2008 19:39:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=132729 Change 132729 by gonzo@gonzo_jeeves on 2008/01/07 19:39:39 o Add cpu_throw(9) implementation. Make it wrapper around mips_cpu_throw, just like cpu_switch(9) is wrapper around mips_cpu_switch. We'll fix it once kernel is ready for testing. o Handle third argument of cpu_switch(9) and spin while td_lock of new thread is blocked_lock. Reviewed by: cognet Affected files ... .. //depot/projects/mips2-jnpr/src/sys/mips/include/proc.h#4 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#4 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/pm_machdep.c#4 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#6 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/vm_machdep.c#6 edit Differences ... ==== //depot/projects/mips2-jnpr/src/sys/mips/include/proc.h#4 (text+ko) ==== @@ -64,6 +64,7 @@ struct thread; -void mips_cpu_switch(struct thread *, struct thread *); +void mips_cpu_switch(struct thread *, struct thread *, struct mtx *); +void mips_cpu_throw(struct thread *, struct thread *); #endif /* !_MACHINE_PROC_H_ */ ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#4 (text+ko) ==== @@ -67,6 +67,7 @@ ASSYM(TD_UPTE, offsetof(struct thread, td_md.md_upte)); ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack)); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); +ASSYM(TD_LOCK, offsetof(struct thread, td_lock)); ASSYM(U_PCB_REGS, offsetof(struct pcb, pcb_regs.zero)); ASSYM(U_PCB_CONTEXT, offsetof(struct pcb, pcb_context)); ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/pm_machdep.c#4 (text+ko) ==== @@ -535,6 +535,6 @@ void cpu_switch(struct thread *old, struct thread *new, struct mtx * new_lock) { - /* XXX this is lame, maybe, but we ignore new_lock */ - func_2args_asmmacro(&mips_cpu_switch, old, new); + + func_3args_asmmacro(&mips_cpu_switch, old, new, new_lock); } ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#6 (text+ko) ==== @@ -229,13 +229,26 @@ END(savectx) +KSEG0TEXT_START; + +NON_LEAF(mips_cpu_throw, STAND_FRAME_SIZE, ra) + mfc0 t0, COP_0_STATUS_REG # t0 = saved status register + nop + nop + mtc0 zero, COP_0_STATUS_REG # Disable all interrupts + ITLBNOPFIX + j mips_sw1 # We're not interested in old + # thread's context, so jump + # right to action + nop # BDSLOT +END(mips_cpu_throw) + /* *XXX Fixme: should be written to new interface that requires lock * storage. We fake it for now. * mips_cpu_switch(struct thread *old, struct thread *new); * Find the highest priority process and resume it. */ -KSEG0TEXT_START; NON_LEAF(mips_cpu_switch, STAND_FRAME_SIZE, ra) mfc0 t0, COP_0_STATUS_REG # t0 = saved status register nop @@ -243,7 +256,7 @@ mtc0 zero, COP_0_STATUS_REG # Disable all interrupts ITLBNOPFIX beqz a0, mips_sw1 - move a2, a0 + move a3, a0 lw a0, TD_PCB(a0) # load PCB addr of curproc SAVE_U_PCB_CONTEXT(sp, 8, a0) # save old sp subu sp, sp, STAND_FRAME_SIZE @@ -266,7 +279,16 @@ * to be saved with the other registers do so here. */ + sw a3, TD_LOCK(a0) # Switchout td_lock + mips_sw1: +#if defined(SMP) && defined(SCHED_ULE) + la t0, _C_LABEL(blocked_lock) +blocked_loop: + lw t1, TD_LOCK(a1) + beq t0, t1, blocked_loop + nop +#endif move s7, a1 # Store newthread /* * Switch to new context. ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/vm_machdep.c#6 (text+ko) ==== @@ -517,12 +517,10 @@ return (0); } -#ifdef GONE_IN_7 void cpu_throw(struct thread *old, struct thread *new) { - cpu_switch(old, new); - panic("cpu_throw() didn't"); + func_2args_asmmacro(&mips_cpu_throw, old, new); + panic("mips_cpu_throw() returned"); } -#endif