From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 CAB1231A7EA for ; Tue, 7 Jul 2026 19:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783451962; cv=none; b=TsUzbgpDH/PVDmTmN6Rp8L12W/+5pvhQFKQu6OVHagxYPsikT1RddozhVadpg4oemBp4STHZ85D67TOZx3XTxluBuOKqxsrFVV1gFaGEGY/ywsKU1StopENLy3fdnF0U22LYQjiuf+rG7XL/iyFYadt1lEIB46jm1n/3HeflC28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783451962; c=relaxed/simple; bh=KW55rsPLyXqNaV8A5t93YjO2CS6FW2eBcyStOIgoMYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P/cecUfenLpaSSDcL9dwO8dms0qgP2M1IRZiwS9auqi25dRYrjUtT+NLXoV/0pT7a6n9mdNp7y3gaWfVhVoUbJLB9mgjuHq0nyx4TVGVkJT576KxoM62GDXPygBxPqz8Egv2WHhEEEtN6CGcLiOKU/tlKKeqqLMsMCB/6y6KW6Q= 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=c6mez4bU; arc=none smtp.client-ip=209.85.161.44 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="c6mez4bU" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-6a347ec19a5so1072716eaf.2 for ; Tue, 07 Jul 2026 12:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783451960; x=1784056760; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QiqGU7OY98G2ViD6DEKb5QXbzFW9qlDntwYnyycFfIQ=; b=c6mez4bU1e8CBd/mx3Re2UluEkTyhn7BZFGQ5GjmHB7zdY1ZHb7zf83meYxnS5Za/L UXdXGrWFgwoaRRgZMm/Iw9bWMyMKf9A+7pf6iaMPxh7DiD6HQcjC55hMGz3KJaoVWwVz xRkuR06fzJNoIuKbMVBNhZGVqCg8+pvnhWQRjGQXw8kbOuh7Tc5dujpyD2cLDTS0+Xrz Fu5z0tpHUXSQvos702aaukp+j+Tz9Wbmu/KxkLo78kpElcPxf6eHGSoCJDc6mslyvwpx v6wIxAxFv8KLMt/WfPz0yJuP3EnX/r7kxa1RHfULrkshsmKWCqUrd2o4Enbcs2WCsRO+ Bdvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783451960; x=1784056760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=QiqGU7OY98G2ViD6DEKb5QXbzFW9qlDntwYnyycFfIQ=; b=shLAgJovE+T6JnhA2JweSHyJFyLYuc8efvU8sYEQuvlObkFUbNsXWk+wf70JncRyg6 jSsw2Nkpq4lONbY2ZQlqoV6HSU2lp0tetUH9H+OPX3UPStSyqg28wRtPTyuQ0FMJg2fC 0bGI69bmQpqxC9Oj5JNXU9I3XlnJZIX4PN7Ui4IQ5JxZrNfnkWO1B9dSgOHNtSBxiTyl 20qC8ewiHKjuMj6DxKMWTsJR3nCgKs4055yYjDc8gufWUbS7XoWyV780IAPvNxB1Ws55 Iu28YInAdly0O0akp8Yq5rtKp4KPWrVTJuu6xC2y/3g4Itp1iwP6xErNUZNin07UC3xA gxzg== X-Forwarded-Encrypted: i=1; AFNElJ+XgP+ACee/g68cDGWFI5Rm1ogFbpbNpzh/N1M7XOb0tcjykoNPd/MOkxr2QSOPlDJ8xzd2mBJejVqKl14=@vger.kernel.org X-Gm-Message-State: AOJu0YzyZbIJLLcmKT+IIX9LyVI04WMIbIIzoUG3HyAO63Ko2gJnTfLR oeSsSkcWUB5dwYjk4+gU8w1TCHl3Q7TzCmIX7VK/k+PYs0JSWN7m7j3W X-Gm-Gg: AfdE7cmI9BGcxsW5n46uKXeC5KVvW/fqsSd9V8r5jX4kBd9dGZo0taSxDmfqjig84Da rsQ//hLt6SZ54N1bD8as5faJr3sH5GNbPR6KCOa6njXvs3ST3to16LkR86pRqI+qE5OVve6b7iX ePppcgV6+cVSzy+MbmZs2x3JfYJAoA7dVpLJeKTgk5hR7OovTBeeiDs1b73vMRICK/wwr3lDHOb FktdW4N8uXZQRXbrRwQbr11RxennLUmYbhX7cf1Qd7ce6NyiMR/ZHfEXAgjyDXhtfaKoAJhFJQ/ lfKmEqm/kaV/NgEaDFfATx/dCykzxR3BiHdJrwszZ8TppnxvByHlFefOcrz3SkuSzzxfrqf/QsM l79eUk5VXdRQCr99x8yv/vwX0oznQp4EiDl6aW8sJZ8fuo1E2GBVz1a8j2qrsVNY/l7KKXzWzGG ORAnW+NPL+Pvn7TBRdbg9mU9QeeLrT7ZaxzMDTSs0wLUcJYbGOPagb X-Received: by 2002:a05:6820:1525:b0:6a1:7d5d:d55b with SMTP id 006d021491bc7-6a355767d61mr4135973eaf.63.1783451959711; Tue, 07 Jul 2026 12:19:19 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:a::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6a36a5ef513sm220102eaf.6.2026.07.07.12.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 12:19:19 -0700 (PDT) From: Joshua Hahn To: Usama Arif 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, 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, vbabka@kernel.org, ying.huang@linux.alibaba.com, ziy@nvidia.com, shakeel.butt@linux.dev, hannes@cmpxchg.org Subject: Re: [PATCH 0/3] mm: handle device-private PMDs in walk callbacks Date: Tue, 7 Jul 2026 12:19:16 -0700 Message-ID: <20260707191917.3213033-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260707135255.292870-1-usama.arif@linux.dev> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 > [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