From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4413D13B293 for ; Fri, 26 Jun 2026 00:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782434662; cv=none; b=XR86h6ZKcy4zQBv3faMS14oY6U7Lrwo//vzWBBDRF/QZceOND6jaYuTjEBUc+fC7gdYt4EOyLZGR5XcevM5CjfkIR61WmC2w5uUYT60aqqh0+ujZKlPgfQWPF6ZFjoXd6wwv/jKWog6tGLqV9PfJXrkBUqO40vEoZpJaBUiynFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782434662; c=relaxed/simple; bh=iYlZ02g8BbrotBk0oVebMSyfQzLL2wzGu1p0fE+TqoA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cKirFWv78mBDdQ67u5xF/btz5U6lKF++M015G93wo7S0xGDtlT6hQ7HjFazwC7veEerPpc3bi3nkyGG5hCuVMGHNyG6C7oqJqbqmk4naD9wzsQoNZoiCqULh6ecZ/qZ+R60ykaz9tbfnfP2TGGYLcUr9QHfxiR6hPxeTb1ThTAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i4ZlWQmP; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i4ZlWQmP" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c0efc7ef797so63618966b.2 for ; Thu, 25 Jun 2026 17:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782434660; x=1783039460; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=rIoxXZTpiyNd5JYFa4lQt0gUtbR9irnlA4zKsBOidWE=; b=i4ZlWQmPA/otLIeIGbrI8jAKT0ViZ/QbxoZHDei2LFOgkQN29+HHoye0Q17FVyL65V kkoujfTnVJ6omNfOdauqyP1aImxZa3s7Iyvv1B2wKZOh4wD4IWd7hnxFROYa+O4Ycsm/ WwlQ/obvct927ss+Qy/cFk8IWnFJTg+P7bl3IYqkhI2IziY+D1oEq/sSaOTJbQk3dvzh aSygtcYFPpB6gQVOd1MFUaLe7VsPeQvUi+48Q06LUFDqPUrVHPZ8jVJ/BgvjNju2+l6Y wNbC85FAbi0VTaKJis9IhIQfmVYdQnkU02XHbH/HVQKFKJK+L3A9DcAEHIszaUMJJ/ek HaaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782434660; x=1783039460; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rIoxXZTpiyNd5JYFa4lQt0gUtbR9irnlA4zKsBOidWE=; b=n281vzAFsp/ZpFabU9aGBs/S4ZXszwd7Z9kl/aozh1ghmLUFw54jVVSqlPCbuBenPl zDQD9MrDnQcFmsg1jLClB8V53lHMMfQP6NzSVwiIQW/SZQ2mmdO/gJNMMvpST2OQsly9 ndJ8kGfuFPduTnnnKyBMJNeG/ThIA5XvBS34KE6RxOoKH2r9DWU3TyrPJL/+O2EpI0Jz A184uY+bDufA2ebDTRyeV8Uh/IxfCsJJSFcSwK7FKOP1f7xsQDrneGSEK1/kOrVEnnT2 aRjW34XMKPQ+fd2Sdk9CvhGSWbzBbzqpYr0V614iCVRysZeCR5LxGrYv9D8MsMtFVlXt j7Sg== X-Forwarded-Encrypted: i=1; AHgh+RqlKAgMfIou350ko40JqmSWunWOFFbUITeMz3xTdc4QDOGNZAC0tBn46lGW63TIZVY7Xlk5+dyIYbFQ4eM=@vger.kernel.org X-Gm-Message-State: AOJu0Yyaqs7/Txey6O8dXHIg1g+t5Ab4dqH1cbrJf0NIDAA/CLfNDPca dtKw1oEvP/b8UY3tceC+9NtiaAYI+enfBglMJKmUDP/AQBp4mT5djaE+ X-Gm-Gg: AfdE7clWe9dgXkm+eq2SipUrD1a4Xn8Cxc9SPrG635Pw8OW14/GJtHLJ1kj3QQfyhep 2XhsvJJKZJi9/5kKwrM24rrBECCuGHHMNjtsO06XHr/sJ68k+Dx2Wbm2nxnqMVGAq3zSqzktJF6 WuB/23r2Husis/mfko4xkDRtDGTEFCEAUfxUnccimVsUJ3u75A+haVoA2QnOj6jLk2PYVeca6N2 1nKXWjLrLBfZyuPO3hTO2z2bhNdC8trRumRtKbYeHryKM0drsnwI73SorMoVmDRHy3VD6egGQaA ITYn2OpThzqUHA3gOiBzmi8JYa7tukvnktUo6TihYX5p9iYY0VYtrEBKt34rnCttKndzOnZg5IO hUO50N5wEY2WXRRs9A+pC58cItxS2IbarQilAwmduoviFoGEaIwY6wQy/esYNmLCSlUCGv6dItt JY1z+dfw8XV1yG9hUz5ZJzag== X-Received: by 2002:a17:906:2081:b0:c12:20b0:d8eb with SMTP id a640c23a62f3a-c1220b0ea52mr34718366b.7.1782434659530; Thu, 25 Jun 2026 17:44:19 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c11fbe06543sm261224666b.29.2026.06.25.17.44.17 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jun 2026 17:44:18 -0700 (PDT) Date: Fri, 26 Jun 2026 00:44:16 +0000 From: Wei Yang To: Balbir Singh Cc: Wei Yang , akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, ziy@nvidia.com, sj@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Lance Yang Subject: Re: [Patch mm-hotfixes v4] mm/page_vma_mapped: fix device-private PMD handling Message-ID: <20260626004416.vm4funxhn42hbi3c@master> Reply-To: Wei Yang References: <20260624065353.1622-1-richard.weiyang@gmail.com> <38410976-ddac-4848-a4ff-e6a9f7d9c828@nvidia.com> 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-Disposition: inline In-Reply-To: <38410976-ddac-4848-a4ff-e6a9f7d9c828@nvidia.com> User-Agent: NeoMutt/20170113 (1.7.2) On Thu, Jun 25, 2026 at 09:12:23PM +1000, Balbir Singh wrote: >On 6/24/26 16:53, Wei Yang wrote: >> Commit 65edfda6f3f2 ("mm/rmap: extend rmap and migration support >> device-private entries") introduced the concept of device-private >> PMD entries, but did not correctly update the rmap walk code to >> account for them. >> >> As a result, when page_vma_mapped_walk() encounters device-private >> PMD entries, it takes no action other than to acquire the PMD lock >> and exit. >> >> However this is highly problematic for two reasons - firstly, >> device private entries possess a PFN so check_pmd() needs to be >> called to ensure an overlapping PFN range. >> >> Secondly, and more importantly, if PVMW_MIGRATION is set the >> caller assumes the returned entry is a migration entry, resulting >> in memory corruption when the caller tries to interpret the device >> private entry as such. >> >> In addition, commit 146287290023 ("mm/huge_memory: implement >> device-private THP splitting") allowed device private PMDs to be >> split like THP mappings, but again did not update this code path. >> >> As a result, we might race a PMD split prior to acquiring the PMD >> lock. >> >> This patch addresses all of these issues by invoking check_pmd(), >> ensuring PMVW_MIGRATION is not set and checks whether a split raced >> us we do for PMD THP and migration entries. > >Should be PVMW_MIGRATION and "us we do" -> "as we do" > Hi, Balbir Sorry for missing your comment. Hmm... looks you are right. Andrew, Would you mind handling it or prefer a v2? -- Wei Yang Help you, Help me