> Date: Fri, 10 Apr 2020 09:31:24 +0200
> From: Martin Pieuchot <[email protected]>
> 
> In order to reduce the differences with other architecture and to be able
> to use WITNESS on powerpc I'm proposing the diff below that makes use of
> the MI mp (ticket) lock implementation for powerpc.
> 
> This has been tested by Peter J. Philipp but I'd like to have more tests
> before proceeding.
> 
> As explained previously the pmap code, which is using a recursive
> spinlock to protect the hash, still uses the old lock implementation with
> this diff.
> 
> Please fire your MP macppc and report back :o)

Hopefully we can get rid of the recursive pmap lock at some point.
But for now, ok kettenis@

> Index: arch/powerpc/include/mplock.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc/include/mplock.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 mplock.h
> --- arch/powerpc/include/mplock.h     4 Dec 2017 09:51:03 -0000       1.3
> +++ arch/powerpc/include/mplock.h     9 Apr 2020 16:21:55 -0000
> @@ -27,25 +27,27 @@
>  #ifndef _POWERPC_MPLOCK_H_
>  #define _POWERPC_MPLOCK_H_
>  
> +#define __USE_MI_MPLOCK
> +
>  /*
>   * Really simple spinlock implementation with recursive capabilities.
>   * Correctness is paramount, no fancyness allowed.
>   */
>  
> -struct __mp_lock {
> +struct __ppc_lock {
>       volatile struct cpu_info *mpl_cpu;
>       volatile long           mpl_count;
>  };
>  
>  #ifndef _LOCORE
>  
> -void __mp_lock_init(struct __mp_lock *);
> -void __mp_lock(struct __mp_lock *);
> -void __mp_unlock(struct __mp_lock *);
> -int __mp_release_all(struct __mp_lock *);
> -int __mp_release_all_but_one(struct __mp_lock *);
> -void __mp_acquire_count(struct __mp_lock *, int);
> -int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
> +void __ppc_lock_init(struct __ppc_lock *);
> +void __ppc_lock(struct __ppc_lock *);
> +void __ppc_unlock(struct __ppc_lock *);
> +int __ppc_release_all(struct __ppc_lock *);
> +int __ppc_release_all_but_one(struct __ppc_lock *);
> +void __ppc_acquire_count(struct __ppc_lock *, int);
> +int __ppc_lock_held(struct __ppc_lock *, struct cpu_info *);
>  
>  #endif
>  
> Index: arch/powerpc/powerpc/lock_machdep.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc/powerpc/lock_machdep.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 lock_machdep.c
> --- arch/powerpc/powerpc/lock_machdep.c       5 Mar 2020 09:28:31 -0000       
> 1.8
> +++ arch/powerpc/powerpc/lock_machdep.c       9 Apr 2020 16:21:01 -0000
> @@ -27,7 +27,7 @@
>  #include <ddb/db_output.h>
>  
>  void
> -__mp_lock_init(struct __mp_lock *lock)
> +__ppc_lock_init(struct __ppc_lock *lock)
>  {
>       lock->mpl_cpu = NULL;
>       lock->mpl_count = 0;
> @@ -43,7 +43,7 @@ extern int __mp_lock_spinout;
>  #endif
>  
>  static __inline void
> -__mp_lock_spin(struct __mp_lock *mpl)
> +__ppc_lock_spin(struct __ppc_lock *mpl)
>  {
>  #ifndef MP_LOCKDEBUG
>       while (mpl->mpl_count != 0)
> @@ -55,14 +55,14 @@ __mp_lock_spin(struct __mp_lock *mpl)
>               CPU_BUSY_CYCLE();
>  
>       if (nticks == 0) {
> -             db_printf("__mp_lock(%p): lock spun out\n", mpl);
> +             db_printf("__ppc_lock(%p): lock spun out\n", mpl);
>               db_enter();
>       }
>  #endif
>  }
>  
>  void
> -__mp_lock(struct __mp_lock *mpl)
> +__ppc_lock(struct __ppc_lock *mpl)
>  {
>       /*
>        * Please notice that mpl_count gets incremented twice for the
> @@ -92,18 +92,18 @@ __mp_lock(struct __mp_lock *mpl)
>               }
>               ppc_intr_enable(s);
>  
> -             __mp_lock_spin(mpl);
> +             __ppc_lock_spin(mpl);
>       }
>  }
>  
>  void
> -__mp_unlock(struct __mp_lock *mpl)
> +__ppc_unlock(struct __ppc_lock *mpl)
>  {
>       int s;
>  
>  #ifdef MP_LOCKDEBUG
>       if (mpl->mpl_cpu != curcpu()) {
> -             db_printf("__mp_unlock(%p): not held lock\n", mpl);
> +             db_printf("__ppc_unlock(%p): not held lock\n", mpl);
>               db_enter();
>       }
>  #endif
> @@ -118,14 +118,14 @@ __mp_unlock(struct __mp_lock *mpl)
>  }
>  
>  int
> -__mp_release_all(struct __mp_lock *mpl)
> +__ppc_release_all(struct __ppc_lock *mpl)
>  {
>       int rv = mpl->mpl_count - 1;
>       int s;
>  
>  #ifdef MP_LOCKDEBUG
>       if (mpl->mpl_cpu != curcpu()) {
> -             db_printf("__mp_release_all(%p): not held lock\n", mpl);
> +             db_printf("__ppc_release_all(%p): not held lock\n", mpl);
>               db_enter();
>       }
>  #endif
> @@ -140,13 +140,13 @@ __mp_release_all(struct __mp_lock *mpl)
>  }
>  
>  int
> -__mp_release_all_but_one(struct __mp_lock *mpl)
> +__ppc_release_all_but_one(struct __ppc_lock *mpl)
>  {
>       int rv = mpl->mpl_count - 2;
>  
>  #ifdef MP_LOCKDEBUG
>       if (mpl->mpl_cpu != curcpu()) {
> -             db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl);
> +             db_printf("__ppc_release_all_but_one(%p): not held lock\n", 
> mpl);
>               db_enter();
>       }
>  #endif
> @@ -157,14 +157,14 @@ __mp_release_all_but_one(struct __mp_loc
>  }
>  
>  void
> -__mp_acquire_count(struct __mp_lock *mpl, int count)
> +__ppc_acquire_count(struct __ppc_lock *mpl, int count)
>  {
>       while (count--)
> -             __mp_lock(mpl);
> +             __ppc_lock(mpl);
>  }
>  
>  int
> -__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
> +__ppc_lock_held(struct __ppc_lock *mpl, struct cpu_info *ci)
>  {
>       return mpl->mpl_cpu == ci;
>  }
> Index: arch/powerpc/powerpc/pmap.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc/powerpc/pmap.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 pmap.c
> --- arch/powerpc/powerpc/pmap.c       5 Sep 2019 03:08:55 -0000       1.171
> +++ arch/powerpc/powerpc/pmap.c       9 Apr 2020 16:16:37 -0000
> @@ -185,19 +185,19 @@ int physmem;
>  int physmaxaddr;
>  
>  #ifdef MULTIPROCESSOR
> -struct __mp_lock pmap_hash_lock;
> +struct __ppc_lock pmap_hash_lock;
>  
> -#define      PMAP_HASH_LOCK_INIT()           __mp_lock_init(&pmap_hash_lock)
> +#define      PMAP_HASH_LOCK_INIT()           __ppc_lock_init(&pmap_hash_lock)
>  
>  #define      PMAP_HASH_LOCK(s)                                               
> \
>  do {                                                                 \
>       s = ppc_intr_disable();                                         \
> -     __mp_lock(&pmap_hash_lock);                                     \
> +     __ppc_lock(&pmap_hash_lock);                                    \
>  } while (0)
>  
>  #define      PMAP_HASH_UNLOCK(s)                                             
> \
>  do {                                                                 \
> -     __mp_unlock(&pmap_hash_lock);                                   \
> +     __ppc_unlock(&pmap_hash_lock);                                  \
>       ppc_intr_enable(s);                                             \
>  } while (0)
>  
> 
> 

Reply via email to