From nobody Tue May 19 03:22:41 2026 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 4gKKjt4Kq3z6ddv4 for ; Tue, 19 May 2026 03:22:42 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gKKjs73j1z3KRp for ; Tue, 19 May 2026 03:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779160962; 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=B/cMTlBn1uv9pgMhdktSCZVOKEZIBOf1isihQDhscKo=; b=qYj8aB9dbPutZd57phYu0YU47Jps+7MY9YTDYOak++5yFuPVE5Mu6VRhh3MWMTICqbMV8w FjabE7ftsisaWZg8MAHitOkXLgxn7dE4AVpsLKY5EhowbU4fMYOoCIRtUrmWZq8BAtIS4K rf6X1G2OZnHDcSYH00tyQQzFYXGzf2IbVun/Z1A6z3rW3vJxodlTcmM+7U9RBSOWfGK8xV fsPiUH0gQyE/3JLay1zonyMcw5sdk3eV7eneXl3wi1PG69TiT6EYbGMMrgv0Jsux+MqQif dw4ktWDHVupZDBYqrsZCWf9vJUKJNJ+T0OkYmqLIrqa5aiT8RxDuHdLjKtDRww== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779160962; a=rsa-sha256; cv=none; b=GeI6TjmHOMsiL3mlTM7vEcZ8SL/8KaZ/OZiJewbaRHGZNDLmn1qnQgxbZ/AQ0V5AGBO+/I kC0SBmJUuy4Xf+d9nCaVFMOcZ/q1x3y22Vi9yfLAUZTXdWJJgMrvwnoQghqZ7RwU/V7D5J vSyrp1oagirJiHqmYyTE7py/Lcq5nxFjg47DNWALIf3upOXrke0CJYMSxqn4macGkTPaOY 9KoH9l8PE0xC+CXtMAUCgN+scnOHhDe/ZVki1zouYimh7eccETeZYRVBUQ1vsVK7M38QTW sOw34ai9nrpa8ok/Iti6O2ClpnsTpn3RgnmMn+VLr8o4cu1fuAKObqQKawLFPQ== 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=1779160962; 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=B/cMTlBn1uv9pgMhdktSCZVOKEZIBOf1isihQDhscKo=; b=SUywWk6kZkFVgkenjMkrpLpjErjO4jLX04tJP0ljuU2kUhcEm5OX6RuABZuvPNBb+8Y+qs DngsLyXcMtHWfdiOSkFRyEqUEmuWuJ5bVZUZdalhTZqh8sS3+8IjrCvhyIZAU3hUfeniXO oGcex7l3xCOeVl0GyNUzv29oE60yhuUB58LsCh+pjvWr6oNnCokSIbBT+O14v4eeuipjUH Y81hh+1IEpwKsWJVRSxJpzDcI7goNi+qzS0MFzPJ+nNxwoft+DuSaxVVFwp4lQXi8PR+1b 5QjzHLJYKNDblkD0UTQej7h/8kowtFy3Inob/BNZEkt0lLs3pWBALA030q+sBQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gKKjs5rRqzxCv for ; Tue, 19 May 2026 03:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3f330 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 19 May 2026 03:22:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 67f7f2781daa - main - linuxkpi: work with numpages > 1 in the set_pages_*() KPIs 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 67f7f2781daa9bd398b424ffe2bd0be67f37f03d Auto-Submitted: auto-generated Date: Tue, 19 May 2026 03:22:41 +0000 Message-Id: <6a0bd781.3f330.9bd5956@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=67f7f2781daa9bd398b424ffe2bd0be67f37f03d commit 67f7f2781daa9bd398b424ffe2bd0be67f37f03d Author: Kyle Evans AuthorDate: 2026-05-19 03:22:21 +0000 Commit: Kyle Evans CommitDate: 2026-05-19 03:22:21 +0000 linuxkpi: work with numpages > 1 in the set_pages_*() KPIs These calls are used for buddy pages at least in drm's ttm_pool, which leads to a panic when we invoke lowmem handlers and drm tries to shrink the pool. Cope with numpages > 1 by traversing the contiguous pages and executing the adjustment there, as well, as suggested by markj@. Previous versions have tried to use the corresponding `set_memory_*()` functions, but it is believed that not updating `md.pat_mode` breaks subsequent userspace mappings in ways that may result in things like screen tearing or other artifacts when running i915kms. This stabilized my amdgpu laptop running two VMs, chromium and a concurrent buildworld. Reviewed by: bz, markj Differential Revision: https://reviews.freebsd.org/D57004 --- sys/compat/linuxkpi/common/include/asm/set_memory.h | 17 +++++------------ sys/compat/linuxkpi/common/src/linux_page.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/asm/set_memory.h b/sys/compat/linuxkpi/common/include/asm/set_memory.h index f328fcabd243..f45a51a9710b 100644 --- a/sys/compat/linuxkpi/common/include/asm/set_memory.h +++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h @@ -62,35 +62,28 @@ set_memory_wb(unsigned long addr, int numpages) return (-pmap_change_attr((void *)addr, len, VM_MEMATTR_WRITE_BACK)); } +int lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma); + static inline int set_pages_uc(struct page *page, int numpages) { - KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); - - pmap_page_set_memattr(page, VM_MEMATTR_UNCACHEABLE); - return (0); + return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_UNCACHEABLE)); } static inline int set_pages_wc(struct page *page, int numpages) { - KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); - #ifdef VM_MEMATTR_WRITE_COMBINING - pmap_page_set_memattr(page, VM_MEMATTR_WRITE_COMBINING); + return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_WRITE_COMBINING)); #else return (set_pages_uc(page, numpages)); #endif - return (0); } static inline int set_pages_wb(struct page *page, int numpages) { - KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); - - pmap_page_set_memattr(page, VM_MEMATTR_WRITE_BACK); - return (0); + return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_WRITE_BACK)); } static inline int diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index b91115a5ff16..62bfa07dd297 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -710,6 +710,27 @@ lkpi_arch_phys_wc_del(int reg) #endif } +int +lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma) +{ + while (numpages-- > 0) { + /* + * pmap_page_set_memattr() would only update the DMAP mapping + * if it's a normal page, leaving the kernel map untouched. + */ + MPASS(page->object != kernel_object); + + /* + * pmap_page_set_memattr() sets page->md.pat_mode, which is + * crucial for future userspace mappings. + */ + pmap_page_set_memattr(page, ma); + page++; + } + + return (0); +} + /* * This is a highly simplified version of the Linux page_frag_cache. * We only support up-to 1 single page as fragment size and we will