From owner-freebsd-sparc64@FreeBSD.ORG Thu Jan 13 21:50:52 2005 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C58C416A4CE; Thu, 13 Jan 2005 21:50:52 +0000 (GMT) Received: from obsecurity.dyndns.org (CPE0050040655c8-CM00111ae02aac.cpe.net.cable.rogers.com [69.199.47.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A1B943D4C; Thu, 13 Jan 2005 21:50:52 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 1EFF351B2F; Thu, 13 Jan 2005 13:50:50 -0800 (PST) Date: Thu, 13 Jan 2005 13:50:50 -0800 From: Kris Kennaway To: David Cornejo Message-ID: <20050113215049.GA87457@xor.obsecurity.org> References: <20050103104025.A6665@carver.gumbysoft.com> <20050104014112.23160.qmail@web17309.mail.tpe.yahoo.com> <6.2.0.14.2.20050104102555.049faa18@white.dogwood.com> <20050104222258.GB79661@xor.obsecurity.org> <6.2.0.14.2.20050104155036.04b3bd68@white.dogwood.com> <20050105055845.GA92720@xor.obsecurity.org> <20050112234108.GA17895@xor.obsecurity.org> <6.2.0.14.2.20050112134405.04cfa580@white.dogwood.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline In-Reply-To: <6.2.0.14.2.20050112134405.04cfa580@white.dogwood.com> User-Agent: Mutt/1.4.2.1i cc: bmilekic@technocratis.com cc: freebsd-sparc@freebsd.org cc: jhb@freeBSD.org cc: Kris Kennaway Subject: Re: Fast Data Access MMU Miss problem X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2005 21:50:52 -0000 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 12, 2005 at 01:45:21PM -1000, David Cornejo wrote: > If I can help out by running the patch or anything, let me know... Here is a patch from jhb@ that might fix this. Kris Index: sparc64/include/md_var.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/sparc64/include/md_var.h,v retrieving revision 1.15 diff -u -r1.15 md_var.h --- sparc64/include/md_var.h 16 Aug 2003 16:57:57 -0000 1.15 +++ sparc64/include/md_var.h 13 Jan 2005 21:32:48 -0000 @@ -45,10 +45,14 @@ extern vm_paddr_t kstack0_phys; =20 struct pcpu; +struct md_utrap; =20 void cpu_identify(u_long vers, u_int clock, u_int id); void cpu_setregs(struct pcpu *pc); int is_physical_memory(vm_paddr_t addr); +struct md_utrap *utrap_alloc(void); +void utrap_free(struct md_utrap *ut); +struct md_utrap *utrap_hold(struct md_utrap *ut); =20 cpu_block_copy_t spitfire_block_copy; cpu_block_zero_t spitfire_block_zero; Index: sparc64/sparc64/machdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/sparc64/sparc64/machdep.c,v retrieving revision 1.112.2.3 diff -u -r1.112.2.3 machdep.c --- sparc64/sparc64/machdep.c 17 Nov 2004 05:17:08 -0000 1.112.2.3 +++ sparc64/sparc64/machdep.c 13 Jan 2005 21:32:48 -0000 @@ -748,7 +748,6 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_stri= ngs) { struct trapframe *tf; - struct md_utrap *ut; struct pcb *pcb; struct proc *p; u_long sp; @@ -756,10 +755,8 @@ /* XXX no cpu_exec */ p =3D td->td_proc; p->p_md.md_sigtramp =3D NULL; - if ((ut =3D p->p_md.md_utrap) !=3D NULL) { - ut->ut_refcnt--; - if (ut->ut_refcnt =3D=3D 0) - free(ut, M_SUBPROC); + if (p->p_md.md_utrap !=3D NULL) { + utrap_free(p->p_md.md_utrap); p->p_md.md_utrap =3D NULL; } =20 @@ -842,3 +839,40 @@ tf->tf_gsr =3D fpregs->fr_gsr; return (0); } + +struct md_utrap * +utrap_alloc(void) +{ + struct md_utrap *ut; + + ut =3D malloc(sizeof(struct md_utrap), M_SUBPROC, M_WAITOK | M_ZERO); + ut->ut_refcnt =3D 1; + return (ut); +} + +void +utrap_free(struct md_utrap *ut) +{ + int refcnt; + + if (ut =3D=3D NULL) + return; + mtx_pool_lock(mtxpool_sleep, ut); + ut->ut_refcnt--; + refcnt =3D ut->ut_refcnt; + mtx_pool_unlock(mtxpool_sleep, ut); + if (refcnt =3D=3D 0) + free(ut, M_SUBPROC); +} + +struct md_utrap * +utrap_hold(struct md_utrap *ut) +{ + + if (ut =3D=3D NULL) + return (NULL); + mtx_pool_lock(mtxpool_sleep, ut); + ut->ut_refcnt++; + mtx_pool_unlock(mtxpool_sleep, ut); + return (ut); +} Index: sparc64/sparc64/sys_machdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/sparc64/sparc64/sys_machdep.c,v retrieving revision 1.13 diff -u -r1.13 sys_machdep.c --- sparc64/sparc64/sys_machdep.c 22 Aug 2003 07:38:08 -0000 1.13 +++ sparc64/sparc64/sys_machdep.c 13 Jan 2005 21:35:16 -0000 @@ -34,6 +34,7 @@ #include #include =20 +#include #include #include =20 @@ -119,9 +120,7 @@ } if (ua.type !=3D UTH_NOCHANGE) { if (ut =3D=3D NULL) { - ut =3D malloc(sizeof *ut, M_SUBPROC, - M_WAITOK | M_ZERO); - ut->ut_refcnt =3D 1; + ut =3D utrap_alloc(); td->td_proc->p_md.md_utrap =3D ut; } ut->ut_precise[ua.type] =3D ua.new_precise; Index: sparc64/sparc64/vm_machdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/sparc64/sparc64/vm_machdep.c,v retrieving revision 1.66.2.1 diff -u -r1.66.2.1 vm_machdep.c --- sparc64/sparc64/vm_machdep.c 30 Sep 2004 17:26:51 -0000 1.66.2.1 +++ sparc64/sparc64/vm_machdep.c 13 Jan 2005 21:35:53 -0000 @@ -111,15 +111,12 @@ void cpu_exit(struct thread *td) { - struct md_utrap *ut; struct proc *p; =20 p =3D td->td_proc; p->p_md.md_sigtramp =3D NULL; - if ((ut =3D p->p_md.md_utrap) !=3D NULL) { - ut->ut_refcnt--; - if (ut->ut_refcnt =3D=3D 0) - free(ut, M_SUBPROC); + if (p->p_md.md_utrap !=3D NULL) { + utrap_free(p->p_md.md_utrap); p->p_md.md_utrap =3D NULL; } } @@ -200,7 +197,6 @@ void cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flag= s) { - struct md_utrap *ut; struct trapframe *tf; struct frame *fp; struct pcb *pcb1; @@ -216,9 +212,7 @@ return; =20 p2->p_md.md_sigtramp =3D td1->td_proc->p_md.md_sigtramp; - if ((ut =3D td1->td_proc->p_md.md_utrap) !=3D NULL) - ut->ut_refcnt++; - p2->p_md.md_utrap =3D ut; + p2->p_md.md_utrap =3D utrap_hold(td1->td_proc->p_md.md_utrap); =20 /* The pcb must be aligned on a 64-byte boundary. */ pcb1 =3D td1->td_pcb; --gBBFr7Ir9EOA20Yy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFB5u04Wry0BWjoQKURAkM3AJ9C4lTRavvhfgmzXrrEwdnhs0mDhgCgxAzk 6L8Hnk8RfJMYulp1kZkn1uc= =WELA -----END PGP SIGNATURE----- --gBBFr7Ir9EOA20Yy--