All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
@ 2026-05-29 11:17 Dev Jain
  2026-05-29 16:45 ` Lorenzo Stoakes
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Dev Jain @ 2026-05-29 11:17 UTC (permalink / raw)
  To: akpm, liam, ljs, jgg, leon, david, shuah
  Cc: Dev Jain, vbabka, jannh, pfalcato, rppt, surenb, mhocko, balbirs,
	linux-mm, linux-kernel, linux-fsdevel, linux-kselftest,
	ryan.roberts, anshuman.khandual, stable

pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
entry. This became false once device-private entries at the PMD level were
added.

One can hit the warning by patching hmm-tests.c with the following:

diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
index e1c8a679a4cf3..7f0a3384f3c5f 100644
--- a/tools/testing/selftests/mm/hmm-tests.c
+++ b/tools/testing/selftests/mm/hmm-tests.c
@@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
 	return 0;
 }

+static int hmm_read_self_pagemap(void *addr, unsigned long npages,
+				 unsigned long page_size)
+{
+	const size_t entry_size = sizeof(uint64_t);
+	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
+	uint64_t *entries;
+	ssize_t nread;
+	int fd;
+
+	entries = malloc(npages * entry_size);
+	if (!entries)
+		return -ENOMEM;
+
+	fd = open("/proc/self/pagemap", O_RDONLY);
+	if (fd < 0) {
+		free(entries);
+		return -errno;
+	}
+
+	nread = pread(fd, entries, npages * entry_size, offset);
+	close(fd);
+	free(entries);
+
+	if (nread < 0)
+		return -errno;
+	if ((size_t)nread != npages * entry_size)
+		return -EIO;
+
+	return 0;
+}
+
 static void hmm_buffer_free(struct hmm_buffer *buffer)
 {
 	if (buffer == NULL)
@@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
 	ASSERT_EQ(ret, 0);
 	ASSERT_EQ(buffer->cpages, npages);

+	/* Exercise pagemap on a PMD device-private entry. */
+	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
+	ASSERT_EQ(ret, 0);
+
 	/* Check what the device read. */
 	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
 		ASSERT_EQ(ptr[i], i);


Therefore, remove the stale migration-only assertion.

Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
Cc: stable@vger.kernel.org
Signed-off-by: Dev Jain <dev.jain@arm.com>
---
Applies on mm-unstable (404fb4f38e8f).

 fs/proc/task_mmu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 1e3a15bf46f4e..58938e62154d9 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -2129,7 +2129,6 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
 			flags |= PM_SOFT_DIRTY;
 		if (pmd_swp_uffd_wp(pmd))
 			flags |= PM_UFFD_WP;
-		VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
 		page = softleaf_to_page(entry);
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-29 11:17 [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry Dev Jain
@ 2026-05-29 16:45 ` Lorenzo Stoakes
  2026-05-29 23:36   ` Andrew Morton
  2026-05-31 19:11 ` David Hildenbrand (Arm)
  2026-06-02  4:21 ` Oscar Salvador (SUSE)
  2 siblings, 1 reply; 8+ messages in thread
From: Lorenzo Stoakes @ 2026-05-29 16:45 UTC (permalink / raw)
  To: Dev Jain
  Cc: akpm, liam, jgg, leon, david, shuah, vbabka, jannh, pfalcato,
	rppt, surenb, mhocko, balbirs, linux-mm, linux-kernel,
	linux-fsdevel, linux-kselftest, ryan.roberts, anshuman.khandual,
	stable

On Fri, May 29, 2026 at 11:17:03AM +0000, Dev Jain wrote:
> pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
> entry. This became false once device-private entries at the PMD level were
> added.
>
> One can hit the warning by patching hmm-tests.c with the following:
>
> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
> index e1c8a679a4cf3..7f0a3384f3c5f 100644
> --- a/tools/testing/selftests/mm/hmm-tests.c
> +++ b/tools/testing/selftests/mm/hmm-tests.c
> @@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
>  	return 0;
>  }
>
> +static int hmm_read_self_pagemap(void *addr, unsigned long npages,
> +				 unsigned long page_size)
> +{
> +	const size_t entry_size = sizeof(uint64_t);
> +	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
> +	uint64_t *entries;
> +	ssize_t nread;
> +	int fd;
> +
> +	entries = malloc(npages * entry_size);
> +	if (!entries)
> +		return -ENOMEM;
> +
> +	fd = open("/proc/self/pagemap", O_RDONLY);
> +	if (fd < 0) {
> +		free(entries);
> +		return -errno;
> +	}
> +
> +	nread = pread(fd, entries, npages * entry_size, offset);
> +	close(fd);
> +	free(entries);
> +
> +	if (nread < 0)
> +		return -errno;
> +	if ((size_t)nread != npages * entry_size)
> +		return -EIO;
> +
> +	return 0;
> +}
> +
>  static void hmm_buffer_free(struct hmm_buffer *buffer)
>  {
>  	if (buffer == NULL)
> @@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
>  	ASSERT_EQ(ret, 0);
>  	ASSERT_EQ(buffer->cpages, npages);
>
> +	/* Exercise pagemap on a PMD device-private entry. */
> +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
> +	ASSERT_EQ(ret, 0);
> +
>  	/* Check what the device read. */
>  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
>  		ASSERT_EQ(ptr[i], i);

Thanks for this!

though, hmm it really feels like you maybe want to add this as a test and
make this a series :)

Andrew is usually fine with adding tests as part of a fix I believe!

>
>
> Therefore, remove the stale migration-only assertion.
>
> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dev Jain <dev.jain@arm.com>

The logic does seem sense, it does seem like something of an oversight here
and I can repro the assert (though I have to fix something else first on my
system, patch incoming for that...!)

> ---
> Applies on mm-unstable (404fb4f38e8f).
>
>  fs/proc/task_mmu.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 1e3a15bf46f4e..58938e62154d9 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -2129,7 +2129,6 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
>  			flags |= PM_SOFT_DIRTY;
>  		if (pmd_swp_uffd_wp(pmd))
>  			flags |= PM_UFFD_WP;
> -		VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
>  		page = softleaf_to_page(entry);

>  	}
>
> --
> 2.43.0
>

Cheers, Lorenzo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-29 16:45 ` Lorenzo Stoakes
@ 2026-05-29 23:36   ` Andrew Morton
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2026-05-29 23:36 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Dev Jain, liam, jgg, leon, david, shuah, vbabka, jannh, pfalcato,
	rppt, surenb, mhocko, balbirs, linux-mm, linux-kernel,
	linux-fsdevel, linux-kselftest, ryan.roberts, anshuman.khandual,
	stable

On Fri, 29 May 2026 17:45:24 +0100 Lorenzo Stoakes <ljs@kernel.org> wrote:

> > +	/* Exercise pagemap on a PMD device-private entry. */
> > +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
> > +	ASSERT_EQ(ret, 0);
> > +
> >  	/* Check what the device read. */
> >  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
> >  		ASSERT_EQ(ptr[i], i);
> 
> Thanks for this!
> 
> though, hmm it really feels like you maybe want to add this as a test and
> make this a series :)

yes please!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-29 11:17 [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry Dev Jain
  2026-05-29 16:45 ` Lorenzo Stoakes
