The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=dd83da532c36830a0c0aac624903849262ec6f68

commit dd83da532c36830a0c0aac624903849262ec6f68
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2024-09-04 14:38:12 +0000
Commit:     Ed Maste <ema...@freebsd.org>
CommitDate: 2024-09-04 14:38:12 +0000

    umtx: shm: Collapse USHMF_REG_LINKED and USHMF_OBJ_LINKED flags
    
    ...into the only USHMF_LINKED, as they are always set or unset together.
    
    This is both to stop giving the impression that they can be set/unset
    independently, which they can't with the current code, and to make it
    clearer that an upcoming reference counting fix is correct.
    
    Reviewed by:    kib
    Approved by:    emaste (mentor)
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D46126
---
 sys/kern/kern_umtx.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index e6d5e2de5e88..8d70438ea195 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -4293,8 +4293,7 @@ __umtx_op_sem2_wake(struct thread *td, struct 
_umtx_op_args *uap,
 #define        USHM_OBJ_UMTX(o)                                                
\
     ((struct umtx_shm_obj_list *)(&(o)->umtx_data))
 
-#define        USHMF_REG_LINKED        0x0001
-#define        USHMF_OBJ_LINKED        0x0002
+#define        USHMF_LINKED            0x0001
 struct umtx_shm_reg {
        TAILQ_ENTRY(umtx_shm_reg) ushm_reg_link;
        LIST_ENTRY(umtx_shm_reg) ushm_obj_link;
@@ -4354,7 +4353,7 @@ umtx_shm_find_reg_locked(const struct umtx_key *key)
                        KASSERT(reg->ushm_key.type == TYPE_SHM, ("TYPE_USHM"));
                        KASSERT(reg->ushm_refcnt > 0,
                            ("reg %p refcnt 0 onlist", reg));
-                       KASSERT((reg->ushm_flags & USHMF_REG_LINKED) != 0,
+                       KASSERT((reg->ushm_flags & USHMF_LINKED) != 0,
                            ("reg %p not linked", reg));
                        reg->ushm_refcnt++;
                        return (reg);
@@ -4394,14 +4393,11 @@ umtx_shm_unref_reg_locked(struct umtx_shm_reg *reg, 
bool force)
        reg->ushm_refcnt--;
        res = reg->ushm_refcnt == 0;
        if (res || force) {
-               if ((reg->ushm_flags & USHMF_REG_LINKED) != 0) {
+               if ((reg->ushm_flags & USHMF_LINKED) != 0) {
                        TAILQ_REMOVE(&umtx_shm_registry[reg->ushm_key.hash],
                            reg, ushm_reg_link);
-                       reg->ushm_flags &= ~USHMF_REG_LINKED;
-               }
-               if ((reg->ushm_flags & USHMF_OBJ_LINKED) != 0) {
                        LIST_REMOVE(reg, ushm_obj_link);
-                       reg->ushm_flags &= ~USHMF_OBJ_LINKED;
+                       reg->ushm_flags &= ~USHMF_LINKED;
                }
        }
        return (res);
@@ -4494,7 +4490,7 @@ umtx_shm_create_reg(struct thread *td, const struct 
umtx_key *key,
        TAILQ_INSERT_TAIL(&umtx_shm_registry[key->hash], reg, ushm_reg_link);
        LIST_INSERT_HEAD(USHM_OBJ_UMTX(key->info.shared.object), reg,
            ushm_obj_link);
-       reg->ushm_flags = USHMF_REG_LINKED | USHMF_OBJ_LINKED;
+       reg->ushm_flags = USHMF_LINKED;
        mtx_unlock(&umtx_shm_lock);
        *res = reg;
        return (0);

Reply via email to