From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 034BE425CEE for ; Mon, 17 Aug 2026 16:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786982803; cv=none; b=qR1dQXLMnHhNgb4r3vP3vVVcEPBgt/Tsx8a2HHkIK3VAjlZ9BvkTcTEWwomMu/evQgh3LJK6gBfIsg3A1F8j5Uz9lTb+rQvpO8DEDwRMSkQw2rGXmNtNUtolkWWwoL5spEUCXsrjTq4hxIGYeUW33deoqBI+a6TDbKY0rx21Iu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786982803; c=relaxed/simple; bh=U9ISrcKnIIuEGibWNMKdqdSRNMgGzTsVPPbkeFvi5AY=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=XcafcWNSs3x7AmA/y5Pp+sT6fHBcKkA19AdB+TUj4XbXZkbwo2a7X+KY7dmy6nMJN2OvF6zHhc6owiAVRl2OnZdG/RdJfEgqqad2anzyCwgUl9041Lm7HWYVQ/DM9V9fCGFblHNt6Aad7M1johdZSRQtlgANtGksnOUPe+3tR5U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=UUPT5XDS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="UUPT5XDS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20C291F000E9; Mon, 17 Aug 2026 16:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786982801; bh=MJyyJ9fN6w6afhM/ktA8g7Cdiq66qrNC49WmXOBpDc0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=UUPT5XDSTCCNzYpfsT3pvev+OnjAlzoPPMY3yvxjlKltV7G7q3N2tpH9WT0SMcHMj JF7gRQ4JSWePCJ8SWr34Yjs1oqh/Z+k+KWSQVmuy0YkazTQAxXw1nVPfkxmwgxuCqx xt2FUSu2w1+q3bfpYk8v1H+3SniSpH/69TYM+Z1A= Date: Mon, 17 Aug 2026 09:06:40 -0700 From: Andrew Morton To: Balbir Singh Cc: Hui Su , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/migrate_device: fix cache flush when replacing huge zero PMD Message-Id: <20260817090640.287a9a415da49e3974797aa4@linux-foundation.org> In-Reply-To: References: <20260817060845.377800-2-sh_def@163.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 17 Aug 2026 17:35:53 +1000 Balbir Singh wrote: > On 8/17/26 4:08 PM, Hui Su wrote: > > migrate_vma_insert_huge_pmd_page() calls flush_cache_page() before > > replacing an existing huge zero PMD. However, the third argument to > > flush_cache_page() is a PFN, while addr + HPAGE_PMD_SIZE is an end > > virtual address. > > > > More importantly, the mapping being invalidated is PMD-sized rather > > than PAGE_SIZE-sized. Flush the whole PMD range with > > flush_cache_range(), matching other huge PMD invalidation paths. > > > > Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages") > > Signed-off-by: Hui Su > > --- > > mm/migrate_device.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/migrate_device.c b/mm/migrate_device.c > > index 908d2d4ec43a..098c04c1b124 100644 > > --- a/mm/migrate_device.c > > +++ b/mm/migrate_device.c > > @@ -872,7 +872,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, > > > > if (flush) { > > pte_free(vma->vm_mm, pgtable); > > - flush_cache_page(vma, addr, addr + HPAGE_PMD_SIZE); > > + flush_cache_range(vma, addr, addr + HPAGE_PMD_SIZE); > > pmdp_invalidate(vma, addr, pmdp); > > } else { > > pgtable_trans_huge_deposit(vma->vm_mm, pmdp, pgtable); > > Reviewed-by: Balbir Singh doh. It's a shame this actually compiled... Can we add some speculation about the userspace-visible effects of the bug? I'm assuming we should backport the fix?