From nobody Wed Jun 10 04:01:07 2026 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 4gZsX41pwGz6gvWq for ; Wed, 10 Jun 2026 04:01:08 +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 4gZsX364PRz3wDQ for ; Wed, 10 Jun 2026 04:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064067; 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=hX17wDD/B+ZUpRx6a2SLFbAY960AU2cExL+dV19kMUM=; b=hAjmuCp+6VTutouPqJet1iHdirN3wYOkRLngzmtE/STD+wBow16ticQ6/v//XJHU0vYBIg rbO7CiJ7h0DB2CJGn9hC43N/dVtswyzxx2h4kuWiQeBT2zj4hcFwrvvPJgFbJ1fFnUK0X8 i06hybBygg29LyKHQznqZTTKJGu/HLT6WI1Uu4/qK1C8o2bm+z0JzVMuMlu7u8Lt+Rar4c AV0iZFNkJ5l5cdzrJ4G+uuSd4e1iaXCKQXsd0bFXHbCGVA+fugIShJLQeBGJzIUgmBXT4R cF2fJ1jKfpN6NAI1Ce0lBYVCBeAYSoBrpCCqDdZd7X5Q3P8STzOqsHNFfiTWNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781064067; a=rsa-sha256; cv=none; b=lTL3m2xVFMf5JP+1fz45JCi4hxNLeAMIxETUWa5a/z3yAXsTwNb95VOnQDZMm9U20vcj4k 3B/Cx7gG3QxkaIPOBqMOvq3m/EapiuUKR6cqz/pnO6iEu0u06L3mOjTn9Mjlw4zr2Z0JvM O0It6lfwK2cgqkhFwTkM2+kaNhrjl1xGPGhk0L18wsB/8NOWwCx85qfPMXux4hkWbqkPs1 aRsinhnuPhIwXovSlo2aAr6LindsE0tcVCZScLahsxJRkks2CJ7jLjd0j9N9i6K4xi4vfO 9g7u6rZTm/S3z6o4HYGb4r8O0DUrhcgoCJgKa5E8utAax2pUJ2DZpxGXchZhRw== 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=1781064067; 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=hX17wDD/B+ZUpRx6a2SLFbAY960AU2cExL+dV19kMUM=; b=v/hp2bMmEqg4p1KXBt379k1y1164FJR39JX2EdXKanmPWknT7y8WCpzjd98QBud/g35waU jDOFRo1HTaZvleYVnFf01vJ9aE72bzzlai5OWxzqugqMUSTqshO/Ihdzefzfpa5Y9Vmo3G uo/7J154eeB0Db7SAtT4qoqfZGtyzphnDLUVsnIsZPcUCo6TLD1K4xTHlEe5ioqujC9uqj +x5xypUX39HHcUvcQgrE7/38M93fmoc/tb5jWKqFVTruZ9FqbJ2IYBfGlJdXp01ih7KU7h iDLA1ztvVLlHxuwY3rAVbGZlsIk85yL9XLNRlamb/QtyNwc7Hn+OlS0tx+oJkg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZsX35KKHz14VH for ; Wed, 10 Jun 2026 04:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25e67 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 04:01:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 2db75e8df850 - stable/14 - linuxkpi: work with numpages > 1 in the set_pages_*() KPIs 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 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/14 X-Git-Reftype: branch X-Git-Commit: 2db75e8df85044a9865c62d44f4261041f2bbcbc Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 04:01:07 +0000 Message-Id: <6a28e183.25e67.19fe04ab@gitrepo.freebsd.org> The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=2db75e8df85044a9865c62d44f4261041f2bbcbc commit 2db75e8df85044a9865c62d44f4261041f2bbcbc Author: Kyle Evans AuthorDate: 2026-05-19 03:22:21 +0000 Commit: Kyle Evans CommitDate: 2026-06-10 04:00:47 +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 15b90eb3c470..3eb2fab03359 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -512,6 +512,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