Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796377776; b=idnITqGA0WP+iFUrdHdl5qg8WC39AFuX9mF8DQL7kuLExQNOEsQMlsSyH1l085VlCrAR b3U8jAOLRHNhhuRaQ/U3IQW2VK/zXR9zBLr1m6Fvbbud9tYZF+8COO+Q0BenusJkVLZJz ZB61gvhiIQiszcpPz3HcD7HNwt0lwEFH18tlOvKUizvn913jaxYMaVMCzxj4/KYZHO0kU QaZ7Z2h6ODm9Ds5eJAHOBYapfrnlrxGNbulc/BHbtX2ofLtRVHC/YmXE7hZeXtgk41pJa D3P0ZFSVg3SaWIFajqX7PWA+oxDv07IQXG7hxHw7fiWbFF86QLLfv0nScff+Kw0UbKg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796377776; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=J3vUHhVRJsSdbndIQiCvV93SXI3h57sB9uQggB/V6uQ=; b=HBo1vpokLLvRzu/k5tM2A+SGzHZubhNwVl0IFp9x3fepQMTku+2t2UQejeXMooZJ8gNn BGFv3OQ/MNBcu+O4pup6ZvqOWnPwPhq7qOGzsOYT2GOnycNKT+MHRBDs1+lcBZj7FkmNW wMeX93cNzKZN0+u+IVohCwwcYOE9SR5XU5SuBDearpZHW6bdf7wCzGVveLaLwew0kSvug R8z5RQayoDLLliVsUhgitgfG7dpFTz2zSHDMxD6O76WHuoU1/5yTEdOC3kk5YUEH2YpQK Hkh+2WQqdUoVxIQlgh71isfbC/1cF5f3em8pVf748cKBSb9fhmgSovLOsu7IcNyaEIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=YbJ6ndpH; arc=none smtp.remote-ip=115.124.30.97 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BCF3606A680 for ; Fri, 4 Dec 2026 09:49:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BCF3606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=YbJ6ndpH DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796377767; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=J3vUHhVRJsSdbndIQiCvV93SXI3h57sB9uQggB/V6uQ=; b=YbJ6ndpHnqOJVroAlwo4eZgZnhjEamL9cDaW4fI9jk0dullGy6E5cn+niuJ2MYJwzuHuh1A7piRc7bnFc/rV+eJL9I7BK8/R5BgJ7i5ArEVMzGUtWyKcjsXTSoRmTv0jekCzXevi3/OTe2dtwBGzEv5IsiBAD4OtZXjcUp+MyRQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R661e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0XGGtIWl_1796377764; Received: from 30.74.144.139(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XGGtIWl_1796377764 cluster:ay36) by smtp.aliyun-inc.com; Fri, 04 Dec 2026 17:49:26 +0800 Message-ID: <3e173239-73e2-49e9-b0b7-49e40635cc67@linux.alibaba.com> Date: Fri, 4 Dec 2026 17:49:24 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 8/9] mm/rmap: re-enable discarding lazyfree THPs at PMD level To: Zi Yan , David Hildenbrand , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Kiryl Shutsemau , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Kyle Zeng , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sashiko References: <20261203-anon_vma_uaf_fix-v2-0-3d4c746e8839@nvidia.com> <20261203-anon_vma_uaf_fix-v2-8-3d4c746e8839@nvidia.com> From: Baolin Wang In-Reply-To: <20261203-anon_vma_uaf_fix-v2-8-3d4c746e8839@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/4/26 12:17 PM, Zi Yan wrote: > The patch "mm/rmap: don't discard lazyfree THPs at PMD level" disabled > the PMD-level discard, because it cleared the PMD before checking whether > the folio could be discarded, and munmap() or mremap() could skip that > transiently none PMD. > > __discard_anon_folio_pmd_locked() now keeps the PMD invalidated, not > cleared, until the discard is committed, GUP-fast no longer follows an > invalidated PMD on any architecture, powerpc page table check no longer > counts an invalidated PMD as mapped, and sparc64 keeps thp_pte_count > balanced when an invalidated PMD is set again or cleared. Discard lazyfree > THPs at PMD level again. > > Also call update_hiwater_rss() before unmap_huge_pmd_locked(), as the > PTE path does before lowering RSS. The PMD path has skipped it since the > PMD-level discard was added in commit 735ecdfaf4e8 ("mm/vmscan: avoid > split lazyfree THP during shrink_folio_list()"), so a discard could lower > RSS without recording the high watermark first, and VmHWM could be > under-reported. > > Reported-by: Sashiko > Closes: https://sashiko.dev/#/patchset/20261015-anon_vma_uaf_fix-v1-0-7b977303b42b%40nvidia.com?part=7 > Signed-off-by: Zi Yan > To: Andrew Morton > To: David Hildenbrand > To: Lorenzo Stoakes > Cc: Rik van Riel > Cc: "Liam R. Howlett" > Cc: Vlastimil Babka > Cc: Harry Yoo > Cc: Jann Horn > Cc: Lance Yang > Cc: Kyle Zeng > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- Make sense to me. Reviewed-by: Baolin Wang