From owner-freebsd-ppc@freebsd.org Fri Apr 19 22:56:12 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 CB9E0157B423 for ; Fri, 19 Apr 2019 22:56:12 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic305-3.consmr.mail.bf2.yahoo.com (sonic305-3.consmr.mail.bf2.yahoo.com [74.6.133.42]) (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 7E8C76F44C for ; Fri, 19 Apr 2019 22:56:11 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: Fb0mUxsVM1ktbB2ri0N5U9QPUy350fedVeWnjkvJIryRWB0BeXFq5aajGkX.8qF p.p1SLU8iH8IBfSknnjf2ShoGrzRQnSrfLQtpz_7v6UQUs6AwaheO.zD7Vtspogup84IR2RciQay QVnTCK6r5dLZMOQ99dcFQC3pah_.kCfj.P5j2xQr7mA5Rsn6XxhCuCyYZULLG3ih.SoVwwFJ8vFX N2dzCUp3IzkS6Z3wDrC1lA8pCp94YH.ENGvtcGUi48rWLiq9MTYNXADPnAiO14CQc6YKNAr75MIF LJNEjmvsHwrPE1iTkhfADGkakji0T.Sknm8joOhFQbZADweUcqmsRt_ZtXpHh0AqOYMKW.3UdWf1 HMwgYPs__ChioWX8XNCjydUrFHmbhQXpOXO0da9Hyj6uR8wSW.K85Vx2fKkEuApDTeKWerE_XN9F I1gdIzkM5TEMYb71cqTw6LyokR3.rg131IY6G1cBBMOjkycRIgyafau6W8B5AEG5donn6AFokDm_ iuJ_eEY5YuXe0X_qYYXFNlR0NanyqzcW4MyKBlTW9DD4luT4mlhuIUUId2rziZYJMWd8hI.gbE2T bsFnB9PEDeQu_60tWKx1u8nUSkWdPsbLMKODDSQUgDiy8Qvh8MIB_k78DPsuNyQGgHtrj_3tgumu OANFA3y4g6JxLRm9.jY4vxpA52GzHOG6MjOeniqxMYIZI6SenBow10F7PphB6c4dMPdlZiTtyBqd 9sM3wp.ANiU2PpQTfEWgx2Ym8lpnWly3l0KzD0Etsejbo0QoKogw4vFFsPEgvqO_3OPTXpYM8.0W Vc5r6gDr3InJXto1E08_rCTz.co1dPhulhU2MacLyiQqAlf.Ax3sZsX502UXyI1sEhL3Iwhih0wO yKNIC_BKB32yd20chdd8RIBbnRJMLiBGYZYHtuHAd.IOT1TE_P523PE8mx1r2OQAwXAr19mtDmmo ZX7qvHH2CncZYbJtfFhbVQgihYxva1mANsa2BziDCu_uSdXzCBWirdj7NQSpG0mg.B0S.KbZDMEB lDY9FD84uZcYbr6rOWOIXfZAqB4D77O6dGQPQii6vVS5GL_tkZkVGK7dGItm9y_POBxp281qQUwu ww7k8UOSRo7WqZbuaQe6sC2usr.eBRg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.bf2.yahoo.com with HTTP; Fri, 19 Apr 2019 22:56:09 +0000 Received: from c-76-115-7-162.hsd1.or.comcast.net (EHLO [192.168.1.103]) ([76.115.7.162]) by smtp415.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ce4f661cdbe1c0356ac3c159d9d45773; Fri, 19 Apr 2019 22:56:08 +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: spinlock_enter, head -r346144 (and before) and use of nop_prio_mhigh vs. PowerISA document suggestions for lock code Message-Id: Date: Fri, 19 Apr 2019 15:56:06 -0700 To: FreeBSD PowerPC ML , Justin Hibbits X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: 7E8C76F44C X-Spamd-Bar: + X-Spamd-Result: default: False [1.95 / 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)[]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; 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:26101, ipnet:74.6.128.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.07)[0.072,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.38)[ip: (4.10), ipnet: 74.6.128.0/21(1.59), asn: 26101(1.27), country: US(-0.06)]; NEURAL_SPAM_MEDIUM(0.73)[0.728,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.28)[0.279,0]; RCVD_IN_DNSWL_NONE(0.00)[42.133.6.74.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: Fri, 19 Apr 2019 22:56:13 -0000 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: ". . . 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." 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.) 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. 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": void spinlock_enter(void) { struct thread *td; register_t msr; 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(); } void spinlock_exit(void) { struct thread *td; register_t msr; 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(); } } and previously: 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(); } void spinlock_exit(void) { struct thread *td; register_t msr; 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 */ } } (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.) 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. 2.07 and 3.0B lists a special meaning for: 26. No prior version that I looked at does. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)