drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute: BUILD_BUG failed
Subsystems (3)
kernel test robot
build bot::::::
:::::: Manual check reason: "__compiletime_assert_NNN" ::::::
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Matthew Brost <[email protected]>
CC: Francois Dugast <[email protected]>
CC: Balbir Singh <[email protected]>
Hi Matthew,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 1590cf0329716306e948a8fc29f1d3ee87d3989f commit: 139ab31aea8a9436460568d556b432bb7e9311f7 drm/pagemap: Correct cpages calculation for migrate_vma_setup date: 4 months ago
:::::: branch date: 15 hours ago
:::::: commit date: 4 months ago
config: s390-randconfig-r062-20260720 (https://download.01.org/0day-ci/archive/20260720/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260720/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Fixes: 139ab31aea8a ("drm/pagemap: Correct cpages calculation for migrate_vma_setup")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/All errors (new ones prefixed by >>):
>> drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute: BUILD_BUG failed
480 | order = HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
| ^
include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
| ^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:694:2: note: expanded from macro '_compiletime_assert'
694 | __compiletime_assert(condition, msg, prefix, suffix)
| ^
include/linux/compiler_types.h:687:4: note: expanded from macro '__compiletime_assert'
687 | prefix ## suffix(); \
| ^
<scratch space>:91:1: note: expanded from here
91 | __compiletime_assert_458
| ^1 error generated.
vim +480 drivers/gpu/drm/drm_pagemap.c
ec265e1f1cfcce Thomas Hellström 2025-12-19 454
139ab31aea8a94 Matthew Brost 2026-03-12 455 /**
139ab31aea8a94 Matthew Brost 2026-03-12 456 * drm_pagemap_cpages() - Count collected pages
139ab31aea8a94 Matthew Brost 2026-03-12 457 * @migrate_pfn: Array of migrate_pfn entries to account
139ab31aea8a94 Matthew Brost 2026-03-12 458 * @npages: Number of entries in @migrate_pfn
139ab31aea8a94 Matthew Brost 2026-03-12 459 *
139ab31aea8a94 Matthew Brost 2026-03-12 460 * Compute the total number of minimum-sized pages represented by the
139ab31aea8a94 Matthew Brost 2026-03-12 461 * collected entries in @migrate_pfn. The total is derived from the
139ab31aea8a94 Matthew Brost 2026-03-12 462 * order encoded in each entry.
139ab31aea8a94 Matthew Brost 2026-03-12 463 *
139ab31aea8a94 Matthew Brost 2026-03-12 464 * Return: Total number of minimum-sized pages.
139ab31aea8a94 Matthew Brost 2026-03-12 465 */
139ab31aea8a94 Matthew Brost 2026-03-12 466 static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages)
139ab31aea8a94 Matthew Brost 2026-03-12 467 {
139ab31aea8a94 Matthew Brost 2026-03-12 468 unsigned long i, cpages = 0;
139ab31aea8a94 Matthew Brost 2026-03-12 469
139ab31aea8a94 Matthew Brost 2026-03-12 470 for (i = 0; i < npages;) {
139ab31aea8a94 Matthew Brost 2026-03-12 471 struct page *page = migrate_pfn_to_page(migrate_pfn[i]);
139ab31aea8a94 Matthew Brost 2026-03-12 472 struct folio *folio;
139ab31aea8a94 Matthew Brost 2026-03-12 473 unsigned int order = 0;
139ab31aea8a94 Matthew Brost 2026-03-12 474
139ab31aea8a94 Matthew Brost 2026-03-12 475 if (page) {
139ab31aea8a94 Matthew Brost 2026-03-12 476 folio = page_folio(page);
139ab31aea8a94 Matthew Brost 2026-03-12 477 order = folio_order(folio);
139ab31aea8a94 Matthew Brost 2026-03-12 478 cpages += NR_PAGES(order);
139ab31aea8a94 Matthew Brost 2026-03-12 479 } else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) {
139ab31aea8a94 Matthew Brost 2026-03-12 @480 order = HPAGE_PMD_ORDER;
139ab31aea8a94 Matthew Brost 2026-03-12 481 cpages += NR_PAGES(order);
139ab31aea8a94 Matthew Brost 2026-03-12 482 }
139ab31aea8a94 Matthew Brost 2026-03-12 483
139ab31aea8a94 Matthew Brost 2026-03-12 484 i += NR_PAGES(order);
139ab31aea8a94 Matthew Brost 2026-03-12 485 }
139ab31aea8a94 Matthew Brost 2026-03-12 486
139ab31aea8a94 Matthew Brost 2026-03-12 487 return cpages;
139ab31aea8a94 Matthew Brost 2026-03-12 488 }
139ab31aea8a94 Matthew Brost 2026-03-12 489 --
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 1/1 drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
HPAGE_PMD_SHIFT expands to BUILD_BUG() when CONFIG_PGTABLE_HAS_HUGE_LEAVES is not set, causing a compile error when both CONFIG_TRANSPARENT_HUGEPAGE and CONFIG_HUGETLB_PAGE are disabled:
drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute: BUILD_BUG failed
480 | order = HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
Guard the two HPAGE_PMD_ORDER uses with CONFIG_ARCH_ENABLE_THP_MIGRATION, matching the pattern used in migrate_device.c.
--- drivers/gpu/drm/drm_pagemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_pagemap.c +8 -2
@@ -578,10 +578,13 @@ static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) folio =page_folio (page); order =folio_order (folio); cpages +=NR_PAGES (order); - }else if (migrate_pfn[i] &MIGRATE_PFN_COMPOUND ) { + } +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION + else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) { order =HPAGE_PMD_ORDER ; cpages +=NR_PAGES (order); } +#endif i +=NR_PAGES (order); }
@@ -733,7 +736,6 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, own_pages =0 ;for (i =0 ; i < npages;) { -unsigned long j;struct page *page =pfn_to_page (migrate.dst[i]);struct page *src_page =migrate_pfn_to_page (migrate.src[i]);unsigned int order =0 ;
@@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, } migrate.dst[i] =migrate_pfn (migrate.dst[i]); +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (migrate.src[i] &MIGRATE_PFN_COMPOUND ) { +unsigned long j; +drm_WARN_ONCE (dpagemap->drm, src_page &&folio_order (page_folio (src_page)) !=HPAGE_PMD_ORDER ,"Unexpected folio order\n" );
@@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,for (j =1 ; j <NR_PAGES (order) && i + j < npages; j++) migrate.dst[i + j] = 0; } +#endif drm_pagemap_get_devmem_page (page, order, zdd);
Signature · 1 line
2.52.0
[email protected]
AI reviewRe: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Aborting a migration mid-loop leaves raw device PFNs in the migration array, causing a bogus pointer dereference and kernel panic in migrate_vma_pages(). --
--- Patch [1]: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION --- commit 66a306e51148532e3b7d883d3232632355c05797
Author: Jan Stancek <[email protected]>
drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
This commit fixes a compile error when both CONFIG_TRANSPARENT_HUGEPAGE and CONFIG_HUGETLB_PAGE are disabled. It guards HPAGE_PMD_ORDER uses with CONFIG_ARCH_ENABLE_THP_MIGRATION.
Quoted 4 lines
drivers/gpu/drm/drm_pagemap.c +0
-0
[ ... ]
Quoted 12 lines
drivers/gpu/drm/drm_pagemap.c +3
-0@@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, } migrate.dst[i] =migrate_pfn (migrate.dst[i]); +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (migrate.src[i] &MIGRATE_PFN_COMPOUND ) { +unsigned long j; +drm_WARN_ONCE (dpagemap->drm, src_page &&folio_order (page_folio (src_page)) !=HPAGE_PMD_ORDER ,"Unexpected folio order\n" );
drivers/gpu/drm/drm_pagemap.c int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, · line 784
Quoted 6 lines
drivers/gpu/drm/drm_pagemap.c +1
-0@@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,for (j =1 ; j <NR_PAGES (order) && i + j < npages; j++) migrate.dst[i + j] = 0; } +#endif drm_pagemap_get_devmem_page (page, order, zdd);
[Severity: Critical]
This is a pre-existing issue, but can the error path here leave raw device PFNs in the migration array, causing a bogus pointer dereference in migrate_vma_pages()?
In drm_pagemap_migrate_to_devmem(), ops->populate_devmem_pfn() populates migrate.dst with sequential raw device PFNs. The loop processes these and converts them into the migrate_pfn() format. If a migration batch fails mid-loop:
err = drm_pagemap_migrate_range(...);
if (err) {
npages = i + 1;
goto err_finalize;
}The error path zeros out migrate.dst entries up to index i, and then falls through to err_aborted_migration:
err_finalize:
if (err) drm_pagemap_migration_unlock_put_pages(npages, migrate.dst); err_aborted_migration: migrate_vma_pages(&migrate);
Because migrate_vma_pages() iterates up to the original migrate.npages, unprocessed entries (where index > i) still contain unformatted raw PFNs. Since PFNs are sequential, half of them are odd numbers, meaning bit 0 (MIGRATE_PFN_VALID) is set.
Will __migrate_device_pages() misinterpret these odd raw PFNs as valid migration entries, leading to a dereference of a completely bogus struct page pointer when it calls pfn_to_page()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/84a35e16f72330d6e7b2d6e969040f36959e2dad.1784630290.git.jstancek@redhat.com?part=1
Matthew Brost
maintainerRe: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
In reply to Jan StancekQuoted 30 lines · Jan Stancek
HPAGE_PMD_SHIFTexpands toBUILD_BUG()whenCONFIG_PGTABLE_HAS_HUGE_LEAVESis not set, causing a compile error when bothCONFIG_TRANSPARENT_HUGEPAGEandCONFIG_HUGETLB_PAGEare disabled:
drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute:BUILD_BUGfailed
480 | order =HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #defineHPAGE_PMD_ORDER(HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #defineHPAGE_PMD_SHIFT({BUILD_BUG(); 0; })Guard the two
HPAGE_PMD_ORDERuses withCONFIG_ARCH_ENABLE_THP_MIGRATION, matching the pattern used inmigrate_device.c.Fixes 139ab31aea8a ("drm/pagemap: Correct cpages calculation for migrate_vma_setup")Reported-by kernel test robot <[email protected]>Signed-off-by Jan Stancek <[email protected]>--- drivers/gpu/drm/drm_pagemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_pagemap.c +0
-0
drivers/gpu/drm/drm_pagemap.c static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) · line 584
Quoted 8 lines
drivers/gpu/drm/drm_pagemap.c +3
-1@@ -578,10 +578,13 @@ static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) folio =page_folio (page); order =folio_order (folio); cpages +=NR_PAGES (order); - }else if (migrate_pfn[i] &MIGRATE_PFN_COMPOUND ) { + } +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION + else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) { order =HPAGE_PMD_ORDER ;
Would it be do something like this at the top of the file...
#ifdef HPAGE_PMD_ORDER
#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER
#else
#define DRM_PAGEMAP_PMD_ORDER (-1)
#endif
Then in common code s/HPAGE_PMD_ORDER/DRM_PAGEMAP_PMD_ORDER/
I think this works as we can never get to the MIGRATE_PFN_COMPOUND code paths without CONFIG_ARCH_ENABLE_THP_MIGRATION enabled (see mm/migrate_device.c).
Also btw fixing the unrelated bug Sashiko flagged in this patch.
Matt
Quoted 36 lines
drivers/gpu/drm/drm_pagemap.c +5
-1cpages += NR_PAGES(order); } +#endif i +=NR_PAGES (order); }@@ -733,7 +736,6 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, own_pages =0 ;for (i =0 ; i < npages;) { -unsigned long j;struct page *page =pfn_to_page (migrate.dst[i]);struct page *src_page =migrate_pfn_to_page (migrate.src[i]);unsigned int order =0 ;@@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, } migrate.dst[i] =migrate_pfn (migrate.dst[i]); +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (migrate.src[i] &MIGRATE_PFN_COMPOUND ) { +unsigned long j; +drm_WARN_ONCE (dpagemap->drm, src_page &&folio_order (page_folio (src_page)) !=HPAGE_PMD_ORDER ,"Unexpected folio order\n" );@@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,for (j =1 ; j <NR_PAGES (order) && i + j < npages; j++) migrate.dst[i + j] = 0; } +#endif drm_pagemap_get_devmem_page (page, order, zdd);Signature · 1 line
2.52.0
Matthew Brost
maintainerRe: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
Quoted 42 lines · Matthew Brost
Quoted 30 lines · Jan Stancek
HPAGE_PMD_SHIFTexpands toBUILD_BUG()whenCONFIG_PGTABLE_HAS_HUGE_LEAVESis not set, causing a compile error when bothCONFIG_TRANSPARENT_HUGEPAGEandCONFIG_HUGETLB_PAGEare disabled:
drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute:BUILD_BUGfailed
480 | order =HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #defineHPAGE_PMD_ORDER(HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #defineHPAGE_PMD_SHIFT({BUILD_BUG(); 0; })Guard the two
HPAGE_PMD_ORDERuses withCONFIG_ARCH_ENABLE_THP_MIGRATION, matching the pattern used inmigrate_device.c.Fixes 139ab31aea8a ("drm/pagemap: Correct cpages calculation for migrate_vma_setup")Reported-by kernel test robot <[email protected]>Signed-off-by Jan Stancek <[email protected]>--- drivers/gpu/drm/drm_pagemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_pagemap.c +0
-0drivers/gpu/drm/drm_pagemap.c static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) · line 584
Quoted 8 lines
drivers/gpu/drm/drm_pagemap.c +3
-1@@ -578,10 +578,13 @@ static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) folio =page_folio (page); order =folio_order (folio); cpages +=NR_PAGES (order); - }else if (migrate_pfn[i] &MIGRATE_PFN_COMPOUND ) { + } +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION + else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) { order =HPAGE_PMD_ORDER ;Would it be do something like this at the top of the file...
Quoted 6 lines
#ifdef
HPAGE_PMD_ORDER
#defineDRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
#defineDRM_PAGEMAP_PMD_ORDER(-1)
#endif
Opps screwed my snippet up - HPAGE_PMD_ORDER seems to be always defined...
So actually...
#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)
#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER
#else
define DRM_PAGEMAP_PMD_ORDER (-1)
#endif
Matt
Quoted 46 lines
Then in common code s/HPAGE_PMD_ORDER/DRM_PAGEMAP_PMD_ORDER/
I think this works as we can never get to the
MIGRATE_PFN_COMPOUNDcode paths withoutCONFIG_ARCH_ENABLE_THP_MIGRATIONenabled (seemm/migrate_device.c).Also btw fixing the unrelated bug Sashiko flagged in this patch.
Matt
Quoted 36 lines
drivers/gpu/drm/drm_pagemap.c +5
-1cpages += NR_PAGES(order); } +#endif i +=NR_PAGES (order); }@@ -733,7 +736,6 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, own_pages =0 ;for (i =0 ; i < npages;) { -unsigned long j;struct page *page =pfn_to_page (migrate.dst[i]);struct page *src_page =migrate_pfn_to_page (migrate.src[i]);unsigned int order =0 ;@@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, } migrate.dst[i] =migrate_pfn (migrate.dst[i]); +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (migrate.src[i] &MIGRATE_PFN_COMPOUND ) { +unsigned long j; +drm_WARN_ONCE (dpagemap->drm, src_page &&folio_order (page_folio (src_page)) !=HPAGE_PMD_ORDER ,"Unexpected folio order\n" );@@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,for (j =1 ; j <NR_PAGES (order) && i + j < npages; j++) migrate.dst[i + j] = 0; } +#endif drm_pagemap_get_devmem_page (page, order, zdd);Signature · 1 line
2.52.0
Jan Stancek
Tested-byRe: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
Quoted 53 lines · Matthew Brost
Quoted 42 lines · Matthew Brost
Quoted 30 lines · Jan Stancek
HPAGE_PMD_SHIFTexpands toBUILD_BUG()whenCONFIG_PGTABLE_HAS_HUGE_LEAVESis not set, causing a compile error when bothCONFIG_TRANSPARENT_HUGEPAGEandCONFIG_HUGETLB_PAGEare disabled:
drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute:BUILD_BUGfailed
480 | order =HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #defineHPAGE_PMD_ORDER(HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #defineHPAGE_PMD_SHIFT({BUILD_BUG(); 0; })Guard the two
HPAGE_PMD_ORDERuses withCONFIG_ARCH_ENABLE_THP_MIGRATION, matching the pattern used inmigrate_device.c.Fixes 139ab31aea8a ("drm/pagemap: Correct cpages calculation for migrate_vma_setup")Reported-by kernel test robot <[email protected]>Signed-off-by Jan Stancek <[email protected]>--- drivers/gpu/drm/drm_pagemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_pagemap.c +0
-0drivers/gpu/drm/drm_pagemap.c static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) · line 584
Quoted 8 lines
drivers/gpu/drm/drm_pagemap.c +3
-1@@ -578,10 +578,13 @@ static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages) folio =page_folio (page); order =folio_order (folio); cpages +=NR_PAGES (order); - }else if (migrate_pfn[i] &MIGRATE_PFN_COMPOUND ) { + } +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION + else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) { order =HPAGE_PMD_ORDER ;Would it be do something like this at the top of the file...
Quoted 6 lines
#ifdef
HPAGE_PMD_ORDER
#defineDRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
#defineDRM_PAGEMAP_PMD_ORDER(-1)
#endifOpps screwed my snippet up -
HPAGE_PMD_ORDERseems to be always defined...
Quoted 7 lines
So actually...
#if
IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)
#defineDRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
defineDRM_PAGEMAP_PMD_ORDER(-1)
#endif
Works for me.
Feel free to add:
if you'll be posting your version.
Thanks,
Jan
Quoted 50 lines
Matt
Quoted 46 lines
Then in common code s/HPAGE_PMD_ORDER/DRM_PAGEMAP_PMD_ORDER/
I think this works as we can never get to the
MIGRATE_PFN_COMPOUNDcode paths withoutCONFIG_ARCH_ENABLE_THP_MIGRATIONenabled (seemm/migrate_device.c).Also btw fixing the unrelated bug Sashiko flagged in this patch.
Matt
Quoted 36 lines
drivers/gpu/drm/drm_pagemap.c +5
-2cpages += NR_PAGES(order); } +#endif i +=NR_PAGES (order); }@@ -733,7 +736,6 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, own_pages =0 ;for (i =0 ; i < npages;) { -unsigned long j;struct page *page =pfn_to_page (migrate.dst[i]);struct page *src_page =migrate_pfn_to_page (migrate.src[i]);unsigned int order =0 ;@@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, } migrate.dst[i] =migrate_pfn (migrate.dst[i]); +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (migrate.src[i] &MIGRATE_PFN_COMPOUND ) { +unsigned long j; +drm_WARN_ONCE (dpagemap->drm, src_page &&folio_order (page_folio (src_page)) !=HPAGE_PMD_ORDER ,"Unexpected folio order\n" );@@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,for (j =1 ; j <NR_PAGES (order) && i + j < npages; j++) migrate.dst[i + j] = 0; } +#endif drm_pagemap_get_devmem_page (page, order, zdd); --2.52.0