@ 2026-05-31 19:11 ` David Hildenbrand (Arm)
  2026-06-01  4:56   ` Dev Jain
  2026-06-02  4:20   ` Oscar Salvador (SUSE)
  2026-06-02  4:21 ` Oscar Salvador (SUSE)
  2 siblings, 2 replies; 8+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-31 19:11 UTC (permalink / raw)
  To: Dev Jain, akpm, liam, ljs, jgg, leon, shuah
  Cc: vbabka, jannh, pfalcato, rppt, surenb, mhocko, balbirs, linux-mm,
	linux-kernel, linux-fsdevel, linux-kselftest, ryan.roberts,
	anshuman.khandual, stable

On 5/29/26 13:17, Dev Jain wrote:
> pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
> entry. This became false once device-private entries at the PMD level were
> added.
> 
> One can hit the warning by patching hmm-tests.c with the following:
> 
> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
> index e1c8a679a4cf3..7f0a3384f3c5f 100644
> --- a/tools/testing/selftests/mm/hmm-tests.c
> +++ b/tools/testing/selftests/mm/hmm-tests.c
> @@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
>  	return 0;
>  }
> 
> +static int hmm_read_self_pagemap(void *addr, unsigned long npages,
> +				 unsigned long page_size)
> +{
> +	const size_t entry_size = sizeof(uint64_t);
> +	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
> +	uint64_t *entries;
> +	ssize_t nread;
> +	int fd;
> +
> +	entries = malloc(npages * entry_size);
> +	if (!entries)
> +		return -ENOMEM;
> +
> +	fd = open("/proc/self/pagemap", O_RDONLY);
> +	if (fd < 0) {
> +		free(entries);
> +		return -errno;
> +	}
> +
> +	nread = pread(fd, entries, npages * entry_size, offset);
> +	close(fd);
> +	free(entries);
> +
> +	if (nread < 0)
> +		return -errno;
> +	if ((size_t)nread != npages * entry_size)
> +		return -EIO;
> +
> +	return 0;
> +}
> +
>  static void hmm_buffer_free(struct hmm_buffer *buffer)
>  {
>  	if (buffer == NULL)
> @@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
>  	ASSERT_EQ(ret, 0);
>  	ASSERT_EQ(buffer->cpages, npages);
> 
> +	/* Exercise pagemap on a PMD device-private entry. */
> +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
> +	ASSERT_EQ(ret, 0);
> +
>  	/* Check what the device read. */
>  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
>  		ASSERT_EQ(ptr[i], i);
> 
> 


> Therefore, remove the stale migration-only assertion.
> 
> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dev Jain <dev.jain@arm.com>
> ---
> Applies on mm-unstable (404fb4f38e8f).
> 
>  fs/proc/task_mmu.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 1e3a15bf46f4e..58938e62154d9 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -2129,7 +2129,6 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
>  			flags |= PM_SOFT_DIRTY;
>  		if (pmd_swp_uffd_wp(pmd))
>  			flags |= PM_UFFD_WP;
> -		VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
>  		page = softleaf_to_page(entry);
>  	}
>  

