From nobody Mon Dec 09 03:28:34 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 4Y66lR3Lz3z5g7fv; Mon, 09 Dec 2024 03:28:35 +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 4Y66lR2lW0z44nx; Mon, 9 Dec 2024 03:28:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733714915; 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=HiJDa3RNVajpJQnYNkg6HFTI0ZFZWigmRoxq+deS2SM=; b=Gcx8rwfr7oz7uoQfH07WsZwQIo0Hcy3RGIQ4SK/i/oeGT7pbxFpnU9K0r+rLI8ZAmpkWYj AkgNhxqocPuvaYa2kyp7QoV0Tf8+KlJsbP3NJiCWJEESKCgk0J6mfVX39sAAZ1GfhHVDhm 3n8/OPRGbREMYIGOSb8W4d+UCySYu7urWad3AuKGW6pN5gbfFEjP21kRgSEhqFxiQ5fSg5 U1cEV8IdLRny6ck/0E8PbwqYfdethTBJMvITYkZLDg8TbrmGM2eGPwjrqaYMuRnThZdZMy DNcTwz65W5oaa6SF/sJgV/nftO8RFRu69YE11FkdunfEd+XJ5Psyw+rj3thixw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733714915; 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=HiJDa3RNVajpJQnYNkg6HFTI0ZFZWigmRoxq+deS2SM=; b=johnbBPKELHd9Di7prChG6kOGgziWPOoEGyhPape8cppyQujjf59dzP0ENRJu9HqbgBmAy Vg1V4XPWISzzjtHbBWzEoc2zJzKFW9ggh8Ffs+9bVVKKQ4/nPJlUo+ZyASv5s4wd+3ZDDT eAnaRFIFB5+DMEJBsk8dpgM8cuhk6grK4QlCG6akq71jL9/xCNUGWaJB8Eur8+06073dYe bHXfUWZGtfaTBspY8yfz+gzbuGskY8/g9BpMFrsOLB3g9mONHA5lQ4qLz7fUXxXViAHsdj m3l02m+a3MdhpaEGmY49nAcjmWEAeOGX5ta7NbZ/g4H9fLppLVSmMVdThSilJw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733714915; a=rsa-sha256; cv=none; b=ZAkKdHfLQX3+NrI9fr3DMfPmHnmyr8ciJHkmLsgWqMQesTz0W4PBu6LBx2l4zCjmUzBTIy 6MHha13GZikrvRoBz2N1W1wyTIjldVlHCpF7oeaVDTyAOrrgOSYS5Kw2M4hwWbDfpLqNCq TXX47OfIzxOnokJNHzIHQIRPR2QpNP6BitwpyaSJ4pDhv3aJ2fFyvkzzYY4Ww89MWvL8wC Lu1Gyuz/x5Gt0hdTBNMzsKGUuq9CRjF1svQUzXVPifrVtdwEf0FdkdyQlYCsAy2v6hGXvN jzkU4h5xoJyf87Vn4CB48x7h1QXNF6Q6zpqgYHKMVAYrbuQ6sXFyZnRcU0VAMg== 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 4Y66lR0TpszKwx; Mon, 9 Dec 2024 03:28:35 +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 4B93SYvP083764; Mon, 9 Dec 2024 03:28:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B93SYHh083761; Mon, 9 Dec 2024 03:28:34 GMT (envelope-from git) Date: Mon, 9 Dec 2024 03:28:34 GMT Message-Id: <202412090328.4B93SYHh083761@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: c5b19cef3609 - main - vm_map: wrap map->system_map checks into wrapper 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5b19cef3609211e692d6b21abcddef877c94af7 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c5b19cef3609211e692d6b21abcddef877c94af7 commit c5b19cef3609211e692d6b21abcddef877c94af7 Author: Konstantin Belousov AuthorDate: 2024-12-06 23:51:08 +0000 Commit: Konstantin Belousov CommitDate: 2024-12-09 03:27:44 +0000 vm_map: wrap map->system_map checks into wrapper Reviewed by: alc Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D47934 --- sys/vm/vm_fault.c | 2 +- sys/vm/vm_map.c | 49 ++++++++++++++++++++++++------------------------- sys/vm/vm_map.h | 6 ++++++ sys/vm/vm_pageout.c | 2 +- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 6e0415b30600..8c7fe9e37af1 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1355,7 +1355,7 @@ vm_fault_getpages(struct faultstate *fs, int *behindp, int *aheadp) MPASS(status == FAULT_CONTINUE || status == FAULT_RESTART); if (status == FAULT_RESTART) return (status); - KASSERT(fs->vp == NULL || !fs->map->system_map, + KASSERT(fs->vp == NULL || !vm_map_is_system(fs->map), ("vm_fault: vnode-backed object mapped by system map")); /* diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index c3aa499e0dc7..f7847a244586 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -523,7 +523,7 @@ void _vm_map_lock(vm_map_t map, const char *file, int line) { - if (map->system_map) + if (vm_map_is_system(map)) mtx_lock_flags_(&map->system_mtx, 0, file, line); else sx_xlock_(&map->lock, file, line); @@ -614,7 +614,7 @@ static void _vm_map_assert_locked(vm_map_t map, const char *file, int line) { - if (map->system_map) + if (vm_map_is_system(map)) mtx_assert_(&map->system_mtx, MA_OWNED, file, line); else sx_assert_(&map->lock, SA_XLOCKED, file, line); @@ -657,7 +657,7 @@ _vm_map_unlock(vm_map_t map, const char *file, int line) { VM_MAP_UNLOCK_CONSISTENT(map); - if (map->system_map) { + if (vm_map_is_system(map)) { #ifndef UMA_USE_DMAP if (map == kernel_map && (map->flags & MAP_REPLENISH) != 0) { uma_prealloc(kmapentzone, 1); @@ -675,7 +675,7 @@ void _vm_map_lock_read(vm_map_t map, const char *file, int line) { - if (map->system_map) + if (vm_map_is_system(map)) mtx_lock_flags_(&map->system_mtx, 0, file, line); else sx_slock_(&map->lock, file, line); @@ -685,7 +685,7 @@ void _vm_map_unlock_read(vm_map_t map, const char *file, int line) { - if (map->system_map) { + if (vm_map_is_system(map)) { KASSERT((map->flags & MAP_REPLENISH) == 0, ("%s: MAP_REPLENISH leaked", __func__)); mtx_unlock_flags_(&map->system_mtx, 0, file, line); @@ -700,7 +700,7 @@ _vm_map_trylock(vm_map_t map, const char *file, int line) { int error; - error = map->system_map ? + error = vm_map_is_system(map) ? !mtx_trylock_flags_(&map->system_mtx, 0, file, line) : !sx_try_xlock_(&map->lock, file, line); if (error == 0) @@ -713,7 +713,7 @@ _vm_map_trylock_read(vm_map_t map, const char *file, int line) { int error; - error = map->system_map ? + error = vm_map_is_system(map) ? !mtx_trylock_flags_(&map->system_mtx, 0, file, line) : !sx_try_slock_(&map->lock, file, line); return (error == 0); @@ -734,7 +734,7 @@ _vm_map_lock_upgrade(vm_map_t map, const char *file, int line) { unsigned int last_timestamp; - if (map->system_map) { + if (vm_map_is_system(map)) { mtx_assert_(&map->system_mtx, MA_OWNED, file, line); } else { if (!sx_try_upgrade_(&map->lock, file, line)) { @@ -760,7 +760,7 @@ void _vm_map_lock_downgrade(vm_map_t map, const char *file, int line) { - if (map->system_map) { + if (vm_map_is_system(map)) { KASSERT((map->flags & MAP_REPLENISH) == 0, ("%s: MAP_REPLENISH leaked", __func__)); mtx_assert_(&map->system_mtx, MA_OWNED, file, line); @@ -780,10 +780,9 @@ int vm_map_locked(vm_map_t map) { - if (map->system_map) + if (vm_map_is_system(map)) return (mtx_owned(&map->system_mtx)); - else - return (sx_xlocked(&map->lock)); + return (sx_xlocked(&map->lock)); } /* @@ -806,7 +805,7 @@ _vm_map_unlock_and_wait(vm_map_t map, int timo, const char *file, int line) VM_MAP_UNLOCK_CONSISTENT(map); mtx_lock(&map_sleep_mtx); - if (map->system_map) { + if (vm_map_is_system(map)) { KASSERT((map->flags & MAP_REPLENISH) == 0, ("%s: MAP_REPLENISH leaked", __func__)); mtx_unlock_flags_(&map->system_mtx, 0, file, line); @@ -864,7 +863,7 @@ vm_map_wait_busy(vm_map_t map) VM_MAP_ASSERT_LOCKED(map); while (map->busy) { vm_map_modflags(map, MAP_BUSY_WAKEUP, 0); - if (map->system_map) + if (vm_map_is_system(map)) msleep(&map->busy, &map->system_mtx, 0, "mbusy", 0); else sx_sleep(&map->busy, &map->lock, 0, "mbusy", 0); @@ -927,7 +926,7 @@ vm_map_init_system(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max) static void vm_map_entry_dispose(vm_map_t map, vm_map_entry_t entry) { - uma_zfree(map->system_map ? kmapentzone : mapentzone, entry); + uma_zfree(vm_map_is_system(map) ? kmapentzone : mapentzone, entry); } /* @@ -961,7 +960,7 @@ vm_map_entry_create(vm_map_t map) } } else #endif - if (map->system_map) { + if (vm_map_is_system(map)) { new_entry = uma_zalloc(kmapentzone, M_NOWAIT); } else { new_entry = uma_zalloc(mapentzone, M_WAITOK); @@ -2428,7 +2427,7 @@ vm_map_entry_charge_object(vm_map_t map, vm_map_entry_t entry) VM_MAP_ASSERT_LOCKED(map); KASSERT((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0, ("map entry %p is a submap", entry)); - if (entry->object.vm_object == NULL && !map->system_map && + if (entry->object.vm_object == NULL && !vm_map_is_system(map) && (entry->eflags & MAP_ENTRY_GUARD) == 0) vm_map_entry_back(entry); else if (entry->object.vm_object != NULL && @@ -2493,7 +2492,7 @@ vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t startaddr) vm_map_entry_t new_entry; int bdry_idx; - if (!map->system_map) + if (!vm_map_is_system(map)) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s: map %p entry %p start 0x%jx", __func__, map, entry, (uintmax_t)startaddr); @@ -2536,7 +2535,7 @@ vm_map_lookup_clip_start(vm_map_t map, vm_offset_t start, vm_map_entry_t entry; int rv; - if (!map->system_map) + if (!vm_map_is_system(map)) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s: map %p start 0x%jx prev %p", __func__, map, (uintmax_t)start, prev_entry); @@ -2566,7 +2565,7 @@ vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, vm_offset_t endaddr) vm_map_entry_t new_entry; int bdry_idx; - if (!map->system_map) + if (!vm_map_is_system(map)) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s: map %p entry %p end 0x%jx", __func__, map, entry, (uintmax_t)endaddr); @@ -3936,7 +3935,7 @@ vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry) MPASS(entry->cred == NULL); MPASS((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0); MPASS(object == NULL); - vm_map_entry_deallocate(entry, map->system_map); + vm_map_entry_deallocate(entry, vm_map_is_system(map)); return; } @@ -3987,7 +3986,7 @@ vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry) } VM_OBJECT_WUNLOCK(object); } - if (map->system_map) + if (vm_map_is_system(map)) vm_map_entry_deallocate(entry, TRUE); else { entry->defer_next = curthread->td_map_def_user; @@ -4710,7 +4709,7 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry) p->p_textvp == NULL)) return (KERN_FAILURE); - MPASS(!map->system_map); + MPASS(!vm_map_is_system(map)); lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK); stacklim = lim_cur(curthread, RLIMIT_STACK); @@ -5118,7 +5117,7 @@ RetryLookupLocked: /* * Create an object if necessary. */ - if (entry->object.vm_object == NULL && !map->system_map) { + if (entry->object.vm_object == NULL && !vm_map_is_system(map)) { if (vm_map_lock_upgrade(map)) goto RetryLookup; entry->object.vm_object = vm_object_allocate_anon(atop(size), @@ -5206,7 +5205,7 @@ vm_map_lookup_locked(vm_map_t *var_map, /* IN/OUT */ /* * Fail if an object should be created. */ - if (entry->object.vm_object == NULL && !map->system_map) + if (entry->object.vm_object == NULL && !vm_map_is_system(map)) return (KERN_FAILURE); /* diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 5ecec0531e1c..ed1106734951 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -278,6 +278,12 @@ vm_map_range_valid(vm_map_t map, vm_offset_t start, vm_offset_t end) return (true); } +static inline bool +vm_map_is_system(vm_map_t map) +{ + return ((map->system_map)); +} + #endif /* KLD_MODULE */ #endif /* _KERNEL */ diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index f6c5e6291692..28a54a83fd49 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1844,7 +1844,7 @@ vm_pageout_oom_pagecount(struct vmspace *vmspace) long res; map = &vmspace->vm_map; - KASSERT(!map->system_map, ("system map")); + KASSERT(!vm_map_is_system(map), ("system map")); sx_assert(&map->lock, SA_LOCKED); res = 0; VM_MAP_ENTRY_FOREACH(entry, map) {