From nobody Wed Jun 10 04:01:16 2026 X-Original-To: dev-commits-src-branches@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 4gZsXD4ztzz6gvXm for ; Wed, 10 Jun 2026 04:01:16 +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 4gZsXD2K4Fz3wN5 for ; Wed, 10 Jun 2026 04:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064076; 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=ZULIPO0IbnQCz/jgcHVeULelrmKLmPR+7RN9OrZhnrs=; b=g8F9w2K8KfAjxOmO6Gz0PFeV/tfkuDyN4t7BEa5tRT5jtDSIgVOjRW2GtDl/R9OONJCDBB FRKMXuf4ml9SeRFNkbZwSEvP3LZz0HTohT6mnW7ZmhL1osMxbnXBo+cj356bJxs3zICZav wBm5h0FC2G8DsEJx3AZFz21onhArLEcrVx4qR7Csz1xu77lDBCgMC+c2Ro1eOyJm28G9og bXEN1uvy9V6qEm44d7UcSXDgLdeHJ1OSFTkFyURZ+WmM3xoDjS+CIBwe6DAedooRyb+7ho L+ECDm5u0muukultSgeYhRwcnTBp1wveFv07eBD0EXAXbm5kRssdpmi2Xq2DIQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781064076; a=rsa-sha256; cv=none; b=mE1x9qchxcrh/1s/bWMut5GbiFpTGcgtS7Q9QQDBmYQ1Hpgw57mXbBS3sh12QWu2OcaYmN mlQj1JEFcF9S5JVFSGwVtzv0EDWaQGpZ6Ae0tUVsnrtnDZModnOq2lVeLcbRaLevvYiVIT rgyshZiN/jId4+2N5ml8h91HqgOiw+PRu7FgblLORO1mA1vnMlDd4jCd/aR5O1LpWrLcQ0 GPUy7/K83cCzXixydEDx7EtrSWycFSsZL6P63rMCSgfJUHqCbig3dhzNkcLD0sf6iKTGqf AiNoyn1Er0DLIhlZWy/wZzZY7YgzVgdzzs3zVHQEFQG+LtdK3DMmXU4hVqbXjw== 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=1781064076; 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=ZULIPO0IbnQCz/jgcHVeULelrmKLmPR+7RN9OrZhnrs=; b=CISVhBmunwsfrUgTv0trWG4NnIhvj7lc8zn02+lFrTWoJRE7jY4abDc3Qd+JhpQu8w6J6t gjreF7KgBPk3r7TSyeRjp+0gC0bQUr0YT0LoSEIn4fFlWb9qBT0ueVPQwifWylSDenef1Y Y+UHqsnq1wvBCq1CL8dGGKtUZ836RzRFXaZ+VrNX3ER+GqAQ9G5wWko3sHyPBkPanI4z6K CS5HeFRaog/U1ha67hE8i6xVdoQuuuMAiXhN+YYCpIC7KN9g5q/IhbYivPr2JDVWBQKjmp 8Age9EEugNs414bLsytKEAyeUDzWrzXho0uLcMbkbr2naYYKlCsvO4HeuYow6g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZsXD1pfvz14hF for ; Wed, 10 Jun 2026 04:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 258f5 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 04:01:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 92a2764ba175 - stable/15 - linuxkpi: work with numpages > 1 in the set_pages_*() KPIs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/15 X-Git-Reftype: branch X-Git-Commit: 92a2764ba175e5af550d96a4b509d7776c6dffa6 Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 04:01:16 +0000 Message-Id: <6a28e18c.258f5.2a285432@gitrepo.freebsd.org> The branch stable/15 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=92a2764ba175e5af550d96a4b509d7776c6dffa6 commit 92a2764ba175e5af550d96a4b509d7776c6dffa6 Author: Kyle Evans AuthorDate: 2026-05-19 03:22:21 +0000 Commit: Kyle Evans CommitDate: 2026-06-10 04:00:37 +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 (cherry picked from commit 67f7f2781daa9bd398b424ffe2bd0be67f37f03d) (cherry picked from commit 8dad29555a5807bf21941807752e1589e20312de) --- sys/compat/linuxkpi/common/include/asm/set_memory.h | 15 +++------------ sys/compat/linuxkpi/common/include/linux/page.h | 2 ++ sys/compat/linuxkpi/common/src/linux_page.c | 21 +++++++++++++++++++++ 3 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 1019aaf264a0..54a1311ef9a5 100644 --- a/sys/compat/linuxkpi/common/include/asm/set_memory.h +++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h @@ -65,32 +65,23 @@ set_memory_wb(unsigned long addr, int numpages) 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/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h index 37ab593a64e9..6f5f37d2fd0f 100644 --- a/sys/compat/linuxkpi/common/include/linux/page.h +++ b/sys/compat/linuxkpi/common/include/linux/page.h @@ -127,4 +127,6 @@ clflush_cache_range(void *addr, unsigned int size) } #endif +int lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma); + #endif /* _LINUXKPI_LINUX_PAGE_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index d8b65a12dc67..f562bd5e0dbd 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