From nobody Tue Jul 30 15:38:48 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 4WYKBw3rqWz5RRKc; Tue, 30 Jul 2024 15:38:48 +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 4WYKBw1dN6z42Lw; Tue, 30 Jul 2024 15:38:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722353928; 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=VeE7cpQTvzXJvAK375Scb2qqUQFCQ8dFCb6cwZZ4K14=; b=q9pMGw2x+lXbXzT0f/E5L9PCO++i//4DnEd2kmUy1m+XyoWBDIenxNwWFYaASaOt/OoR31 1pT8l7bsXWn3zuX8LUw8OpDqTW1Jm4T3DEMgi27zag1/aDLp4cAx/XOoYqGaSkT9hftfDu Sf6Vh4rk9+M1xcjcL2K3GHUJcPiOHCqX2EFIaW8qNoRwyTJo1Bou6NKPPYAUIuYw1nLb6v f2J3ti6vPHPEc4SKn6BDX0Zdw5rFHpzsEIDsXJyFx5P4wF15y2oqWa/CSMpmaYNamUUSzx loIzxwkCcrchaZhPh36dZpU7SeMIi2HhkObNfEF0SDEj/IDum05urAwuKPnz0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722353928; a=rsa-sha256; cv=none; b=H04LSt2sL+5cUE68ONcNTEnTYeqE5Ma968yHl0NFYhu4K4q5i6ktU0L/n34dmp9LmgF1v4 UjmJHEwIm1CTpOHqRkUiOT4cJ6l0ZKdUI5b7FdggJRyGZ63dRSsghjj0DHwUfo+o4NDZsD rRpHl9ZMbe/MduvGkQ5K7XfrrJ7GP9tseHAtZDNIjIOiWCrKkXXDchR1xpO6CL1BTasjwF n4iQOK5FzRbDwgUk4KIjwSLkFQ0pzPgD6WNM0OGASzXMGQzHGuL3mg/yJQc1SliJAad5pY CIrsgH26Pco6/YHYOcAI3eU2HKtYkZeuG3Bzz5+TKBKdNyBmMStMGBVyZZwJsA== 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=1722353928; 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=VeE7cpQTvzXJvAK375Scb2qqUQFCQ8dFCb6cwZZ4K14=; b=M20Ht3tMOu2353QKUKcNl5xelM5yQ9IdSAyDFjUJoOiRxVCs7NsyJIAe2FtSksYfQMW2sQ IC4+mQ8P8yNllLIWDrSdK8xoAyOSFCQc3JR+9AoTDg8Gs+QIqmJBOqyPpoaay5xm5aHOrZ JmtEhXXP+thCpm2SuJLUCehLhAIQnS0Fc/Wzljsu7mZHqZh4OrC5sPLNSfIPiYMH8ZVqQs QzNBr8VynSYc9JdsnPA84buoyQccPJ4pJCYs1ish88wBLPO1XTv4e4TaTQ7wn2BR8Ve1Xj T6Ym9dGFVLFhlD12mGhXIvnRNo1Bj3rNJ4WiwIqVFmTZ6cBjYdh2HUVp5YIV0w== 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 4WYKBw1Dx6zNc2; Tue, 30 Jul 2024 15:38:48 +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 46UFcmK7049650; Tue, 30 Jul 2024 15:38:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46UFcmoH049647; Tue, 30 Jul 2024 15:38:48 GMT (envelope-from git) Date: Tue, 30 Jul 2024 15:38:48 GMT Message-Id: <202407301538.46UFcmoH049647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bojan =?utf-8?Q?Novkovi=C4=87?= Subject: git: 3f32a7e4eee5 - main - vm: Add a KVA arena for M_NEVERFREED allocations 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: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f32a7e4eee53d5565a4076e69a41d1afd803e0c Auto-Submitted: auto-generated The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=3f32a7e4eee53d5565a4076e69a41d1afd803e0c commit 3f32a7e4eee53d5565a4076e69a41d1afd803e0c Author: Bojan Novković AuthorDate: 2024-07-16 14:14:30 +0000 Commit: Bojan Novković CommitDate: 2024-07-30 15:38:24 +0000 vm: Add a KVA arena for M_NEVERFREED allocations This patch adds a new KVA arena for separating M_NEVERFREED allocations. Separating KVAs for pages that are never freed should facilitate superpage promotion in the kernel. Differential Revision: https://reviews.freebsd.org/D45997 Reviewed by: alc, kib, markj Tested by: alc --- sys/vm/vm_kern.c | 21 ++++++++++++++++----- sys/vm/vm_pagequeue.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index a04044463fe2..fb7c80b767ed 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -473,10 +473,12 @@ kmem_malloc_domain(int domain, vm_size_t size, int flags) vm_size_t asize; int rv; - if (__predict_true((flags & M_EXEC) == 0)) + if (__predict_true((flags & (M_EXEC | M_NEVERFREED)) == 0)) arena = vm_dom[domain].vmd_kernel_arena; - else + else if ((flags & M_EXEC) != 0) arena = vm_dom[domain].vmd_kernel_rwx_arena; + else + arena = vm_dom[domain].vmd_kernel_nofree_arena; asize = round_page(size); if (vmem_alloc(arena, asize, flags | M_BESTFIT, &addr)) return (0); @@ -882,20 +884,29 @@ kmem_init(vm_offset_t start, vm_offset_t end) /* * In architectures with superpages, maintain separate arenas * for allocations with permissions that differ from the - * "standard" read/write permissions used for kernel memory, - * so as not to inhibit superpage promotion. + * "standard" read/write permissions used for kernel memory + * and pages that are never released, so as not to inhibit + * superpage promotion. * - * Use the base import quantum since this arena is rarely used. + * Use the base import quantum since these arenas are rarely + * used. */ #if VM_NRESERVLEVEL > 0 vm_dom[domain].vmd_kernel_rwx_arena = vmem_create( "kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); + vm_dom[domain].vmd_kernel_nofree_arena = vmem_create( + "kernel NOFREE arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena, kva_import_domain, (vmem_release_t *)vmem_xfree, kernel_arena, KVA_QUANTUM); + vmem_set_import(vm_dom[domain].vmd_kernel_nofree_arena, + kva_import_domain, (vmem_release_t *)vmem_xfree, + kernel_arena, KVA_QUANTUM); #else vm_dom[domain].vmd_kernel_rwx_arena = vm_dom[domain].vmd_kernel_arena; + vm_dom[domain].vmd_kernel_nofree_arena = + vm_dom[domain].vmd_kernel_arena; #endif } diff --git a/sys/vm/vm_pagequeue.h b/sys/vm/vm_pagequeue.h index 86863a0a6400..af1183e63e53 100644 --- a/sys/vm/vm_pagequeue.h +++ b/sys/vm/vm_pagequeue.h @@ -243,6 +243,7 @@ struct vm_domain { } vmd_pgcache[VM_NFREEPOOL]; struct vmem *vmd_kernel_arena; /* (c) per-domain kva R/W arena. */ struct vmem *vmd_kernel_rwx_arena; /* (c) per-domain kva R/W/X arena. */ + struct vmem *vmd_kernel_nofree_arena; /* (c) per-domain kva NOFREE arena. */ u_int vmd_domain; /* (c) Domain number. */ u_int vmd_page_count; /* (c) Total page count. */ long vmd_segs; /* (c) bitmask of the segments */