From owner-freebsd-ppc@freebsd.org Sat Apr 20 00:22:37 2019 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1FE41157D269 for ; Sat, 20 Apr 2019 00:22:37 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic315-21.consmr.mail.ne1.yahoo.com (sonic315-21.consmr.mail.ne1.yahoo.com [66.163.190.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 74D8F72C76 for ; Sat, 20 Apr 2019 00:22:35 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: mqgLrPsVM1kCynT2hacAoNo2L75OPP.sO3JpKToTHyyHQIJF1994TpXHUtxD.RU NT6quhMBL9b_OFrr3PknV0r146ffvLDlKJh8au7hTJiuwydNjcGixRRXLRbXzLGA5eESCJm2QImM P3jDHNIPpTZKvD.K09eUG6asvu0M9XlWmPTBNWVRz0Lr5_xQXjnaEIc7OtNC_viheS2jlifM12Km G4GUZ7nKopxxkFYtZ1EJefk.wGQ4nLaV04w1w6m2ODgeDhlQj4Mem.9jC0GoKCi0qcaYVpwGSHUu fWJMMezEbDcdsPC56EHzSBiAvofvFH4w3tg6iiJ1LSP4wkl_TBfgLTKi6ycvtItGXkurgkCSgOYv HYNn54Ki0KwOUXXp2RAVN1k0WxV68kq_LLFDPgakdAiO7xiWQYgJqaQJ2VqEf5ye.fHj0s3BZYzn CdNCjxQJraBPuVtmVRRLqGBPJ9DBG4.j.GvVs0Rc38gKGj2kbNmuc7MiEOzxSLFu0ObEWFdkshYM CX.KNoxAX8QS3W5BKIL4h6Eyj8ajlQzl6sq1WOO.r9mhfDR_.unn.5LtvZKBJuivgZeBE1BpDqu5 rMehwPgJ.t8g7F6TY8H3jec2Tc5sOb1D9auv_fpmRdD8rbP7pRJHs1VVQSHqmRHHc9UjXOhSofBG A1tlHj4TVhR2HmWsHKT004FLVO2pxZkFgWZ5YW8BVf0C3Njscwl2G.LcSwhLjMdd43N46qX14BKN myKOfj_4FvU4hxBYX0AoCghsfAdsFZPUNVPG78wcMtewQwbD6cGPhl6U515xTNOuDjpyDoJAPSIZ J25M7swSzql8_ymHrABzsHfEkpIIcuSQKZdJfmxAoG.Jd2GMWS8_FTKduxBWBjOIJxa.ZlFJpAeh N9P1RojeQIRNzxkgNOO89qRZXVaFL1.JC0fwX8lZLlgWbaw7QOtbUA6oNCjP3M8zlSJFtQhNobGs tD6kvkcXo12gM8JGIi6xTa9GEci3Vp255nIJHeCsoclFlX4Zk2FRX4CM1LLkFZjCo95feBsfEN3F Gxff_i18VZ470rcN6nstOdyk9UG5wOfN.Dk3wNzg6CczUQQpbK1qd7.VE3wYO9s0bmrZhhuFa1DA 8hxZd28LJdGbc75MbIEEWnApq9TSsD9.C Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Sat, 20 Apr 2019 00:22:28 +0000 Received: from c-76-115-7-162.hsd1.or.comcast.net (EHLO [192.168.1.103]) ([76.115.7.162]) by smtp402.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c6d030ee6a3b576fa57a7dbe8aa4f053; Sat, 20 Apr 2019 00:22:26 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: spinlock_enter, head -r346144 (and before) and use of nop_prio_mhigh vs. PowerISA document suggestions for lock code Date: Fri, 19 Apr 2019 17:22:24 -0700 References: To: FreeBSD PowerPC ML , Justin Hibbits In-Reply-To: Message-Id: <300DEA60-E9C3-4BB7-A7EF-980EE58257DB@yahoo.com> X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: 74D8F72C76 X-Spamd-Bar: +++ X-Spamd-Result: default: False [3.09 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DKIM_TRACE(0.00)[yahoo.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.31)[0.308,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.76)[ip: (6.26), ipnet: 66.163.184.0/21(1.43), asn: 36646(1.15), country: US(-0.06)]; NEURAL_SPAM_MEDIUM(0.86)[0.864,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.67)[0.668,0]; RCVD_IN_DNSWL_NONE(0.00)[147.190.163.66.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Apr 2019 00:22:37 -0000 [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 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)