From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793109198; b=jZ2yWQSFUBQ/ORThhf+T1wo82i+4LfD8uj2nLZ7H3vfi1y4ECfkoPkA98bfIlGCun3Pt 2sMTer0vWOOyMoCQxFicqZFj9mY/6kquRB0OHjQ18lmqUtV5oWUG0AyP02GbDaFmnTdX2 VDJSsTK9fWYu7WqN9D8/Y7zajIbNvO+xHRbaT0yqGQn5T7LQcQUESG++NQ9NMqEX0p5TV CpAT33ppLghgDVkltrU+8vsyY+uxZM6U5Mkxi8hpMTOr3LMuTpOHk7Or+IOinsDaB0q1U SKBbuP3QcK49M/FQ+kMVq1IBN2MPBDL4+PapqNHnrELblr2zqfweGtwPLWuftmBNqsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793109198; h=Received:DKIM-Signature:Received:Received:X-ME-Sender:X-ME-Received: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=wGwT1JNbkqmcP8fUAnZimf+aufAiCIdNGNB+5b8MPdA=; b=nsN5HbohDMMB55wZ1/UyT3gC94BMv7QD2g6WuKtWz7T411pYS11h5nKj/x8KWIin9Qbe +gsBWlrC6un3YYjlpyvun9MDNWsa3r228uMYEVUkvDlPM1LD6UUgh3sKQn8MOK3Ri6Kxn QG49axsVhQLPrHP2TJK/hhgGL52Axoxig1GWsWn0Zq4qFeNeiZPnNC9Ne0nRD7B2Uje26 /YVTfHIdBDGadQnfolL7PSZR48AEmHlqwwl9GO+bhZwv3TU0YTZjAZr63fIr5GYYjUMNy iVSAkLhrdE8Hb9DO1QkkNwWqvC4zdLLkOJjmG89HgQDyFh7ec4iHhhGoTzE2jusUypg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=neJ6Av6X; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30F6F606A31B for ; Tue, 27 Oct 2026 13:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=neJ6Av6X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09EF01F01825; Tue, 27 Oct 2026 13:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793109197; bh=wGwT1JNbkqmcP8fUAnZimf+aufAiCIdNGNB+5b8MPdA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=neJ6Av6XcAg6zlKSlBzItq+Kq/XVhU3FTSTQ40LLLW1NXhjlBZMaCGr98AraxOMEW +rDgxRqp7oMaPJc8VyZy3Z2ZwiMs8mKLlkRYid5Si+8vRh5YKfA/TlGpvTGtn4Ycq5 0cBX5X6C6Ip9AqH+3gxI2qSkLhOmsx7oN3SLHF+zGVB/nBAHoptZDnJE9pksEQoklH p03vP3AByRwPSoY1xY1ZITKr//jMGet6GgRJvnIhJNHSWDtJh3MSNyhw6L14pkJR9t BFOUfHKE/qGFAhxkcxjILeQvMa/1rR26xCoph5E/k6fpoaA9TG1B224LzKuj4NzVNA kgT6eeSMMSZfw== Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfauth.ams.internal (Postfix) with ESMTP id 85CC7198004A; Tue, 27 Oct 2026 09:53:11 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 27 Oct 2026 09:53:15 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEZ/rZ8QL4tKdVH13M4isFoJoqE6mmyk1+ybcvlxgqSp6W0ayLRKd0L7SfTmxuGb5 U6+Pfm114T++Wp3SC2FV78EqIZ6zQGqKV5XyNS0Q8g8zeea3kGWywXyvNgIRW79CajYQHr 2jF/D3zyUpa8mENlQ2k9kDlrLHG9vuqIwsGPeExjecTgPLyR3BG4mU+4iFcKzGjlB8O7dl rHahXQtAt7H4ct4Hi0ph4caUm45qDhARWvo+NXS6RvFk5in2esxS1VkNF3/wtGoX2gxkDU HYhd+ifyLHB/lQg4TvDcO1vty+4TgdFGCdUfD6xIrm+RnS//HTrIeeMZCfQmeBD5mTfrrt 28F2SJuazbG4sdilPjnUK5Xk2C/b77Urnpd+yJpFkxf0srCyBWlhL6vR0USCQldwnnbiLW 9q+grn+3rpVTZTV5aFHrdKvOYqBL1I68cy6Ts9EvEo2mG6eqSnlWVGArQuLZTDmYpXGIvS wXLvRFTOpi4viZ4HzYk4qCerKNTdy3232MaWMRw4+fGiHl1k0822eLObmoSxbGhZG/SB+U RY6eT6x1Fr7R33DiHsTIEPGR6+Uf+O9CEjZE+sUhhEJff/MTsubZ9LmOVI85mrAWUqqbJx XWv9aGmJ+yJbAfbRPaNRNIocYryGvdsYvD8pPJi4F3KUYMPNesYsAvQV4dWg X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Oct 2026 09:53:10 -0400 (EDT) Date: Tue, 27 Oct 2026 13:53:09 +0000 From: Kiryl Shutsemau To: Konstantin Khorenko Cc: Andrew Morton , "David Hildenbrand (Arm)" , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Peter Xu , Alex Williamson , kvm@vger.kernel.org, =?utf-8?B?TG/Dr2M=?= Molinari , Lorenzo Stoakes , Shuah Khan , linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Madhavan Srinivasan , "Ritesh Harjani (IBM)" , linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jason Gunthorpe Subject: Re: [PATCH v4 1/4] mm/rmap: duplicate a PMD mapping as one in folio_dup_file_rmap_pmd() Message-ID: References: <20261021-b4-prep-vstor-149847-copy_huge_pmd-recheck-special-pmd-v4-0-66f00b7a564c@virtuozzo.com> <20261021-b4-prep-vstor-149847-copy_huge_pmd-recheck-special-pmd-v4-1-66f00b7a564c@virtuozzo.com> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261021-b4-prep-vstor-149847-copy_huge_pmd-recheck-special-pmd-v4-1-66f00b7a564c@virtuozzo.com> On Wed, Oct 21, 2026 at 10:36:00PM +0200, Konstantin Khorenko wrote: > folio_dup_file_rmap_pmd() passes PGTABLE_LEVEL_PTE to > __folio_dup_file_rmap() for HPAGE_PMD_NR pages, so it adds HPAGE_PMD_NR > PTE mappings to the folio instead of one PMD mapping. Each unmap of the > PMD removes one PMD mapping: > > - the folio's mapcount never returns to zero, and removing the folio > from the page cache reports "Bad page cache", or hits a VM_BUG_ON > with CONFIG_DEBUG_VM; > - the first unmap already counts as the last one and drops the > PMD-mapped statistics while the other mm still maps the folio; > - the second one drives the entire mapcount below zero and drops them > again. > > The helper has no caller yet, the next patch adds the first one. Pass > PGTABLE_LEVEL_PMD, as folio_try_dup_anon_rmap_pmd() does. > > Fixes: d8ef5e311d7b ("mm/rmap: convert page_dup_file_rmap() to folio_dup_file_rmap_[pte|ptes|pmd]()") > Signed-off-by: Konstantin Khorenko Reviewed-by: Kiryl Shutsemau (Meta) -- Kiryl Shutsemau / Kirill A. Shutemov