From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 172CD36EA80 for ; Sun, 12 Jul 2026 12:41:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783860064; cv=none; b=TZi5TnqBbSexSKRiEuJh7p7b0e0zvlFJekJAWrLQpJxhjBpU65b2CWuaptDtpIgECjP+I0UCGmT2khvGLR+QV8ZzwsUgJdEdHTx3gMv8qvRzYfD68KGJ+8IiaKnG90s1p41IWqje/c9vWZeXQtPVpr7Mg62YDgrs3McxP+tQq9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783860064; c=relaxed/simple; bh=Fe1dBK0K0IJe1P5zn7VWDd2lteT1kusgC4yEBjsNCxM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Wb87hCUv86u0yUU9FFVNUm/OCkzbvl+566/Ks8nqygd2UnDVqxezbpE7jvA29ukxIU0IrCV4vvGiSvKKH0Io6+ftfpd7mLNPzHDIg71VSE2tIuZZN+cb7eD06W36fKVPN/RGVOt3F0s489WKthz5I3d9hNjgzzAqFr1QzJY95yI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=Xn+wCSmT; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="Xn+wCSmT" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-92e5c92c389so114024585a.3 for ; Sun, 12 Jul 2026 05:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783860062; x=1784464862; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=R//0yPDdMSUye02M0KhsD4bBos+saG3+i2478K3plUg=; b=Xn+wCSmTiHrd8a6j4QB7neXrfzupLXqyep1/OO6T1ySYLVq5/xlLLdwL6PiIV/WLNG GEOgZl4BGo56u7kAimMgR4FuwPQ12Rf6hbe3FsNSdjkQo/A0DF778ZZCEj/YmN2ZBRQg dzn4J0fn3efY8DqJviSWVWc7qy3Ju4sP9jBS7K2yxwyff9IRAy1W8QRXDQkPNPwDQfS1 2xmVaSCs46BiM0PYy3yONhdjBXcKZyGcuIclxvPoZteTboS/OQjyRagdqj/6wbbYjjtm iFOPtMry/6NiO7qdxY8ch/LQ/46z7qPccEwWgXdioAMhVo4ti3PtY/vH9lTiraVTkHzP +z4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783860062; x=1784464862; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=R//0yPDdMSUye02M0KhsD4bBos+saG3+i2478K3plUg=; b=eEZsgAHSdOH3gt/MePaU/muYGA58Cpu0F6IV3977I/9J3eIp7pB2vytEhtxYlcX53/ wzODETeeS8zTe2+PbDeu2+y1Ze+szNgEo+3hASgkH+6HNCsaoqNWDGzkCIeQEMUpV5OJ ffRpi6kXWGzfiNXsktZ3B+wZXycgGG0nQYzysy7s97UXkMDSjyiM7v7PYNbOExTQS/6W 0+QHlvCsYTOQPfm/jlBdPIamshgDVBX4mcST5VoYYHcm+MGac7DiJmRJnPvBgWVaWXEs LIYUA5PmnCPhpiavyfmzDan1ZLuEa63QHV+BayTr307szw/JB6csy39MiBRXIkGpzqI+ ddAQ== X-Forwarded-Encrypted: i=1; AHgh+Rocvyl7CntXPZtDqoxz9pHUXLE2Q1ScpU30J6ifrKA8HMKFuWxwnAwXUcyszGjki/Ca47a9KDfdiJzpQ9Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5FyJpEph9EHCz0Ilzpp4WHkbhZ/Wmri5MSAi6KIMRpw2bSqZm zPxkVO50TFF87YHBsEBAaDSfiTWrCExGsNwvnGM6pVQiO9v5L0nia/Zc1Ov/PzR2RfQ= X-Gm-Gg: AfdE7cl3dml7wwr+D4NCj80NPqcPkYGdVyjHmW2iJnfDk+WOsUOGMXmCuZQuta7HtG2 6d4c1e4V6nlFcfNmEWNI6SxnBvcc89fRZ297W1USrh/d0mYxv0GIKGbmghHSnkaSCBvvlluJhY0 1WNI362YqfDrLmTROrYkwhTaIjrJNnoXChhfyzym0zFyc0tMWXsXvv4D0Qf/kEPiCYOBAthXSiz FcngA2Fd1ZibMYSxfVTy755pL5OxIfweKTz0x2W3yFMnpUtjiDzElS1WA4mYThbvkCs0h71GqSS TFzs8WRXk1eTlbRIY6xUQ/MeXttkjqxAtH49DydFVwd66jYacVQKN3xBDJQLQJi+xc8h+tdus6H S00BiSOxwezhWNoXUROwARGdFHFKZag9cd7FpF6L/Nd52ovapAZYB666+U6vbWMImxBDqnnF+h+ bSmlovg7iHtV+7RnTDvvdHEwtENDg9QYFkPJxjI6ZwvqTIazGc8FEM9f7Ks59K2I/vWc0VjFppw /v2QnE= X-Received: by 2002:a05:620a:45a4:b0:92e:4927:2002 with SMTP id af79cd13be357-92ef2bd531bmr625812485a.39.1783860061909; Sun, 12 Jul 2026 05:41:01 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92ee5d375fesm815846285a.37.2026.07.12.05.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 05:41:01 -0700 (PDT) Date: Sun, 12 Jul 2026 08:40:56 -0400 From: Gregory Price To: Usama Arif Cc: Andrew Morton , apopple@nvidia.com, balbirs@nvidia.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, byungchul@sk.com, david@kernel.org, dev.jain@arm.com, 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, sashiko-bot , stable@vger.kernel.org Subject: Re: [PATCH v3 2/3] mm/madvise: skip device-private PMDs in cold and pageout walks Message-ID: References: <20260710105557.1987433-1-usama.arif@linux.dev> <20260710105557.1987433-3-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260710105557.1987433-3-usama.arif@linux.dev> On Fri, Jul 10, 2026 at 03:55:22AM -0700, Usama Arif wrote: > madvise_cold_or_pageout_pte_range() takes pmd_trans_huge_lock(), whose > pmd_is_huge() check returns true for a device-private PMD. The subsequent > !pmd_present() branch has a VM_BUG_ON() asserting migration is the only > allowed non-present case; a device-private PMD trips it. > > Skip device-private PMDs in that non-present branch and continue to > huge_unlock before calling pmd_folio(). Downgrade the check to > VM_WARN_ON_ONCE() so an unexpected PMD softleaf logs a warning rather > than panicking. Drop the thp_migration_supported() guard: it expands to > IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_SOFTLEAF), and both > pmd_is_migration_entry() and pmd_is_device_private_entry() already > return false when that config is not selected, so the guard suppresses > only the case where the warning would already be silent. > > Potential trigger: an HMM-based GPU driver races with > madvise(MADV_COLD)/MADV_PAGEOUT: pmd_trans_huge(*pmd) reads true, then > migrate_vma_pages() flips the PMD to a device-private entry before the > PMD lock is acquired. > > Reported-by: sashiko-bot > Link: https://sashiko.dev/#/patchset/20260703173903.3789516-1-usama.arif%40linux.dev?part=6 > Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations") > Cc: > Reviewed-by: Joshua Hahn > Reviewed-by: Zi Yan > Reviewed-by: Balbir Singh > Signed-off-by: Usama Arif Reviewed-by: Gregory Price