From nobody Thu Aug 29 21:32:58 2024 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 4Wvvdk2PQxz5MSrD; Thu, 29 Aug 2024 21:32:58 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wvvdk1sjSz4VFf; Thu, 29 Aug 2024 21:32:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724967178; 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=MTNUxmtowQVoJdoXk/Gx3+XUUTHkC+S25LWAjo8XaaE=; b=chnFq0yqBnq3TTLQfyronVxbLXzDeHWdAz5IB4FxESm4uDwIr1uhf9QYC3HksIp3FMK2fp ra+x4BMld9X6leTaphbLxK5CyBdTssJVtcnhuS+R3Wa53zbQw2KijdrCjipDi/WgU22k/A xYo29bwj3MSCMBJcIfGanhThvTFJV54iz6RkvIqBhBO+0Uw8KX5v4SrQZlywy8O48R+hpc EMMf96CWTa8l3woDMo3YkPqLJBmOj0EpUxslFD4gh3LoTIjUiJHTWbjgskRCU++TQMGGhF FgnLWX9mJ4meHt32tuGpHe1La6oxAyfvHTzAGXZ0xoXjY0fuDpGwQczqUeKT4g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724967178; a=rsa-sha256; cv=none; b=bU28Y6Thb/V6jBc1bJ0tEYiuud1GAIt1hanylGsP7Vbu3xGE9uBc1DkoK/GsJt26mycSLX d4MHQg6xqZJQKd+7wZjDKkHtH2pVghIfEXVDtJy+ZKp0D4t28ncHMbYD+5BzS99c9lyCb+ YdxwRX18HTL6lNivpNZ9EW6LuVsMw7tw3HUw1maQvyehz1zBE0LTnO4OSrKPPenCWIqa09 KtlLydiCtrmYInw6/V4VSGCeKWVq2TXSmh5MRJ58cgoARGHqpXpSzcWmT89yoB3IIJWalF Oe5sZQdXfybUlbtpqGatCjBL45pPN+m8NIGIqyPQWUuNeeEspQQLwrwfNgu2aQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724967178; 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=MTNUxmtowQVoJdoXk/Gx3+XUUTHkC+S25LWAjo8XaaE=; b=PpXXuRprPBkjqqKEPM2g0cGIMMGN3kXrgvTcA1ewtL64IqtRXDaa7slxOOrcTIViOhy6yv sH58r/g9NGwAvNOXVQdErHTewzjHfY5ezxpnEBfpoyqc47hROgr3/bj20YzUH2UbYPO7ZN jy+CCJy1wAALcBqUFHHm8+UuouBrNK49uikaClzuboJmE74xnFSLdpFafYv39b1+pNTZN9 9qC0/CELLR+1zmWEPH7GdaZeuXkjdZzziwo65xcrXiURLbb1puyvovHJTodOODRf+ZSAMV fh2dlk9HJbjKvNJh1pbFvXOBjlTl5kRNOxUvT5u8ODAqZ56j5qxbzTwa9HJntg== 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 4Wvvdk1ShfzZbT; Thu, 29 Aug 2024 21:32:58 +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 47TLWwl6038914; Thu, 29 Aug 2024 21:32:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47TLWwjB038911; Thu, 29 Aug 2024 21:32:58 GMT (envelope-from git) Date: Thu, 29 Aug 2024 21:32:58 GMT Message-Id: <202408292132.47TLWwjB038911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7e49f04c8839 - main - rangelocks: stop caching per-thread rl_q_entry 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 7e49f04c88390c4c07f90c733c0d35ad6ff00f1c Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7e49f04c88390c4c07f90c733c0d35ad6ff00f1c commit 7e49f04c88390c4c07f90c733c0d35ad6ff00f1c Author: Konstantin Belousov AuthorDate: 2024-08-29 20:45:21 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-29 21:32:48 +0000 rangelocks: stop caching per-thread rl_q_entry This should reduce the frequency of smr_synchronize() calls, that otherwise occur on almost each rangelock unlock. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D46482 --- sys/kern/kern_rangelock.c | 26 +++----------------------- sys/kern/kern_thread.c | 2 -- sys/sys/proc.h | 2 +- sys/sys/rangelock.h | 1 - 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 3a11059a7f64..3437e3da77ba 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -313,15 +313,8 @@ static struct rl_q_entry * rlqentry_alloc(vm_ooffset_t start, vm_ooffset_t end, int flags) { struct rl_q_entry *e; - struct thread *td; - - td = curthread; - if (td->td_rlqe != NULL) { - e = td->td_rlqe; - td->td_rlqe = NULL; - } else { - e = uma_zalloc_smr(rl_entry_zone, M_WAITOK); - } + + e = uma_zalloc_smr(rl_entry_zone, M_WAITOK); e->rl_q_next = NULL; e->rl_q_free = NULL; e->rl_q_start = start; @@ -333,12 +326,6 @@ rlqentry_alloc(vm_ooffset_t start, vm_ooffset_t end, int flags) return (e); } -void -rangelock_entry_free(struct rl_q_entry *e) -{ - uma_zfree_smr(rl_entry_zone, e); -} - void rangelock_init(struct rangelock *lock) { @@ -401,19 +388,12 @@ static void rangelock_free_free(struct rl_q_entry *free) { struct rl_q_entry *x, *xp; - struct thread *td; - td = curthread; for (x = free; x != NULL; x = xp) { MPASS(!rl_e_is_marked(x)); xp = x->rl_q_free; MPASS(!rl_e_is_marked(xp)); - if (td->td_rlqe == NULL) { - smr_synchronize(rl_smr); - td->td_rlqe = x; - } else { - uma_zfree_smr(rl_entry_zone, x); - } + uma_zfree_smr(rl_entry_zone, x); } } diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 9c3694feb945..4ccd6b26528e 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -460,7 +460,6 @@ thread_init(void *mem, int size, int flags) td->td_allocdomain = vm_phys_domain(vtophys(td)); td->td_sleepqueue = sleepq_alloc(); td->td_turnstile = turnstile_alloc(); - td->td_rlqe = NULL; EVENTHANDLER_DIRECT_INVOKE(thread_init, td); umtx_thread_init(td); td->td_kstack = 0; @@ -480,7 +479,6 @@ thread_fini(void *mem, int size) EVENTHANDLER_DIRECT_INVOKE(thread_fini, td); turnstile_free(td->td_turnstile); sleepq_free(td->td_sleepqueue); - rangelock_entry_free(td->td_rlqe); umtx_thread_fini(td); MPASS(td->td_sel == NULL); } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 57c910d8fce0..1e98cc84a60a 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -247,7 +247,7 @@ struct thread { struct seltd *td_sel; /* Select queue/channel. */ struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */ struct turnstile *td_turnstile; /* (k) Associated turnstile. */ - struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */ + void *td_pad1; /* Available */ struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */ lwpid_t td_tid; /* (b) Thread ID. */ sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */ diff --git a/sys/sys/rangelock.h b/sys/sys/rangelock.h index accf33d7296b..32ccf3427b49 100644 --- a/sys/sys/rangelock.h +++ b/sys/sys/rangelock.h @@ -65,7 +65,6 @@ void *rangelock_wlock(struct rangelock *lock, vm_ooffset_t start, vm_ooffset_t end); void *rangelock_trywlock(struct rangelock *lock, vm_ooffset_t start, vm_ooffset_t end); -void rangelock_entry_free(struct rl_q_entry *e); void rangelock_may_recurse(struct rangelock *lock); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void _rangelock_cookie_assert(void *cookie, int what, const char *file,