The whole thp_migration_supported() guard is a bit shaky, right?

I guess device-private entries currently imply thp_migration_supported(), but
that thp_migration_supported() check is really questionable and should likely
just go away (else if -> else).

Staring at pte_to_pagemap_entry(), likely we'd also want

if (softleaf_has_pfn(entry))
	page = softleaf_to_page(entry);

to prepare for PMD swap entries.


Anyhow, both are unrelated (can you send patches to clean it up?)

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-31 19:11 ` David Hildenbrand (Arm)
@ 2026-06-01  4:56   ` Dev Jain
  2026-06-01  5:48     ` David Hildenbrand (Arm)
  2026-06-02  4:20   ` Oscar Salvador (SUSE)
  1 sibling, 1 reply; 8+ messages in thread
From: Dev Jain @ 2026-06-01  4:56 UTC (permalink / raw)
  To: David Hildenbrand (Arm), akpm, liam, ljs, jgg, leon, shuah
  Cc: vbabka, jannh, pfalcato, rppt, surenb, mhocko, balbirs, linux-mm,
	linux-kernel, linux-fsdevel, linux-kselftest, ryan.roberts,
	anshuman.khandual, stable



On 01/06/26 12:41 am, David Hildenbrand (Arm) wrote:
> On 5/29/26 13:17, Dev Jain wrote:
>> pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
>> entry. This became false once device-private entries at the PMD level were
>> added.
>>
>> One can hit the warning by patching hmm-tests.c with the following:
>>
>> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
>> index e1c8a679a4cf3..7f0a3384f3c5f 100644
>> --- a/tools/testing/selftests/mm/hmm-tests.c
>> +++ b/tools/testing/selftests/mm/hmm-tests.c
>> @@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
>>  	return 0;
>>  }
>>
>> +static int hmm_read_self_pagemap(void *addr, unsigned long npages,
>> +				 unsigned long page_size)
>> +{
>> +	const size_t entry_size = sizeof(uint64_t);
>> +	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
>> +	uint64_t *entries;
>> +	ssize_t nread;
>> +	int fd;
>> +
>> +	entries = malloc(npages * entry_size);
>> +	if (!entries)
>> +		return -ENOMEM;
>> +
>> +	fd = open("/proc/self/pagemap", O_RDONLY);
>> +	if (fd < 0) {
>> +		free(entries);
>> +		return -errno;
>> +	}
>> +
>> +	nread = pread(fd, entries, npages * entry_size, offset);
>> +	close(fd);
>> +	free(entries);
>> +
>> +	if (nread < 0)
>> +		return -errno;
>> +	if ((size_t)nread != npages * entry_size)
>> +		return -EIO;
>> +
>> +	return 0;
>> +}
>> +
>>  static void hmm_buffer_free(struct hmm_buffer *buffer)
>>  {
>>  	if (buffer == NULL)
>> @@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
>>  	ASSERT_EQ(ret, 0);
>>  	ASSERT_EQ(buffer->cpages, npages);
>>
>> +	/* Exercise pagemap on a PMD device-private entry. */
>> +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
>> +	ASSERT_EQ(ret, 0);
>> +
>>  	/* Check what the device read. */
>>  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
>>  		ASSERT_EQ(ptr[i], i);
>>
>>
> 
> 
>> Therefore, remove the stale migration-only assertion.
>>
>> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Dev Jain <dev.jain@arm.com>
>> ---
>> Applies on mm-unstable (404fb4f38e8f).
>>
>>  fs/proc/task_mmu.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
>> index 1e3a15bf46f4e..58938e62154d9 100644
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
>> @@ -2129,7 +2129,6 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
>>  			flags |= PM_SOFT_DIRTY;
>>  		if (pmd_swp_uffd_wp(pmd))
>>  			flags |= PM_UFFD_WP;
>> -		VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
>>  		page = softleaf_to_page(entry);
>>  	}
>>  
> 
> The whole thp_migration_supported() guard is a bit shaky, right?

