Date: Fri, 19 Apr 2019 17:22:24 -0700 From: Mark Millard <marklmi@yahoo.com> To: FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, Justin Hibbits <chmeeedalf@gmail.com> Subject: Re: spinlock_enter, head -r346144 (and before) and use of nop_prio_mhigh vs. PowerISA document suggestions for lock code Message-ID: <300DEA60-E9C3-4BB7-A7EF-980EE58257DB@yahoo.com> In-Reply-To: <F0A58D08-4A99-4483-A419-200A1485E73E@yahoo.com> References: <F0A58D08-4A99-4483-A419-200A1485E73E@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[Looks like nop_prio_mhigh has some vintage-specific behavior, based on if there is a PSPB (Problem State Priority Boost Register) and how it is configured.] On 2019-Apr-19, at 15:56, Mark Millard <marklmi at yahoo.com> wrote: > I found the following text in each of the 2.03, 2.04, 2.05, > 2.06B V2, 2.07, and 3.0B PowerISA documents, in a "Programming > Note" in the "Program Priority Registers" section: >=20 > ". . . if a program is waiting on a lock (...), it could set low = priority with the > result that more processor resources would be diverted to the program = that holds the > lock. This diversion of resources may enable the lock-holding program = to complete > the operation under the lock more quickly, and then relinquish the = lock to the waiting > program." >=20 > The wording suggests working via normal/medium and lower > priorities instead of via normal/medium and higher priorities. > (May be more than just the relative priority matters in the > behavior changes that result each way? Unfortunately the > wording is not very explicit.) >=20 > All of the documents list "or rx,rx,rx" for: > Rx being 31 or 1 or 6 or 2 or 5 or 3 or 7 > (listed lowest to highest relative priority), > 2 being normal/medium. Some table(s) might not > list 3 or 7 in a document but at least one does > in each. Actually, going back to 2.03, for example, only lists 31 in one place as well. Only 1, 6, and 2 are in all such tables. > In the following powerpc64 and 32-bit powerpc > FreeBSD seem to be going in the opposite direction > relative to normal/medium vs. the suggestion > of "low priority": >=20 > void > spinlock_enter(void) > { > struct thread *td; > register_t msr; >=20 > td =3D curthread; > if (td->td_md.md_spinlock_count =3D=3D 0) { > nop_prio_mhigh(); > msr =3D intr_disable(); > td->td_md.md_spinlock_count =3D 1; > td->td_md.md_saved_msr =3D msr; > } else > td->td_md.md_spinlock_count++; > critical_enter(); > } >=20 > void > spinlock_exit(void) > { > struct thread *td; > register_t msr; >=20 > td =3D curthread; > critical_exit(); > msr =3D td->td_md.md_saved_msr; > td->td_md.md_spinlock_count--; > if (td->td_md.md_spinlock_count =3D=3D 0) { > intr_restore(msr); > nop_prio_medium(); > } > } >=20 > and previously: >=20 > void > spinlock_enter(void) > { > struct thread *td; > register_t msr; >=20 > td =3D curthread; > if (td->td_md.md_spinlock_count =3D=3D 0) { > __asm __volatile("or 2,2,2"); /* Set high thread = priority */ > msr =3D intr_disable(); > td->td_md.md_spinlock_count =3D 1; > td->td_md.md_saved_msr =3D msr; > } else > td->td_md.md_spinlock_count++; > critical_enter(); > } >=20 > void > spinlock_exit(void) > { > struct thread *td; > register_t msr; >=20 > td =3D curthread; > critical_exit(); > msr =3D td->td_md.md_saved_msr; > td->td_md.md_spinlock_count--; > if (td->td_md.md_spinlock_count =3D=3D 0) { > intr_restore(msr); > __asm __volatile("or 6,6,6"); /* Set normal thread = priority */ > } > } >=20 > (2,2,2 was higher then 6,6,6 but 2,2,2 is > normal/medium and 6,6,6 is "medium low" the > way the PowerISA documentation reads.) >=20 > 2.06B V2 and 2.07 also list special meanings for: > 27 and 29 and 30. (cpu_spinwait in FreeBSD uses 27.) > But 3.0B does not list them any more. >=20 > 2.07 and 3.0B lists a special meaning for: 26. > No prior version that I looked at does. >=20 PSPB (Problem State Priority Boost Register)is not=20 mentioned until 2.07 of the PowerISA (for those I've been looking at). PSPB can count down and force Medium High back to Medium, for example. A hardware form of timed-temporary priority boost when used that way. It appears that medium and lower priorities do not have such a means of control. Nor do higher priorities, just Medium High. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?300DEA60-E9C3-4BB7-A7EF-980EE58257DB>