NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

RE: PR/57437 CVS commit: src/lib/libpthread

The following reply was made to PR port-arm/57437; it has been noted by GNATS.

From: Vasily Dybala <>
To: "" <>,
	"" <>,
	"" <>, ""
Subject: RE: PR/57437 CVS commit: src/lib/libpthread
Date: Fri, 26 May 2023 08:03:18 +0000

 Thanks for quick fix.
 Fix looks ok, but pthread__smt_wake() call from  pthread_mutex_unlock() wil=
 l call SEV  instruction which does not have paired WFE in pthread_mutex_loc=
 I will check patch during next week.
 -----Original Message-----
 From: Taylor R Campbell <>=20
 Sent: Thursday, May 25, 2023 17:35
 To:;; netbsd-bugs@net=; Vasily Dybala <>
 Subject: PR/57437 CVS commit: src/lib/libpthread
 Caution: This is an external email. Be cautious while opening links or atta=
 The following reply was made to PR port-arm/57437; it has been noted by GNA=
 From: "Taylor R Campbell" <>
 Subject: PR/57437 CVS commit: src/lib/libpthread
 Date: Thu, 25 May 2023 14:30:03 +0000
  Module Name:   src
  Committed By:  riastradh
  Date:          Thu May 25 14:30:03 UTC 2023
  Modified Files:
         src/lib/libpthread: pthread_int.h pthread_spin.c
         src/lib/libpthread/arch/aarch64: pthread_md.h
         src/lib/libpthread/arch/arm: pthread_md.h
         src/lib/libpthread/arch/i386: pthread_md.h
         src/lib/libpthread/arch/x86_64: pthread_md.h
  Log Message:
  libpthread: New pthread__smt_wait to put CPU in low power for spin.
  This is now distinct from pthread__smt_pause, which is for spin lock  back=
 off with no paired wakeup.
  On Arm, there is a single-bit event register per CPU, and there are two  i=
 nstructions to manage it:
  - wfe, wait for event -- if event register is clear, enter low power
    mode and wait until event register is set; then exit low power mode
    and clear event register
  - sev, signal event -- sets event register on all CPUs (other
    circumstances like interrupts also set the event register and cause
    wfe to wake)
  These can be used to reduce the power consumption of spinning for a  lock,=
  but only if they are actually paired -- if there's no sev, wfe  might hang=
  indefinitely.  Currently only pthread_spin(3) actually  pairs them; the ot=
 her lock primitives (internal lock, mutex, rwlock)  do not -- they have spi=
 n lock backoff loops, but no corresponding  wakeup to cancel a wfe.
  It may be worthwhile to teach the other lock primitives to pair  wfe/sev, =
 but that requires some performance measurement to verify  it's actually wor=
 thwhile.  So for now, we just make sure not to use  wfe when there's no sev=
 , and keep everything else the same -- this  should fix severe performance =
 degredation in libpthread on Arm  without hurting anything else.
  No change in the generated code on amd64 and i386.  No change in the  gene=
 rated code for pthread_spin.c on arm and aarch64 -- changes only  the gener=
 ated code for pthread_lock.c, pthread_mutex.c, and  pthread_rwlock.c, as in=
  PR port-arm/57437
  XXX pullup-10
  To generate a diff of this commit:
  cvs rdiff -u -r1.110 -r1.111 src/lib/libpthread/pthread_int.h  cvs rdiff -=
 u -r1.10 -r1.11 src/lib/libpthread/pthread_spin.c  cvs rdiff -u -r1.1 -r1.2=
  cvs rdiff -u -r1.12 -r1.13 src/lib/libpthread/arch/arm/pthread_md.h
  cvs rdiff -u -r1.20 -r1.21 src/lib/libpthread/arch/i386/pthread_md.h
  cvs rdiff -u -r1.12 -r1.13 src/lib/libpthread/arch/x86_64/pthread_md.h
  Please note that diffs are not public domain; they are subject to the  cop=
 yright notices on the relevant files.

Home | Main Index | Thread Index | Old Index