I think if you remove this, then you will trigger a WARN_ON in softleaf_to_page(),
for the case of !CONFIG_ARCH_ENABLE_THP_MIGRATION.
> 
> I guess device-private entries currently imply thp_migration_supported(), but
> that thp_migration_supported() check is really questionable and should likely
> just go away (else if -> else).
> 
> Staring at pte_to_pagemap_entry(), likely we'd also want
> 
> if (softleaf_has_pfn(entry))
> 	page = softleaf_to_page(entry);
> 
> to prepare for PMD swap entries.

Correct, and this is done in
https://lore.kernel.org/all/20260427100553.2754667-4-usama.arif@linux.dev/

I think in addition to that, Usama can also remove the thp_migration_supported() check.
> 
> 
> Anyhow, both are unrelated (can you send patches to clean it up?)
> 
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-06-01  4:56   ` Dev Jain
@ 2026-06-01  5:48     ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 8+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01  5:48 UTC (permalink / raw)
  To: Dev Jain, akpm, liam, ljs, jgg, leon, shuah
  Cc: vbabka, jannh, pfalcato, rppt, surenb, mhocko, balbirs, linux-mm,
	linux-kernel, linux-fsdevel, linux-kselftest, ryan.roberts,
	anshuman.khandual, stable, Usama Arif

On 6/1/26 06:56, Dev Jain wrote:
> 
> 
> On 01/06/26 12:41 am, David Hildenbrand (Arm) wrote:
>> On 5/29/26 13:17, Dev Jain wrote:
>>> pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
>>> entry. This became false once device-private entries at the PMD level were
>>> added.
>>>
>>> One can hit the warning by patching hmm-tests.c with the following:
>>>
>>> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
>>> index e1c8a679a4cf3..7f0a3384f3c5f 100644
>>> --- a/tools/testing/selftests/mm/hmm-tests.c
>>> +++ b/tools/testing/selftests/mm/hmm-tests.c
>>> @@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
>>>  	return 0;
>>>  }
>>>
>>> +static int hmm_read_self_pagemap(void *addr, unsigned long npages,
>>> +				 unsigned long page_size)
>>> +{
>>> +	const size_t entry_size = sizeof(uint64_t);
>>> +	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
>>> +	uint64_t *entries;
>>> +	ssize_t nread;
>>> +	int fd;
>>> +
>>> +	entries = malloc(npages * entry_size);
>>> +	if (!entries)
>>> +		return -ENOMEM;
>>> +
>>> +	fd = open("/proc/self/pagemap", O_RDONLY);
>>> +	if (fd < 0) {
>>> +		free(entries);
>>> +		return -errno;
>>> +	}
>>> +
>>> +	nread = pread(fd, entries, npages * entry_size, offset);
>>> +	close(fd);
>>> +	free(entries);
>>> +
>>> +	if (nread < 0)
>>> +		return -errno;
>>> +	if ((size_t)nread != npages * entry_size)
>>> +		return -EIO;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>  static void hmm_buffer_free(struct hmm_buffer *buffer)
>>>  {
>>>  	if (buffer == NULL)
>>> @@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
>>>  	ASSERT_EQ(ret, 0);
>>>  	ASSERT_EQ(buffer->cpages, npages);
>>>
>>> +	/* Exercise pagemap on a PMD device-private entry. */
>>> +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
>>> +	ASSERT_EQ(ret, 0);
>>> +
>>>  	/* Check what the device read. */
>>>  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
>>>  		ASSERT_EQ(ptr[i], i);
>>>
>>>
>>
>>
>>> Therefore, remove the stale migration-only assertion.
>>>
>>> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Dev Jain <dev.jain@arm.com>
>>> ---
>>> Applies on mm-unstable (404fb4f38e8f).
>>>
>>>  fs/proc/task_mmu.c | 1 -
>>>  1 file changed, 1 deletion(-)
>>>
>>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
>>> index 1e3a15bf46f4e..58938e62154d9 100644
>>> --- a/fs/proc/task_mmu.c
>>> +++ b/fs/proc/task_mmu.c
>>> @@ -2129,7 +2129,6 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
>>>  			flags |= PM_SOFT_DIRTY;
>>>  		if (pmd_swp_uffd_wp(pmd))
>>>  			flags |= PM_UFFD_WP;
>>> -		VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
>>>  		page = softleaf_to_page(entry);
>>>  	}
>>>  
>>
>> The whole thp_migration_supported() guard is a bit shaky, right?
> 
> I think if you remove this, then you will trigger a WARN_ON in softleaf_to_page(),
> for the case of !CONFIG_ARCH_ENABLE_THP_MIGRATION.

Right, what I noted below.

Right now it's all a bit hacked on top of initial migration entry support.

>>
>> I guess device-private entries currently imply thp_migration_supported(), but
>> that thp_migration_supported() check is really questionable and should likely
>> just go away (else if -> else).
>>
>> Staring at pte_to_pagemap_entry(), likely we'd also want
>>
>> if (softleaf_has_pfn(entry))
>> 	page = softleaf_to_page(entry);
>>
>> to prepare for PMD swap entries.
> 
> Correct, and this is done in
> https://lore.kernel.org/all/20260427100553.2754667-4-usama.arif@linux.dev/
> 
> I think in addition to that, Usama can also remove the thp_migration_supported() check.
Yes, that one should go away.

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-31 19:11 ` David Hildenbrand (Arm)
  2026-06-01  4:56   ` Dev Jain
@ 2026-06-02  4:20   ` Oscar Salvador (SUSE)
  1 sibling, 0 replies; 8+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02  4:20 UTC (permalink / raw)
  To: David Hildenbrand (Arm)
  Cc: Dev Jain, akpm, liam, ljs, jgg, leon, shuah, vbabka, jannh,
	pfalcato, rppt, surenb, mhocko, balbirs, linux-mm, linux-kernel,
	linux-fsdevel, linux-kselftest, ryan.roberts, anshuman.khandual,
	stable

