From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 DEA5143B6E1 for ; Wed, 8 Jul 2026 12:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783513382; cv=none; b=rfHC8YUcB6iD9dQj//YRIVCbhC3p22kR4fXTdXGs90KG4BSlpV1FpzuDDKQIFci/5I0Gc5d3GWfAAmv44ae1OXUnLlo+9wmemg5eUu1oVM3iS1g8u9oMGvQHkO4dsAZD9vIDEGPLzYc0I73KbMOvKVq+n6qvso6DmEbK9Vdsd4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783513382; c=relaxed/simple; bh=qpozi1ujDvmkbQI/5GBbbz6pLDGYEZh6wy+epUi94ZI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kVhk/CR1tB6oI+0hQA0TmtwUH5HzwR9DvIiOmB7XYLWqIKo6LRvTrgG0or/mXR8sesGdIl5ng0ocC5JOoKAhzeME1RM8HGYA14LGXqCwzDf+N/23S+qpLNPuhYY/bze3hBOUFpRuBwQ3PxCz8+En3aZB4Hu7GtyLRQVUj/cKBHo= 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=RufyJkYe; arc=none smtp.client-ip=95.215.58.170 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="RufyJkYe" Message-ID: <2b316dd0-c6dc-4b9c-9de3-deeb1f481132@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783513378; 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=Fo8Mr9X9mLiZ/hlXDMi/W+rPm93qY7pvM9Gs5YiAlnI=; b=RufyJkYe4CzbD961SMRPDTI6aFLDcFT+PjBoKCSUG+7xSx7Mzqq4DK+9pLCmifeqypf/GB k09VK5XeZSJfMlADTfIk0tsbeHU+QZlBJcT+V9ZAbLGFHCPATaCjU6eVybWh/w1SENo0hp 9oSxDylAAIZ5Ewtcokzwz6zHqHbCMAs= Date: Wed, 8 Jul 2026 13:22:49 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 0/3] mm: handle device-private PMDs in walk callbacks To: Joshua Hahn Cc: Andrew Morton , apopple@nvidia.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, byungchul@sk.com, david@kernel.org, dev.jain@arm.com, gourry@gourry.net, jannh@google.com, lance.yang@linux.dev, liam@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org, matthew.brost@intel.com, npache@redhat.com, rakie.kim@sk.com, ryan.roberts@arm.com, vbabka@kernel.org, ying.huang@linux.alibaba.com, ziy@nvidia.com, shakeel.butt@linux.dev, hannes@cmpxchg.org References: <20260707191917.3213033-1-joshua.hahnjy@gmail.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: <20260707191917.3213033-1-joshua.hahnjy@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 07/07/2026 20:19, Joshua Hahn wrote: > On Tue, 7 Jul 2026 06:45:06 -0700 Usama Arif wrote: > >> Since commit 368076f52ebe ("mm/huge_memory: add device-private THP support >> to PMD operations") a PMD may hold a device-private swap entry whenever >> an HMM-based GPU driver migrates an anonymous THP folio to device memory >> via migrate_vma_pages(). >> >> pmd_trans_huge_lock() succeeds for such PMDs (pmd_is_huge() returns true >> for any non-present, non-none huge PMD), so several MM walk callbacks >> that used to assume present THP or migration entry are now reachable with >> a device-private PMD. The results range from a VM_BUG_ON() firing on debug >> kernels, to an oops on a bogus vmemmap dereference, to silently isolating >> an unrelated live folio from LRU in the aliasing case. >> >> The first 2 fixes were reported as pre-existing issues by sashiko in my >> PMD swap entry series [1]. Hopefully sashiko won't point these out >> in the next PMD swap entry series :) > > Hello Usama, > > Thank you for the fixes! I think all of them look good and they are fixes > so please feel free to add my > > Reviewed-by: Joshua Hahn > > One thing I wanted to maybe consider is for 1/3, whether it could be > good to gate by !pmd_present() like the sites in 2/3 and 3/3, maybe > that will be more robust in the future if there are other cases we > should protect against (and the same as queue_folios_pte_range, which > uses the !pte_present() check too). > > For 2/3 and 3/3 we already have the !pmd_present() check, would it be > worth considering just changing the VM_BUG_ON condition to include > !pmd_is_device_private_entry()? > > Just wanted to toss my 2c. Thanks again for the fixes Usama! > Joshua > Thanks for the reviews Joshua, I think they all made sense. I have sent v2 [1] following your suggestions. [1] https://lore.kernel.org/all/20260708122040.861335-1-usama.arif@linux.dev/