FreeBSD Bugzilla – Attachment 6983 Details for
Bug 15440
support atomic locks in the UP kernel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 8.79 KB, created by
jburkhol
on 1999-12-12 19:20:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
jburkhol
Created:
1999-12-12 19:20:01 UTC
Size:
8.79 KB
patch
obsolete
>Index: alpha/include/lock.h >=================================================================== >RCS file: /home/ncvs/src/sys/alpha/include/lock.h,v >retrieving revision 1.5 >diff -c -r1.5 lock.h >*** lock.h 1999/08/28 00:38:47 1.5 >--- lock.h 1999/12/12 10:24:43 >*************** >*** 29,34 **** >--- 29,38 ---- > #ifndef _MACHINE_LOCK_H_ > #define _MACHINE_LOCK_H_ > >+ #define COM_LOCK() >+ #define COM_UNLOCK() >+ >+ #define SIMPLELOCK_LOCKED 1 > > /* > * Simple spin lock. >*************** >*** 38,44 **** > volatile int lock_data; > }; > >! #define COM_LOCK() >! #define COM_UNLOCK() > > #endif /* !_MACHINE_LOCK_H_ */ >--- 42,165 ---- > volatile int lock_data; > }; > >! /* inline simplelock functions */ >! static __inline void s_lock_init __P((struct simplelock *)); >! static __inline void s_lock __P((struct simplelock *)); >! static __inline void s_lock_try __P((struct simplelock *)); >! static __inline void s_unlock __P((struct simplelock *)); >! >! /* >! * void >! * s_lock_init(struct simplelock *lkp) >! * { >! * lkp->lock_data = 0; >! * } >! */ >! static __inline void >! s_lock_init(lkp) >! struct simplelock *lkp; >! { >! >! __asm __volatile( >! "# BEGIN cpu_simple_lock_init\n" >! " stl $31, %0 \n" >! " mb \n" >! " # END cpu_simple_lock_init" >! : "=m" (lkp->lock_data)); >! } >! >! /* >! * void >! * s_lock(struct simplelock *lkp) >! * { >! * while (test_and_set(&lkp->lock_data)) >! * continue; >! * } >! */ >! static __inline void >! s_lock(lkp) >! struct simplelock *lkp; >! { >! unsigned long t0; >! >! /* >! * Note, if we detect that the lock is held when >! * we do the initial load-locked, we spin using >! * a non-locked load to save the coherency logic >! * some work. >! */ >! >! __asm __volatile( >! "# BEGIN cpu_simple_lock\n" >! "1: ldl_l %0, %3 \n" >! " bne %0, 2f \n" >! " bis $31, %2, %0 \n" >! " stl_c %0, %1 \n" >! " beq %0, 3f \n" >! " mb \n" >! " br 4f \n" >! "2: ldl %0, %3 \n" >! " beq %0, 1b \n" >! " br 2b \n" >! "3: br 1b \n" >! "4: \n" >! " # END cpu_simple_lock\n" >! : "=r" (t0), "=m" (lkp->lock_data) >! : "i" (SIMPLELOCK_LOCKED), "1" (lkp->lock_data)); >! } >! >! /* >! * int >! * s_lock_try(struct simplelock *lkp) >! * { >! * return (!test_and_set(&lkp->lock_data)); >! * } >! */ >! static __inline int >! s_lock_try(lkp) >! struct simplelock *lkp; >! { >! unsigned long t0, v0; >! >! __asm __volatile( >! "# BEGIN cpu_simple_lock_try\n" >! "1: ldl_l %0, %4 \n" >! " bne %0, 2f \n" >! " bis $31, %3, %0 \n" >! " stl_c %0, %2 \n" >! " beq %0, 3f \n" >! " mb \n" >! " bis $31, 1, %1 \n" >! " br 4f \n" >! "2: bis $31, $31, %1 \n" >! " br 4f \n" >! "3: br 1b \n" >! "4: \n" >! " # END cpu_simple_lock_try" >! : "=r" (t0), "=r" (v0), "=m" (lkp->lock_data) >! : "i" (SIMPLELOCK_LOCKED), "2" (lkp->lock_data)); >! >! return (v0); >! } >! >! /* >! * void >! * s_unlock(struct simplelock *lkp) >! * { >! * lkp->lock_data = 0; >! * } >! */ >! static __inline void >! s_unlock(lkp) >! struct simplelock *lkp; >! { >! >! __asm __volatile( >! "# BEGIN cpu_simple_unlock\n" >! " stl $31, %0 \n" >! " mb \n" >! " # END cpu_simple_unlock" >! : "=m" (lkp->lock_data)); >! } > > #endif /* !_MACHINE_LOCK_H_ */ >Index: i386/i386/simplelock.s >=================================================================== >RCS file: /home/ncvs/src/sys/i386/i386/simplelock.s,v >retrieving revision 1.11 >diff -c -r1.11 simplelock.s >*** simplelock.s 1999/08/28 00:43:50 1.11 >--- simplelock.s 1999/12/12 10:28:58 >*************** >*** 57,75 **** > > /* > * void >- * s_lock_init(struct simplelock *lkp) >- * { >- * lkp->lock_data = 0; >- * } >- */ >- ENTRY(s_lock_init) >- movl 4(%esp), %eax /* get the address of the lock */ >- movl $0, (%eax) >- ret >- >- >- /* >- * void > * s_lock(struct simplelock *lkp) > * { > * while (test_and_set(&lkp->lock_data)) >--- 57,62 ---- >*************** >*** 84,106 **** > * the local cache (and thus causing external bus writes) with repeated > * writes to the lock. > */ >! #ifndef SL_DEBUG >! >! ENTRY(s_lock) >! movl 4(%esp), %eax /* get the address of the lock */ >! movl $1, %ecx >! setlock: >! xchgl %ecx, (%eax) >! testl %ecx, %ecx >! jz gotit /* it was clear, return */ >! wait: >! cmpl $0, (%eax) /* wait to empty */ >! jne wait /* still set... */ >! jmp setlock /* empty again, try once more */ >! gotit: >! ret >! >! #else /* SL_DEBUG */ > > ENTRY(s_lock) > movl 4(%esp), %edx /* get the address of the lock */ >--- 71,77 ---- > * the local cache (and thus causing external bus writes) with repeated > * writes to the lock. > */ >! #ifdef SL_DEBUG > > ENTRY(s_lock) > movl 4(%esp), %edx /* get the address of the lock */ >*************** >*** 143,164 **** > * return (!test_and_set(&lkp->lock_data)); > * } > */ >! #ifndef SL_DEBUG > > ENTRY(s_lock_try) >- movl 4(%esp), %eax /* get the address of the lock */ >- movl $1, %ecx >- >- xchgl %ecx, (%eax) >- testl %ecx, %ecx >- setz %al /* 1 if previous value was 0 */ >- movzbl %al, %eax /* convert to an int */ >- >- ret >- >- #else /* SL_DEBUG */ >- >- ENTRY(s_lock_try) > movl 4(%esp), %edx /* get the address of the lock */ > movl _cpu_lockid, %ecx /* add cpu id portion */ > incl %ecx /* add lock portion */ >--- 114,122 ---- > * return (!test_and_set(&lkp->lock_data)); > * } > */ >! #ifdef SL_DEBUG > > ENTRY(s_lock_try) > movl 4(%esp), %edx /* get the address of the lock */ > movl _cpu_lockid, %ecx /* add cpu id portion */ > incl %ecx /* add lock portion */ >*************** >*** 172,191 **** > ret > > #endif /* SL_DEBUG */ >- >- >- /* >- * void >- * s_unlock(struct simplelock *lkp) >- * { >- * lkp->lock_data = 0; >- * } >- */ >- ENTRY(s_unlock) >- movl 4(%esp), %eax /* get the address of the lock */ >- movl $0, (%eax) >- ret >- > > /* > * These versions of simple_lock block interrupts, >--- 130,135 ---- >Index: i386/include/lock.h >=================================================================== >RCS file: /home/ncvs/src/sys/i386/include/lock.h,v >retrieving revision 1.11 >diff -c -r1.11 lock.h >*** lock.h 1999/11/19 22:47:19 1.11 >--- lock.h 1999/12/12 10:34:22 >*************** >*** 211,220 **** > volatile int lock_data; > }; > >! /* functions in simplelock.s */ >! void s_lock_init __P((struct simplelock *)); > void s_lock __P((struct simplelock *)); > int s_lock_try __P((struct simplelock *)); > void ss_lock __P((struct simplelock *)); > void ss_unlock __P((struct simplelock *)); > void s_lock_np __P((struct simplelock *)); >--- 211,229 ---- > volatile int lock_data; > }; > >! /* functions used by both UP and SMP */ >! static __inline void s_lock_init __P((struct simplelock *)); >! static __inline void s_unlock __P((struct simplelock *)); >! >! #ifndef SL_DEBUG >! static __inline void s_lock __P((struct simplelock *)); >! static __inline int s_lock_try __P((struct simplelock *)); >! #else > void s_lock __P((struct simplelock *)); > int s_lock_try __P((struct simplelock *)); >+ #endif /* SL_DEBUG */ >+ >+ /* functions in simplelock.s */ > void ss_lock __P((struct simplelock *)); > void ss_unlock __P((struct simplelock *)); > void s_lock_np __P((struct simplelock *)); >*************** >*** 222,232 **** >--- 231,305 ---- > > /* inline simplelock functions */ > static __inline void >+ s_lock_init(struct simplelock *lkp) >+ { >+ lkp->lock_data = 0; >+ } >+ >+ static __inline void > s_unlock(struct simplelock *lkp) > { > lkp->lock_data = 0; > } > >+ #ifndef SL_DEBUG >+ >+ /* >+ * void >+ * s_lock(struct simplelock *lkp) >+ * { >+ * while (test_and_set(&lkp->lock_data)) >+ * continue; >+ * } >+ */ >+ static __inline void >+ s_lock(struct simplelock *lkp) >+ { >+ >+ __asm __volatile( >+ " movl $1, %%eax \n" >+ "1: \n" >+ " xchgl %%eax, %0 \n" >+ " testl %%eax, %%eax \n" >+ " jz 3f \n" >+ "2: \n" >+ " cmpl $0, %0 \n" >+ " jne 2b \n" >+ " jmp 1b \n" >+ "3: \n" >+ : "=m" (lkp->lock_data) >+ : "0" (lkp->lock_data) >+ : "eax"); >+ } >+ >+ /* >+ * int >+ * s_lock_try(struct simplelock *lkp) >+ * { >+ * return (!test_and_set(&lkp->lock_data)); >+ * } >+ */ >+ static __inline int >+ s_lock_try(struct simplelock *lkp) >+ { >+ int r; >+ >+ __asm __volatile( >+ " movl $1, %1 \n" >+ " xorl %%ecx, %%ecx \n" >+ " xchgl %1, %0 \n" >+ " testl %1, %1 \n" >+ " setz %%cl \n" >+ " movzbl %%cl, %1 \n" >+ : "=m" (lkp->lock_data), "=r" (r) >+ : "0" (lkp->lock_data) >+ : "ecx"); >+ >+ return (r); >+ } >+ >+ #endif /* SL_DEBUG */ >+ > /* global data in mp_machdep.c */ > extern struct simplelock imen_lock; > extern struct simplelock cpl_lock; >*************** >*** 239,245 **** > > #if !defined(SIMPLELOCK_DEBUG) && NCPUS > 1 > /* >! * This set of defines turns on the real functions in i386/isa/apic_ipl.s. > */ > #define simple_lock_init(alp) s_lock_init(alp) > #define simple_lock(alp) s_lock(alp) >--- 312,318 ---- > > #if !defined(SIMPLELOCK_DEBUG) && NCPUS > 1 > /* >! * This set of defines turns on the real functions in i386/i386/simplelock.s. > */ > #define simple_lock_init(alp) s_lock_init(alp) > #define simple_lock(alp) s_lock(alp)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 15440
: 6983