Re: [PATCH v2] lib/test_hmm: fix garbage pfn and wrong direction in devmem fault debug

Andrew Morton <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Wed, 12 Aug 2026 17:28:56 +0800 [email protected] wrote:

> From: Qiang Liu <[email protected]>
> 
> 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/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.