From owner-svn-src-head@freebsd.org Wed Dec 5 16:43:05 2018 Return-Path: Delivered-To: svn-src-head@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 4C953131B2CB; Wed, 5 Dec 2018 16:43:05 +0000 (UTC) (envelope-from mjg@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 E6D3C7CBD9; Wed, 5 Dec 2018 16:43:04 +0000 (UTC) (envelope-from mjg@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 ADB4E17142; Wed, 5 Dec 2018 16:43:04 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB5Gh445078407; Wed, 5 Dec 2018 16:43:04 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB5Gh45m078405; Wed, 5 Dec 2018 16:43:04 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201812051643.wB5Gh45m078405@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 5 Dec 2018 16:43:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341593 - in head/sys: contrib/vchiq/interface/compat kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: contrib/vchiq/interface/compat kern sys X-SVN-Commit-Revision: 341593 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E6D3C7CBD9 X-Spamd-Result: default: False [-0.68 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.52)[-0.521,0]; NEURAL_HAM_SHORT(-0.13)[-0.126,0]; NEURAL_HAM_LONG(-0.03)[-0.031,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2018 16:43:05 -0000 Author: mjg Date: Wed Dec 5 16:43:03 2018 New Revision: 341593 URL: https://svnweb.freebsd.org/changeset/base/341593 Log: sx: retire SX_NOADAPTIVE The flag is not used by anything for years and supporting it requires an explicit read from the lock when entering slow path. Flag value is left unused on purpose. Sponsored by: The FreeBSD Foundation Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h head/sys/kern/kern_sx.c head/sys/sys/sx.h Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h ============================================================================== --- head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Wed Dec 5 15:56:44 2018 (r341592) +++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Wed Dec 5 16:43:03 2018 (r341593) @@ -162,10 +162,6 @@ struct mutex { */ typedef struct rwlock rwlock_t; -#if defined(SX_ADAPTIVESPIN) && !defined(SX_NOADAPTIVE) -#define SX_NOADAPTIVE SX_ADAPTIVESPIN -#endif - #define DEFINE_RWLOCK(name) \ struct rwlock name; \ SX_SYSINIT(name, &name, #name) Modified: head/sys/kern/kern_sx.c ============================================================================== --- head/sys/kern/kern_sx.c Wed Dec 5 15:56:44 2018 (r341592) +++ head/sys/kern/kern_sx.c Wed Dec 5 16:43:03 2018 (r341593) @@ -71,8 +71,6 @@ __FBSDID("$FreeBSD$"); #define ADAPTIVE_SX #endif -CTASSERT((SX_NOADAPTIVE & LO_CLASSFLAGS) == SX_NOADAPTIVE); - #ifdef HWPMC_HOOKS #include PMC_SOFT_DECLARE( , , lock, failed); @@ -233,7 +231,7 @@ sx_init_flags(struct sx *sx, const char *description, int flags; MPASS((opts & ~(SX_QUIET | SX_RECURSE | SX_NOWITNESS | SX_DUPOK | - SX_NOPROFILE | SX_NOADAPTIVE | SX_NEW)) == 0); + SX_NOPROFILE | SX_NEW)) == 0); ASSERT_ATOMIC_LOAD_PTR(sx->sx_lock, ("%s: sx_lock not aligned for %s: %p", __func__, description, &sx->sx_lock)); @@ -252,7 +250,6 @@ sx_init_flags(struct sx *sx, const char *description, if (opts & SX_NEW) flags |= LO_NEW; - flags |= opts & SX_NOADAPTIVE; lock_init(&sx->lock_object, &lock_class_sx, description, NULL, flags); sx->sx_lock = SX_LOCK_UNLOCKED; sx->sx_recurse = 0; @@ -572,7 +569,6 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO volatile struct thread *owner; u_int i, n, spintries = 0; enum { READERS, WRITER } sleep_reason = READERS; - bool adaptive; bool in_critical = false; #endif #ifdef LOCK_PROFILING @@ -642,10 +638,6 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__, sx->lock_object.lo_name, (void *)sx->sx_lock, file, line); -#ifdef ADAPTIVE_SX - adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0); -#endif - #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -669,8 +661,6 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO lda.spin_cnt++; #endif #ifdef ADAPTIVE_SX - if (__predict_false(!adaptive)) - goto sleepq; /* * If the lock is write locked and the owner is * running on another CPU, spin until the owner stops @@ -762,20 +752,18 @@ retry_sleepq: * chain lock. If so, drop the sleep queue lock and try * again. */ - if (adaptive) { - if (!(x & SX_LOCK_SHARED)) { - owner = (struct thread *)SX_OWNER(x); - if (TD_IS_RUNNING(owner)) { - sleepq_release(&sx->lock_object); - sx_drop_critical(x, &in_critical, - &extra_work); - continue; - } - } else if (SX_SHARERS(x) > 0 && sleep_reason == WRITER) { + if (!(x & SX_LOCK_SHARED)) { + owner = (struct thread *)SX_OWNER(x); + if (TD_IS_RUNNING(owner)) { sleepq_release(&sx->lock_object); - sx_drop_critical(x, &in_critical, &extra_work); + sx_drop_critical(x, &in_critical, + &extra_work); continue; } + } else if (SX_SHARERS(x) > 0 && sleep_reason == WRITER) { + sleepq_release(&sx->lock_object); + sx_drop_critical(x, &in_critical, &extra_work); + continue; } #endif @@ -1021,7 +1009,6 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO #ifdef ADAPTIVE_SX volatile struct thread *owner; u_int i, n, spintries = 0; - bool adaptive; #endif #ifdef LOCK_PROFILING uint64_t waittime = 0; @@ -1066,10 +1053,6 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO lock_delay_arg_init(&lda, NULL); #endif -#ifdef ADAPTIVE_SX - adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0); -#endif - #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -1095,9 +1078,6 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO #endif #ifdef ADAPTIVE_SX - if (__predict_false(!adaptive)) - goto sleepq; - /* * If the owner is running on another CPU, spin until * the owner stops running or the state of the lock @@ -1154,7 +1134,6 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO continue; } } -sleepq: #endif /* @@ -1176,7 +1155,7 @@ retry_sleepq: * the owner stops running or the state of the lock * changes. */ - if (!(x & SX_LOCK_SHARED) && adaptive) { + if (!(x & SX_LOCK_SHARED)) { owner = (struct thread *)SX_OWNER(x); if (TD_IS_RUNNING(owner)) { sleepq_release(&sx->lock_object); Modified: head/sys/sys/sx.h ============================================================================== --- head/sys/sys/sx.h Wed Dec 5 15:56:44 2018 (r341592) +++ head/sys/sys/sx.h Wed Dec 5 16:43:03 2018 (r341593) @@ -273,7 +273,6 @@ __sx_xunlock(struct sx *sx, struct thread *td, const c #define SX_NOPROFILE 0x02 #define SX_NOWITNESS 0x04 #define SX_QUIET 0x08 -#define SX_NOADAPTIVE 0x10 #define SX_RECURSE 0x20 #define SX_NEW 0x40