From nobody Mon Dec 09 03:28:33 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 4Y66lQ0CxTz5g7kr; Mon, 09 Dec 2024 03:28:34 +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 4Y66lP6nNqz44Tt; Mon, 9 Dec 2024 03:28:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733714914; 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=yw+7iYDDkWoxp7bpEySZbIawHfUBl6tOfquMTA7AupA=; b=ZAevO8SJeDPioTLMmSyE3TFxkoFoAb+MBQZm4Zqd392XRn8vNyFQIiSMVHbSPhOnotoQCK 5s7SQRFoym/1Nj7OWYO3hNzkOcUFzNKZrqvnjOIHCAD0X1n/hv/hWHdWtRX5jTfGu3Nno4 IgUid/Iwc5WD7U3sumL6UmuYFNJRTSy6OoW1a0Rg8gSK1xs85tM9wx74NwQQY61h4xd7Tx 9kTIEGd94SVBImbjyrqDrF+QJogUjLCghC8mjrv6mYfDhzRTgBwEnBWPJ8SOvSETDaesC3 4ONYzG+CDTfODwPWD4fUk1M9bOPNh2sjZnKPhSpT/RsOUj3pwNEVqSgmJl2J9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733714914; 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=yw+7iYDDkWoxp7bpEySZbIawHfUBl6tOfquMTA7AupA=; b=yDSPb5EiGO4NMUC9ZFDnPID+cDJXn868c3tuPTMdn4CN1sNvTRC0fWkwZsyhLQ4y8S74mT gDUWXeWJEIDwiAR7swS8zU6JsJf3EMPwzkn+EC9e3DzuxO5noSMMaQ16BXBSP1yLK+1ciS zBvwybHR06jr6a3+ZczNOAGGr2S/pUEVJkaQfWKKUvAE6wf8S9Y2hS8Gv4Z5kYMaPdVxrb S+OmeT2Ozc+ctw1IEHQWM67eRWPJyYmgnVXuyJ/7QLk4VbLR6c+StPTO6SBwxK43NujqOF 7BapkL/NSz+Uyfpj4LjIR+FD0yuk70oFQKjCAPxPbb//s66xot8ly8pmAt+1PQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733714914; a=rsa-sha256; cv=none; b=psLHDuUnomwo9n+dZfiFXQ3/FwpDBl6bQ0ZBO6CjR1iVxA0VMzJc2r7DwLt+yBGL0m+Oqj g5E2o5UTeyW9k1Dy0/5PsJHNFXelGOWMCyEYN8FmsX+KJx1idLLDeGCwkUmkE1n9vfMUcc 24A7mtdprE0t9eAtiAfGactBcd0Wtje/jsihandWjyzboXjGbfgDPY6+PHEjVXekvosjBy l+bZzqE/I3ZHIWjZgWsqvFthYEq3tq9SnFdxnaT5SCvQikEhJ9xYUZuWw0WQRRIwyVXrbv xjG2MPfLvg41jutlPoRg9lHXPUl8sIWD2ybBsuTTCtJBajsWXXAUEn+IigkRkA== 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 4Y66lP6FhWzLTD; Mon, 9 Dec 2024 03:28:33 +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 4B93SXUg083710; Mon, 9 Dec 2024 03:28:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B93SXxd083707; Mon, 9 Dec 2024 03:28:33 GMT (envelope-from git) Date: Mon, 9 Dec 2024 03:28:33 GMT Message-Id: <202412090328.4B93SXxd083707@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: 6ed68e6f5d47 - main - vm_map: overlap system map mutex and user man sx 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: 6ed68e6f5d47ca30716d4e06c1452e68530970db Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6ed68e6f5d47ca30716d4e06c1452e68530970db commit 6ed68e6f5d47ca30716d4e06c1452e68530970db Author: Konstantin Belousov AuthorDate: 2024-12-05 22:44:08 +0000 Commit: Konstantin Belousov CommitDate: 2024-12-09 03:27:44 +0000 vm_map: overlap system map mutex and user man sx This saves 616-584 = 32 bytes per struct vmspace on amd64, which allows to pack 7 vmspaces per page vs. 6 for non-overlapping layout. I used anonymous union member feature to avoid too much churn. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47934 --- sys/vm/vm_kern.c | 3 +-- sys/vm/vm_map.c | 18 +++++++++++------- sys/vm/vm_map.h | 7 +++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index a748a6c57d65..29a64a0fe6d8 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -830,8 +830,7 @@ kmem_init(vm_offset_t start, vm_offset_t end) vm_size_t quantum; int domain; - vm_map_init(kernel_map, kernel_pmap, VM_MIN_KERNEL_ADDRESS, end); - kernel_map->system_map = 1; + vm_map_init_system(kernel_map, kernel_pmap, VM_MIN_KERNEL_ADDRESS, end); vm_map_lock(kernel_map); /* N.B.: cannot use kgdb to debug, starting with this assignment ... */ (void)vm_map_insert(kernel_map, NULL, 0, diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 910ebfb6dc4e..c3aa499e0dc7 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -292,9 +292,7 @@ vmspace_zinit(void *mem, int size, int flags) vm = (struct vmspace *)mem; map = &vm->vm_map; - memset(map, 0, sizeof(*map)); - mtx_init(&map->system_mtx, "vm map (system)", NULL, - MTX_DEF | MTX_DUPOK); + memset(map, 0, sizeof(*map)); /* set map->system_map = false */ sx_init(&map->lock, "vm map (user)"); PMAP_LOCK_INIT(vmspace_pmap(vm)); return (0); @@ -890,7 +888,6 @@ _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max) map->header.eflags = MAP_ENTRY_HEADER; map->needs_wakeup = FALSE; - map->system_map = 0; map->pmap = pmap; map->header.end = min; map->header.start = max; @@ -908,13 +905,20 @@ _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max) void vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max) { - _vm_map_init(map, pmap, min, max); - mtx_init(&map->system_mtx, "vm map (system)", NULL, - MTX_DEF | MTX_DUPOK); + map->system_map = false; sx_init(&map->lock, "vm map (user)"); } +void +vm_map_init_system(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max) +{ + _vm_map_init(map, pmap, min, max); + map->system_map = true; + mtx_init(&map->system_mtx, "vm map (system)", NULL, MTX_DEF | + MTX_DUPOK); +} + /* * vm_map_entry_dispose: [ internal use only ] * diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index d0b4bb52968e..5ecec0531e1c 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -203,8 +203,10 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry) */ struct vm_map { struct vm_map_entry header; /* List of entries */ - struct sx lock; /* Lock for map data */ - struct mtx system_mtx; + union { + struct sx lock; /* Lock for map data */ + struct mtx system_mtx; + }; int nentries; /* Number of entries */ vm_size_t size; /* virtual size */ u_int timestamp; /* Version number */ @@ -484,6 +486,7 @@ int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t); int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); +void vm_map_init_system(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int); int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, vm_pindex_t *, vm_prot_t *, boolean_t *);