From nobody Wed Dec 04 20:25:01 2024 X-Original-To: dev-commits-src-main@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 4Y3TXZ1vJRz5g8mr; Wed, 04 Dec 2024 20:25:02 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y3TXY6wVpz4DkM; Wed, 4 Dec 2024 20:25:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733343902; 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=d2a34kEN+Vjz+5EhwZ4TailkNeYyWHygJW26wKWNC7A=; b=Olqh6JA0O95lRwQQR6hcFY+ogl8W7fEMYt/y1hWrQhn5oTvJOCsnR2uPloYu5w2y1wRbRf 0ORyebL01Rv8XJLSRM2MS0fK59yHxb6ungIi1kS72BTAiKA0e8oL8ULNI2PkbnHoXL6Pm5 3lKLPD2dGGIoylVHV2MdqLGzR7ZaMZ5ChIggvyYdIRXhF/a89wI2wbaryxX+gfVEKAEvLQ IMxIRHt8sV3r3BU8W5As25x3FryUPz6ZtTBwi05odeHe3JkbMdewX6qz4lZOk0ZREySs7l XgXHAHlYxEUY+m6gYevzvqHFGVyM/IK/LLMt32Vapdbec0f9jWvC+J4JXhXbvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733343902; 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=d2a34kEN+Vjz+5EhwZ4TailkNeYyWHygJW26wKWNC7A=; b=ZlCZ311qh/CQsYE+BPywEXs3t8t+fcuAPWONYSeeBuZQlIpTgQxw3L6EYrkNztl9uPtCxT DFW7RBo1uc6nZyPXovD9C4i8jPw9WxQc/vKcWSpx7Zg+65fbVVkqKXIYv5LPntTxDIU6Cv oERBhK4S1UVCvK1svY0GnDmGM9DRjXrvbK5p0TMnsr6enfNAJWbSzMpAmBtVzGQ/1qgCF5 u3HXmfSaMqDxQJ7wHaYAJ1HDoM1qNBOoxQ6rKVjEctWmIdXTN5SAUbHU5/69CWDAHzI3zW +D3owoVlIvowdNV+Sddi05FAoiXjJ7Rl4yNVqDNJDTkY7uiRGy6slBIBeWKAxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733343902; a=rsa-sha256; cv=none; b=oTz4d7vo/Ez3Y6nttrySn/47mJ2F2jyg3gbVXD1Zcmzrx9kiAgjYswAmH5UbSmVAdOYJS8 0j0+5Clq50chhcF/djBZrW2RWxE0KRASw9EbAf8MF+U4PZ1Yglb2nt5TWOgPgfG4df45/U ENEbP+QIjzSJ7bRtemtt1z6CaMzLaRc6VLikZy4z0avkJ2FhiXHKAj+FxNRIZ3QPTJYlWn /wNgmdkP8FPXH8YGHPfWR/42Ck86FuqofWUyJ08bD+4GqzjEO7j21sTkPGHDiq4KtLpy0/ RmrULoZisx84RfTIhSx9hBc4jBn30wsk7geBTEhW4YTuERJxofZ2eYxBpMJz0g== 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 4Y3TXY6LkzzMds; Wed, 4 Dec 2024 20:25:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B4KP1eh083643; Wed, 4 Dec 2024 20:25:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B4KP1GW083640; Wed, 4 Dec 2024 20:25:01 GMT (envelope-from git) Date: Wed, 4 Dec 2024 20:25:01 GMT Message-Id: <202412042025.4B4KP1GW083640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: b2bde8a6d391 - main - tcp_hpts: consistenly use macros to lock & unlock List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2bde8a6d391f31d3eef8d07f9dba2e311a5295d Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=b2bde8a6d391f31d3eef8d07f9dba2e311a5295d commit b2bde8a6d391f31d3eef8d07f9dba2e311a5295d Author: Gleb Smirnoff AuthorDate: 2024-12-04 20:16:42 +0000 Commit: Gleb Smirnoff CommitDate: 2024-12-04 20:16:42 +0000 tcp_hpts: consistenly use macros to lock & unlock The macros version of lock/unlock has already been used 23 times in this file and the bare version was used 6 times only, so prefer the former. No functional change. --- sys/netinet/tcp_hpts.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c index d5dea1c98a94..0c7338eb222b 100644 --- a/sys/netinet/tcp_hpts.c +++ b/sys/netinet/tcp_hpts.c @@ -173,6 +173,7 @@ /* Each hpts has its own p_mtx which is used for locking */ #define HPTS_MTX_ASSERT(hpts) mtx_assert(&(hpts)->p_mtx, MA_OWNED) #define HPTS_LOCK(hpts) mtx_lock(&(hpts)->p_mtx) +#define HPTS_TRYLOCK(hpts) mtx_trylock(&(hpts)->p_mtx) #define HPTS_UNLOCK(hpts) mtx_unlock(&(hpts)->p_mtx) struct tcp_hpts_entry { /* Cache line 0x00 */ @@ -1503,7 +1504,7 @@ __tcp_set_hpts(struct tcpcb *tp, int32_t line) if (failed == 0) tp->t_flags2 |= TF2_HPTS_CPU_SET; } - mtx_unlock(&hpts->p_mtx); + HPTS_UNLOCK(hpts); } static struct tcp_hpts_entry * @@ -1560,7 +1561,7 @@ __tcp_run_hpts(void) /* Already active */ return; } - if (mtx_trylock(&hpts->p_mtx) == 0) { + if (!HPTS_TRYLOCK(hpts)) { /* Someone else got the lock */ return; } @@ -1615,8 +1616,7 @@ __tcp_run_hpts(void) } hpts->p_hpts_active = 0; out_with_mtx: - HPTS_MTX_ASSERT(hpts); - mtx_unlock(&hpts->p_mtx); + HPTS_UNLOCK(hpts); NET_EPOCH_EXIT(et); } @@ -1630,7 +1630,7 @@ tcp_hpts_thread(void *ctx) int ticks_ran; hpts = (struct tcp_hpts_entry *)ctx; - mtx_lock(&hpts->p_mtx); + HPTS_LOCK(hpts); if (hpts->p_direct_wake) { /* Signaled by input or output with low occupancy count. */ callout_stop(&hpts->co); @@ -1640,7 +1640,7 @@ tcp_hpts_thread(void *ctx) counter_u64_add(hpts_wake_timeout, 1); if (callout_pending(&hpts->co) || !callout_active(&hpts->co)) { - mtx_unlock(&hpts->p_mtx); + HPTS_UNLOCK(hpts); return; } } @@ -1769,7 +1769,7 @@ back_to_sleep: hpts_timeout_swi, hpts, hpts->p_cpu, (C_DIRECT_EXEC | C_PREL(tcp_hpts_precision))); NET_EPOCH_EXIT(et); - mtx_unlock(&hpts->p_mtx); + HPTS_UNLOCK(hpts); } #undef timersub