From owner-svn-src-all@freebsd.org Fri Apr 12 00:53:32 2019 Return-Path: Delivered-To: svn-src-all@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 7408F156E6EB; Fri, 12 Apr 2019 00:53:32 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0AE05850F4; Fri, 12 Apr 2019 00:53:32 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D528A1A24C; Fri, 12 Apr 2019 00:53:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3C0rVru048936; Fri, 12 Apr 2019 00:53:31 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3C0rVj7048933; Fri, 12 Apr 2019 00:53:31 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904120053.x3C0rVj7048933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Fri, 12 Apr 2019 00:53:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346144 - in head/sys/powerpc: include powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys/powerpc: include powerpc X-SVN-Commit-Revision: 346144 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0AE05850F4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.94)[-0.945,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Apr 2019 00:53:32 -0000 Author: jhibbits Date: Fri Apr 12 00:53:30 2019 New Revision: 346144 URL: https://svnweb.freebsd.org/changeset/base/346144 Log: powerpc: Adjust priority NOPs, and make them functions PowerISA 2.07 and PowerISA 3.0 both specify special NOPs for priority adjustments, with "medium" priority being normal. We had been setting medium-low as our normal priority. Rather than guess each time as to what we want and the right NOP, wrap them in inline functions, and replace the occurrances of the NOPs with the functions. Also, make DELAY() drop to very low priority while waiting, so we don't burn CPU. Coupled with r346143, this shaves off a modest 5-8% on buildworld times with -j72. There may be more room for improvement with judicious use of these NOPs. MFC after: 2 weeks Modified: head/sys/powerpc/include/cpufunc.h head/sys/powerpc/powerpc/machdep.c head/sys/powerpc/powerpc/mp_machdep.c Modified: head/sys/powerpc/include/cpufunc.h ============================================================================== --- head/sys/powerpc/include/cpufunc.h Fri Apr 12 00:44:33 2019 (r346143) +++ head/sys/powerpc/include/cpufunc.h Fri Apr 12 00:53:30 2019 (r346144) @@ -212,6 +212,43 @@ get_pcpu(void) return (ret); } +/* "NOP" operations to signify priorities to the kernel. */ +static __inline void +nop_prio_vlow(void) +{ + __asm __volatile("or 31,31,31"); +} + +static __inline void +nop_prio_low(void) +{ + __asm __volatile("or 1,1,1"); +} + +static __inline void +nop_prio_mlow(void) +{ + __asm __volatile("or 6,6,6"); +} + +static __inline void +nop_prio_medium(void) +{ + __asm __volatile("or 2,2,2"); +} + +static __inline void +nop_prio_mhigh(void) +{ + __asm __volatile("or 5,5,5"); +} + +static __inline void +nop_prio_high(void) +{ + __asm __volatile("or 3,3,3"); +} + #endif /* _KERNEL */ #endif /* !_MACHINE_CPUFUNC_H_ */ Modified: head/sys/powerpc/powerpc/machdep.c ============================================================================== --- head/sys/powerpc/powerpc/machdep.c Fri Apr 12 00:44:33 2019 (r346143) +++ head/sys/powerpc/powerpc/machdep.c Fri Apr 12 00:53:30 2019 (r346144) @@ -494,7 +494,7 @@ spinlock_enter(void) td = curthread; if (td->td_md.md_spinlock_count == 0) { - __asm __volatile("or 2,2,2"); /* Set high thread priority */ + nop_prio_mhigh(); msr = intr_disable(); td->td_md.md_spinlock_count = 1; td->td_md.md_saved_msr = msr; @@ -515,7 +515,7 @@ spinlock_exit(void) td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) { intr_restore(msr); - __asm __volatile("or 6,6,6"); /* Set normal thread priority */ + nop_prio_medium(); } } Modified: head/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/mp_machdep.c Fri Apr 12 00:44:33 2019 (r346143) +++ head/sys/powerpc/powerpc/mp_machdep.c Fri Apr 12 00:53:30 2019 (r346144) @@ -78,8 +78,8 @@ machdep_ap_bootstrap(void) __asm __volatile("msync; isync"); while (ap_letgo == 0) - __asm __volatile("or 31,31,31"); - __asm __volatile("or 6,6,6"); + nop_prio_vlow(); + nop_prio_medium(); /* * Set timebase as soon as possible to meet an implicit rendezvous