From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 D2EA131DD97 for ; Mon, 22 Jun 2026 15:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782140420; cv=none; b=MsM/RiIU/EcGncC6hGC97Os1R2nZSzGHhfJ4gIAxr1ejGQL4/mQbxnhMPqjr1Nw5hHuk2JtIoYEZcfX4OLdi5s1mGC+tHsgSAsSYHftS8EnD+EJSRHwKtXtAmf8WlZ5TnF2uejOvzggdQ8w6mIbShLB5Mae2tX1f/vHf2b7pDk0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782140420; c=relaxed/simple; bh=PlnXP82l5c9DBIRhnBwz60gBUOqylW2SmOkpkj4/boc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oaAuYEgJ3SUN2mUz2C38z3EGEQlggve5/11vcJhWcutkh/0bgOsZfCacr7t5DSJ+f5og0aiSF2qv77FWRZQO1wq6zsj9nzSRaPSfiQzmiSlfo24dDEMo3aDKPTN3cY9Qymw7nt9e2E3rxdGxZd65p31NsOlbBSAAvD3Qc/s/4zk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lm7QAjZj; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lm7QAjZj" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782140415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NOJ7I8F4EO4YGKqeUHW4KddOImg3/9NrBeT3tUiiggU=; b=lm7QAjZjJbNEjzhuKwp0t1Wo0hoKuz96n30Jj0Jga70Q2X+pdZe1co7PxyVG3oEUiCtdfb i/Jiv9p5E5Vq/0nSMaQDAQQ5WRo7gwjfD7sEQCSDBp2IL2ZVc5Mn8J4Fh4i+3LSrjIt692 XXYWmHgWKSGT/dpiCjUyhvOmhiC/wkY= Date: Mon, 22 Jun 2026 22:59:39 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/page_vma_mapped: revalidate and do proper check before return device-private pmd Content-Language: en-US To: Wei Yang , Lorenzo Stoakes Cc: akpm@linux-foundation.org, david@kernel.org, riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, sj@kernel.org, ziy@nvidia.com, balbirs@nvidia.com, linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260622130651.23359-1-richard.weiyang@gmail.com> <20260622142102.pcmr5pftshj5lvju@master> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260622142102.pcmr5pftshj5lvju@master> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/6/22 22:21, Wei Yang wrote: > On Mon, Jun 22, 2026 at 02:46:40PM +0100, Lorenzo Stoakes wrote: >> +cc Lance, linux-kernel >> >> Your subject line is 83 characters long and is way too detailed how about 'fix >> device-private PMD handling'? >> > > Got it. > >> You forgot to include linux-kernel@vger.kernel.org on the mail, lore seems to be >> a bit broken atm but in general it's helpful to include that. > > Got it. > > So usually we send a patch to both linux-mm and linux-kernel? If so, I > remember is later actions. Yeah, please keep linux-kernel copied too. For MM patches, linux-mm + linux-kernel is the right default, IMHO :) >> >> Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's >> intended as a hotfix. >> > > Got it. > [...] >> ----8<---- >> >From e6a3c1c782714ed831c4d46a14bb99226423bf59 Mon Sep 17 00:00:00 2001 >> From: Wei Yang >> Date: Mon, 22 Jun 2026 13:06:51 +0000 >> Subject: [PATCH] refactored >> >> Signed-off-by: Lorenzo Stoakes >> --- >> mm/page_vma_mapped.c | 20 +++++++++++++++----- >> 1 file changed, 15 insertions(+), 5 deletions(-) >> >> diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c >> index 2ccbabfb2cc1..17dff8aab9f9 100644 >> --- a/mm/page_vma_mapped.c >> +++ b/mm/page_vma_mapped.c >> @@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) >> /* THP pmd was split under us: handle on pte level */ >> spin_unlock(pvmw->ptl); >> pvmw->ptl = NULL; >> - } else if (!pmd_present(pmde)) { >> - const softleaf_t entry = softleaf_from_pmd(pmde); >> + } else if (pmd_is_device_private_entry(pmde)) { >> + softleaf_t entry; >> + >> + pvmw->ptl = pmd_lock(mm, pvmw->pmd); >> + pmde = *pvmw->pmd; >> + entry = softleaf_from_pmd(pmde); >> >> - if (softleaf_is_device_private(entry)) { >> - pvmw->ptl = pmd_lock(mm, pvmw->pmd); >> + if (likely(softleaf_is_device_private(entry))) { >> + if (pvmw->flags & PVMW_MIGRATION) >> + return not_found(pvmw); >> + if (!check_pmd(softleaf_to_pfn(entry), pvmw)) >> + return not_found(pvmw); >> return true; >> } >> - >> + /* device-private pmd was split under us: handle on pte level */ >> + spin_unlock(pvmw->ptl); >> + pvmw->ptl = NULL; >> + } else if (!pmd_present(pmde)) { >> if ((pvmw->flags & PVMW_SYNC) && >> thp_vma_suitable_order(vma, pvmw->address, >> PMD_ORDER) && >> -- >> 2.54.0 > > If we prefer this way, I will check and take it. And +1 on Lorenzo's diff. Much cleaner. Cheers, Lance