On Sun, May 31, 2026 at 09:11:53PM +0200, David Hildenbrand (Arm) wrote:
> The whole thp_migration_supported() guard is a bit shaky, right?
> 
> I guess device-private entries currently imply thp_migration_supported(), but
> that thp_migration_supported() check is really questionable and should likely
> just go away (else if -> else).
> 
> Staring at pte_to_pagemap_entry(), likely we'd also want
> 
> if (softleaf_has_pfn(entry))
> 	page = softleaf_to_page(entry);
> 
> to prepare for PMD swap entries.

Yes, that is what I was doing for non-present PMDs when implementing the
new API [1].

[1] https://lore.kernel.org/linux-mm/20260525165528.184397-5-osalvador@suse.de/

 

-- 
Oscar Salvador
SUSE Labs


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry
  2026-05-29 11:17 [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry Dev Jain
  2026-05-29 16:45 ` Lorenzo Stoakes
  2026-05-31 19:11 ` David Hildenbrand (Arm)
@ 2026-06-02  4:21 ` Oscar Salvador (SUSE)
  2 siblings, 0 replies; 8+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02  4:21 UTC (permalink / raw)
  To: Dev Jain
  Cc: akpm, liam, ljs, jgg, leon, david, shuah, vbabka, jannh, pfalcato,
	rppt, surenb, mhocko, balbirs, linux-mm, linux-kernel,
	linux-fsdevel, linux-kselftest, ryan.roberts, anshuman.khandual,
	stable

On Fri, May 29, 2026 at 11:17:03AM +0000, Dev Jain wrote:
> pagemap_pmd_range_thp() warns if a non-present PMD is not a migration
> entry. This became false once device-private entries at the PMD level were
> added.
> 
> One can hit the warning by patching hmm-tests.c with the following:
> 
> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
> index e1c8a679a4cf3..7f0a3384f3c5f 100644
> --- a/tools/testing/selftests/mm/hmm-tests.c
> +++ b/tools/testing/selftests/mm/hmm-tests.c
> @@ -209,6 +209,37 @@ static int hmm_dmirror_cmd(int fd,
>  	return 0;
>  }
> 
> +static int hmm_read_self_pagemap(void *addr, unsigned long npages,
> +				 unsigned long page_size)
> +{
> +	const size_t entry_size = sizeof(uint64_t);
> +	const off_t offset = ((uintptr_t)addr / page_size) * entry_size;
> +	uint64_t *entries;
> +	ssize_t nread;
> +	int fd;
> +
> +	entries = malloc(npages * entry_size);
> +	if (!entries)
> +		return -ENOMEM;
> +
> +	fd = open("/proc/self/pagemap", O_RDONLY);
> +	if (fd < 0) {
> +		free(entries);
> +		return -errno;
> +	}
> +
> +	nread = pread(fd, entries, npages * entry_size, offset);
> +	close(fd);
> +	free(entries);
> +
> +	if (nread < 0)
> +		return -errno;
> +	if ((size_t)nread != npages * entry_size)
> +		return -EIO;
> +
> +	return 0;
> +}
> +
>  static void hmm_buffer_free(struct hmm_buffer *buffer)
>  {
>  	if (buffer == NULL)
> @@ -2314,6 +2345,10 @@ TEST_F(hmm, migrate_anon_huge_fault)
>  	ASSERT_EQ(ret, 0);
>  	ASSERT_EQ(buffer->cpages, npages);
> 
> +	/* Exercise pagemap on a PMD device-private entry. */
> +	ret = hmm_read_self_pagemap(buffer->ptr, npages, self->page_size);
> +	ASSERT_EQ(ret, 0);
> +
>  	/* Check what the device read. */
>  	for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
>  		ASSERT_EQ(ptr[i], i);
> 
> 
> Therefore, remove the stale migration-only assertion.
> 
> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dev Jain <dev.jain@arm.com>

LGTM,

Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>



-- 
Oscar Salvador
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-02  4:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 11:17 [PATCH] fs/proc/task_mmu: do not warn on seeing non-migration pmd entry Dev Jain
2026-05-29 16:45 ` Lorenzo Stoakes
2026-05-29 23:36   ` Andrew Morton
2026-05-31 19:11 ` David Hildenbrand (Arm)
2026-06-01  4:56   ` Dev Jain
2026-06-01  5:48     ` David Hildenbrand (Arm)
2026-06-02  4:20   ` Oscar Salvador (SUSE)
2026-06-02  4:21 ` Oscar Salvador (SUSE)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.