From nobody Fri Jul 14 04:13:08 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R2J446FzLz4mn5d; Fri, 14 Jul 2023 04:13:08 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R2J445XtSz40lY; Fri, 14 Jul 2023 04:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689307988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eOD4RRmyFqd5owaPKbzucP3ylnF8KBxqR/Pq3uzRnBY=; b=Y93VNIINzBNPNCf34MfF7YgsavM+2v4TUfrXZKNueYEvl7DRKgCd7LEY16zbkvnb6Hdbrt fLJeb3+xWCyD1+ipagPOJQ5IwMn1PYU8oy2wldZQp2DvQoque7NTxEBHXH6wGyX/mol03n 5xXRf7IHDroYTzieMqF+X0bYDZiZUKkC/U0txyOC6mNpGhZYBQWpuNNCvDFtl/8kSAwJ9O AWOUwHlK2rLB7AIZ4UcZZuEFjesd3kmgnWfWlcLiZknzbNd2qA+sDpE/8iuZAuPPYRZx74 JFdu7c3cYVzxYb/KE+P4p3OQKWW5EhONHSmN7IV0PmRVq/AFsbchngKC98YzlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689307988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eOD4RRmyFqd5owaPKbzucP3ylnF8KBxqR/Pq3uzRnBY=; b=jKkDVnRxcQ0bDBGDIpW/A8Inch81jjHw2SodSZZmes5jV6gXrzqhECSwUNFArp1EiAGFoy 5JlRPxcE++sniHWlmgh4MDDeWB/uLOLumOU83I1mNXsmMkWRVvwEetEtSh09yEmhm0KSys 6fPaQn1vg04Frkz+ft9fvtugZ3V+v+DcCSmqUusDUhkZQpgzkipck33af/lUF3WWGw7Lsr N0eb69+WG0owDDrwBJuV6KTYJ2ZFVePy09t07hvZC0tTojGUAcTMSSRRmyH/OqEtVJtY5k 3QKUah/+JqFM9P8t1WHxiPHnln5wbVdqjvbVUS6TbSImBazn7Nt7i3SciAZF1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689307988; a=rsa-sha256; cv=none; b=WXpbKiZlq8nclwFbIiAp74MtPCLvBlX2Zvih4X8D4A+Zfvq71to6ngRW9T6at2kkhyIpr8 kkcm802hte0Gib20ZjO6Zr0kUl8J89ztTYFGZnIXgU8PCnVE/Kv8kcPkBLDEtMdxjXL95L hY9HwcDsBBxXubo+y+PE6ac5AK9DOqmrQkDY/LCCfYWhI9q+D4HJ8fdtKVJQiqg59PT/Ki X8KVtMheO2mlDsgYGOfgc7kxaP7ER9u3lTgvbQF/QqMds97bUW2/JJGmjE2sr/jXIf160L WqYSJuwPgjnEXlOpcZOf9ek26q6khQsKhgQPwTJ6mFQYHuJrGz6sAeZCPS7F/A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R2J444f9jz1Hp8; Fri, 14 Jul 2023 04:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36E4D8Uw085965; Fri, 14 Jul 2023 04:13:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36E4D8xY085964; Fri, 14 Jul 2023 04:13:08 GMT (envelope-from git) Date: Fri, 14 Jul 2023 04:13:08 GMT Message-Id: <202307140413.36E4D8xY085964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 36a037f1501e - stable/13 - libthr: Patch to reduce latency to acquire+release a pthread mutex. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 36a037f1501e0969b56f643c5e9782334bd540e3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36a037f1501e0969b56f643c5e9782334bd540e3 commit 36a037f1501e0969b56f643c5e9782334bd540e3 Author: Greg Becker AuthorDate: 2023-07-07 22:03:14 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-13 01:29:17 +0000 libthr: Patch to reduce latency to acquire+release a pthread mutex. (cherry picked from commit b370ef156ab9d88450e9bc0440df522aec88cc44) --- lib/libthr/thread/thr_mutex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 2cbfd9a459d3..40e0b7382f95 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -596,7 +596,7 @@ check_and_init_mutex(pthread_mutex_t *mutex, struct pthread_mutex **m) *m = *mutex; ret = 0; - if (*m == THR_PSHARED_PTR) { + if (__predict_false(*m == THR_PSHARED_PTR)) { *m = __thr_pshared_offpage(mutex, 0); if (*m == NULL) ret = EINVAL; @@ -714,7 +714,7 @@ done: return (ret); } -static inline int +static __always_inline int mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime, bool cvattach, bool rb_onlist) { @@ -728,7 +728,7 @@ mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime, if (!rb_onlist) robust = _mutex_enter_robust(curthread, m); ret = _thr_umutex_trylock2(&m->m_lock, TID(curthread)); - if (ret == 0 || ret == EOWNERDEAD) { + if (__predict_true(ret == 0) || ret == EOWNERDEAD) { enqueue_mutex(curthread, m, ret); if (ret == EOWNERDEAD) m->m_lock.m_flags |= UMUTEX_NONCONSISTENT; @@ -951,7 +951,7 @@ mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime) return (ret); } -static int +static __always_inline int mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer) { struct pthread *curthread;