From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 281D6169AD2 for ; Tue, 7 Jul 2026 13:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783432390; cv=none; b=EHVMzBXQvG1KrCVccdlwCPpE0C4f4zJhBAZY5Tlmtn8sHdHeIfA+GCYTpWNmGqNmyxgyyuP5Bb4d4BLtfr/476FrP6eOP1YrG/aOc5ygYNNjW/Le3zaS6Up6vR5KpKZbdEsD3c2YvXZ1deq0Q8/jfeLjNhhAlC871dbJLHf17t4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783432390; c=relaxed/simple; bh=rK4UNdlm4X2kSi+YkQnmVs/3E0VjOk6dY9C4W+VKUW4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EZSPqDt5GgDrI1jzSpjhjlXdc6relIrXPLQ6cUxu8zQKVke9KJo/rLhub4t3EqN7DtzJ9PuzlmT0ESZhQ2+WqiIZdIYCiWNUUrAaFF1VU841cVxfUibX5wpZoasTTUDQjI66HGDJOsNYiQpeFC0syGnoHkFbBlfYAGJJLOHpq4A= 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=HHp5WcPc; arc=none smtp.client-ip=91.218.175.182 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="HHp5WcPc" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783432386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QHrvCBDIqc3E1FZYa+jpIBEplfGugDRdYB4bBJbLc/E=; b=HHp5WcPcftn7/we8jv3iWrulSaQUrvHAaRpXFsX1MKn8IOqSbM5dRaB0LBIzeu+u1EEfwv XszoZPgZOG1xXYQZAuzUKHpBJaB0+SeXJriZ73WV9avGYA5oH8PZykt2DOkfCMHIiuSjOY vQu5IroVVeJcUDHlh7V/Mmk4uZ8tv5A= From: Usama Arif To: 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, joshua.hahnjy@gmail.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, usama.arif@linux.dev, vbabka@kernel.org, ying.huang@linux.alibaba.com, ziy@nvidia.com, shakeel.butt@linux.dev, hannes@cmpxchg.org Subject: [PATCH 0/3] mm: handle device-private PMDs in walk callbacks Date: Tue, 7 Jul 2026 06:45:06 -0700 Message-ID: <20260707135255.292870-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 :) [1] https://sashiko.dev/#/patchset/20260703173903.3789516-1-usama.arif%40linux.dev?part=6 Usama Arif (3): mm/mempolicy: skip device-private PMDs when queueing folios mm/madvise: skip device-private PMDs in cold and pageout walks mm/huge_memory: skip device-private PMDs in madvise_free_huge_pmd mm/huge_memory.c | 3 +++ mm/madvise.c | 3 +++ mm/mempolicy.c | 2 ++ 3 files changed, 8 insertions(+) -- 2.53.0-Meta