From owner-svn-src-all@freebsd.org Mon Nov 5 21:34:20 2018 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 6262E110C731; Mon, 5 Nov 2018 21:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D9602742C1; Mon, 5 Nov 2018 21:34:19 +0000 (UTC) (envelope-from jhb@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 BA1F71D248; Mon, 5 Nov 2018 21:34:19 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wA5LYJkF044917; Mon, 5 Nov 2018 21:34:19 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA5LYISI044908; Mon, 5 Nov 2018 21:34:18 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201811052134.wA5LYISI044908@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 5 Nov 2018 21:34:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340164 - in head/sys: amd64/include arm/include arm64/include i386/include kern mips/include powerpc/include riscv/include sparc64/include X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys: amd64/include arm/include arm64/include i386/include kern mips/include powerpc/include riscv/include sparc64/include X-SVN-Commit-Revision: 340164 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D9602742C1 X-Spamd-Result: default: False [-101.79 / 200.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.78)[-0.781,0]; ALLOW_DOMAIN_WHITELIST(-100.00)[FreeBSD.org]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mx1.FreeBSD.org]; NEURAL_HAM_SHORT(-0.90)[-0.898,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Server: mx1.freebsd.org 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: Mon, 05 Nov 2018 21:34:20 -0000 Author: jhb Date: Mon Nov 5 21:34:17 2018 New Revision: 340164 URL: https://svnweb.freebsd.org/changeset/base/340164 Log: Add a KPI for the delay while spinning on a spin lock. Replace a call to DELAY(1) with a new cpu_lock_delay() KPI. Currently cpu_lock_delay() is defined to DELAY(1) on all platforms. However, platforms with a DELAY() implementation that uses spin locks should implement a custom cpu_lock_delay() doesn't use locks. Reviewed by: kib MFC after: 3 days Modified: head/sys/amd64/include/cpu.h head/sys/arm/include/cpu.h head/sys/arm64/include/cpu.h head/sys/i386/include/cpu.h head/sys/kern/kern_mutex.c head/sys/mips/include/cpu.h head/sys/powerpc/include/cpu.h head/sys/riscv/include/cpu.h head/sys/sparc64/include/cpu.h Modified: head/sys/amd64/include/cpu.h ============================================================================== --- head/sys/amd64/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/amd64/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -50,6 +50,7 @@ #define cpu_getstack(td) ((td)->td_frame->tf_rsp) #define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap)) #define cpu_spinwait() ia32_pause() +#define cpu_lock_delay() DELAY(1) #define TRAPF_USERMODE(framep) \ (ISPL((framep)->tf_cs) == SEL_UPL) Modified: head/sys/arm/include/cpu.h ============================================================================== --- head/sys/arm/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/arm/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -61,6 +61,7 @@ get_cyclecount(void) #define cpu_getstack(td) ((td)->td_frame->tf_usr_sp) #define cpu_setstack(td, sp) ((td)->td_frame->tf_usr_sp = (sp)) #define cpu_spinwait() /* nothing */ +#define cpu_lock_delay() DELAY(1) #define ARM_NVEC 8 #define ARM_VEC_ALL 0xffffffff Modified: head/sys/arm64/include/cpu.h ============================================================================== --- head/sys/arm64/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/arm64/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -51,6 +51,7 @@ #define cpu_getstack(td) ((td)->td_frame->tf_sp) #define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) #define cpu_spinwait() __asm __volatile("yield" ::: "memory") +#define cpu_lock_delay() DELAY(1) /* Extract CPU affinity levels 0-3 */ #define CPU_AFF0(mpidr) (u_int)(((mpidr) >> 0) & 0xff) Modified: head/sys/i386/include/cpu.h ============================================================================== --- head/sys/i386/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/i386/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -50,6 +50,7 @@ #define cpu_getstack(td) ((td)->td_frame->tf_esp) #define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap)) #define cpu_spinwait() ia32_pause() +#define cpu_lock_delay() DELAY(1) #define TRAPF_USERMODE(framep) \ ((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM)) Modified: head/sys/kern/kern_mutex.c ============================================================================== --- head/sys/kern/kern_mutex.c Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/kern/kern_mutex.c Mon Nov 5 21:34:17 2018 (r340164) @@ -1206,7 +1206,7 @@ _mtx_lock_indefinite_check(struct mtx *m, struct lock_ ldap->spin_cnt++; if (ldap->spin_cnt < 60000000 || kdb_active || panicstr != NULL) - DELAY(1); + cpu_lock_delay(); else { td = mtx_owner(m); Modified: head/sys/mips/include/cpu.h ============================================================================== --- head/sys/mips/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/mips/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -71,6 +71,7 @@ #define cpu_getstack(td) ((td)->td_frame->sp) #define cpu_setstack(td, nsp) ((td)->td_frame->sp = (nsp)) #define cpu_spinwait() /* nothing */ +#define cpu_lock_delay() DELAY(1) /* * A machine-independent interface to the CPU's counter. Modified: head/sys/powerpc/include/cpu.h ============================================================================== --- head/sys/powerpc/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/powerpc/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -128,6 +128,7 @@ get_cyclecount(void) #define cpu_getstack(td) ((td)->td_frame->fixreg[1]) #define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */ +#define cpu_lock_delay() DELAY(1) extern char btext[]; extern char etext[]; Modified: head/sys/riscv/include/cpu.h ============================================================================== --- head/sys/riscv/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/riscv/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -46,6 +46,7 @@ #define cpu_getstack(td) ((td)->td_frame->tf_sp) #define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) #define cpu_spinwait() /* nothing */ +#define cpu_lock_delay() DELAY(1) #ifdef _KERNEL Modified: head/sys/sparc64/include/cpu.h ============================================================================== --- head/sys/sparc64/include/cpu.h Mon Nov 5 21:32:41 2018 (r340163) +++ head/sys/sparc64/include/cpu.h Mon Nov 5 21:34:17 2018 (r340164) @@ -48,6 +48,7 @@ #define cpu_getstack(td) ((td)->td_frame->tf_sp) #define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) #define cpu_spinwait() /* nothing */ +#define cpu_lock_delay() DELAY(1) #ifdef _KERNEL