Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] lib/test_hmm: fix garbage pfn and wrong direction in devmem fault debug
@ 2026-08-12  9:28 liuqiangneo
  2026-08-12 22:58 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: liuqiangneo @ 2026-08-12  9:28 UTC (permalink / raw)
  To: akpm, jgg, leon; +Cc: linux-mm, linux-kernel, Qiang Liu

From: Qiang Liu <liuqiang@kylinos.cn>

Move pr_debug() inside the `if (dpage)` block to avoid
printing garbage pfn for NULL dpage, and correct the
direction label from "sys to dev" to "dev to sys".

Assisted-by: Qoder:Qwen-3.8-MAX-Preview
Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
---
v1->v2:
- Rebase from mm-everything to mm-new.
- Change commit message.

Link to v1:
https://lore.kernel.org/all/20260811092256.102101-1-liuqiangneo@163.com/
---
 lib/test_hmm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 6205fb313bd0..7c4d10eae6fe 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1151,10 +1151,9 @@ static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args,
 		if (!dpage && !order)
 			return VM_FAULT_OOM;
 
-		pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
-				page_to_pfn(spage), page_to_pfn(dpage));
-
 		if (dpage) {
+			pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n",
+					page_to_pfn(spage), page_to_pfn(dpage));
 			lock_page(dpage);
 			*dst |= migrate_pfn(page_to_pfn(dpage));
 		}
-- 
2.43.0


No virus found
		Checked by Hillstone Network AntiVirus



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

* Re: [PATCH v2] lib/test_hmm: fix garbage pfn and wrong direction in devmem fault debug
  2026-08-12  9:28 [PATCH v2] lib/test_hmm: fix garbage pfn and wrong direction in devmem fault debug liuqiangneo
@ 2026-08-12 22:58 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-08-12 22:58 UTC (permalink / raw)
  To: liuqiangneo; +Cc: jgg, leon, linux-mm, linux-kernel, Qiang Liu

On Wed, 12 Aug 2026 17:28:56 +0800 liuqiangneo@163.com wrote:

> From: Qiang Liu <liuqiang@kylinos.cn>
> 
> Move pr_debug() inside the `if (dpage)` block to avoid
> printing garbage pfn for NULL dpage, and correct the
> direction label from "sys to dev" to "dev to sys".
> 
> ...
>
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -1151,10 +1151,9 @@ static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args,
>  		if (!dpage && !order)
>  			return VM_FAULT_OOM;
>  
> -		pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
> -				page_to_pfn(spage), page_to_pfn(dpage));
> -
>  		if (dpage) {
> +			pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n",
> +					page_to_pfn(spage), page_to_pfn(dpage));
>  			lock_page(dpage);
>  			*dst |= migrate_pfn(page_to_pfn(dpage));

Looks OK to me, thanks.

We could just remove the pr_debug.  I suspect it was a development-time
thing and nobody uses it any more.

Your patch prompted Sashiko to find three possible pre-existing issues
in this code:

	https://sashiko.dev/#/patchset/20260812092856.55296-1-liuqiangneo@163.com


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

end of thread, other threads:[~2026-08-12 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12  9:28 [PATCH v2] lib/test_hmm: fix garbage pfn and wrong direction in devmem fault debug liuqiangneo
2026-08-12 22:58 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox