From nobody Mon Oct 6 22:49:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1752753168; cv=none; d=zohomail.com; s=zohoarc; b=FEE/tWH4aFbw5S60tO9c7h6OUHrielsFqJwYhB/lG5t8HlNJrNx80rx0tAYd3L38T3FCuVhFRE1/q/sY9O9Q20i5C9GZQSAs9dg2y+mnFGmald//Ol4BYgQ9dzte69nMgUTFJxwB9DdFGGOW1DVBfSJbejMpAnJtEnUHx2pivjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752753168; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oAAYYXy+5qwpASBfNrlxr8guN8G2i706wjpGFlltV74=; b=Y0gLFLTIjhdoi0r58g/etbjBL0o9LQmCKJKC9APcHDhII+saNtFen2Nm72hZVnqxCbFsq+6k8cSDBeYx+/oKfuoA2UM0/Sj2nOI/s01gKmhlgSbjdO1hLOrVcWEDXTypstt37bIX2d1m8TiTvLmizGj1J4J/bUuc9EwJTqf6mgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752753168872421.11226540794917; Thu, 17 Jul 2025 04:52:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1046608.1416981 (Exim 4.92) (envelope-from ) id 1ucNA6-0001yA-Uz; Thu, 17 Jul 2025 11:52:30 +0000 Received: by outflank-mailman (output) from mailman id 1046608.1416981; Thu, 17 Jul 2025 11:52:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ucNA6-0001y1-RU; Thu, 17 Jul 2025 11:52:30 +0000 Received: by outflank-mailman (input) for mailman id 1046608; Thu, 17 Jul 2025 11:52:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ucNA6-0001TV-8b for xen-devel@lists.xenproject.org; Thu, 17 Jul 2025 11:52:30 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 831bfff8-6304-11f0-b894-0df219b8e170; Thu, 17 Jul 2025 13:52:28 +0200 (CEST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-d2QeHBjPMR-28s-cTvWR9A-1; Thu, 17 Jul 2025 07:52:23 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a5281ba3a4so517464f8f.0 for ; Thu, 17 Jul 2025 04:52:23 -0700 (PDT) Received: from localhost (p200300d82f1f36000dc826ee9aa9fdc7.dip0.t-ipconnect.de. [2003:d8:2f1f:3600:dc8:26ee:9aa9:fdc7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-45634f4c546sm20298345e9.7.2025.07.17.04.52.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jul 2025 04:52:21 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 831bfff8-6304-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752753147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oAAYYXy+5qwpASBfNrlxr8guN8G2i706wjpGFlltV74=; b=PowJqas7tpfMmsMJaVxOmZnEmQPtsKHWnYCHCm4aEYoT9Aw2OaefEcltD1hxTxxQkn6Bov g0O403vR4QPDWg7P0Ucrsj3KaP0PQB4jBOQVAGTZ+umBd1UD14S7oGsQBeZiXKnQLBjNxc phvY48Te2VAiSA9cidoTnvC96mzq6hQ= X-MC-Unique: d2QeHBjPMR-28s-cTvWR9A-1 X-Mimecast-MFC-AGG-ID: d2QeHBjPMR-28s-cTvWR9A_1752753143 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752753143; x=1753357943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oAAYYXy+5qwpASBfNrlxr8guN8G2i706wjpGFlltV74=; b=E8PKKuhKOtVU6zgTXPv1WNnHGYONpkFc3hl3nh4W4ZyKv9gUJvge11eHO4iZ3Fb5ED ReMU6R6km9ZzkHYnyIoCHw6tvucy7W06ZV0ryj0Hz/vtNBfMHftzD7kthD6upTt7ZvbJ 6jHp4uAENMr49WKk/RM2Uj02zfJFD+cf5rBclSTSnKJwNJMrCCBIvnU/bTBetUNFrOMt InyFa2+JPVrxAId3C9esoFyR4BgeENV1lElQ2LwWAa5FLdVK4hduHRIjCXVdrgxTPwDS IQVfLQsTOTls8nvWIYl9+Ej6hE94Lq7q0vtRXeBmXsJPtRp23zr2KDdwUQNxsc7oGvoP LDoA== X-Forwarded-Encrypted: i=1; AJvYcCU3FOGkgh6J9GlliGBUUgMrK2thSA8TxoekLbhnCcweJIslnf0MLJEpuleWyW5EaNp3OT1vw815Rj4=@lists.xenproject.org X-Gm-Message-State: AOJu0YxoMt7grY09Wq5d1bDSF6YPf7ujlBp7YGXx29j4nUm2U1xHr0KX UnD3S3vU7N0Eczje28R10kfkzmHJmAOvoXrSMZRYcemP2iEu/BAHqCjxz4cIEci680HBQqwWVXS tBRLjKSqLRTythvmAx6lOoUeH9KUwubA45Upw6GLibKKO6Ef3fv39udAabH1lNK2GO4i1 X-Gm-Gg: ASbGncsJQ0LeVTLG83lYs6QSNBtIdZbMM/XamGrrv04vbQEUDKAHlCKkDgHqcFEK6zI hRDeBgnOBGWNoKD3YnhlgcesYh+T7/mZbOx9wVBUnha2RWE7Ady8puBmDDpgdrrkulIcS+6qqZA vCLa4dn0KmvKdnOKkBreQH0Av8QjND8KeQI27JEdrryq/5pA6kCWxLh6Dmj0nsFd5QYqZk/f61r Px0mx3Wx882JOSi2hbz1p42vAeovb5O1H8U6Pn+AXuR7t+6xpZkEiCsq271uKF4r1alRj36KKvZ TxdH6Pk1va5QCzTdSJWMMmtzlH+oSjbypMX3n30x/PMy5pWLYBOF1xcAfMQFL+/FW7R+IaTqv+z Df+vxCTC+oytRIsFLkuruBHA= X-Received: by 2002:a05:6000:23c8:b0:3a6:d95c:5e8 with SMTP id ffacd0b85a97d-3b60dd7aac2mr3879076f8f.35.1752753142626; Thu, 17 Jul 2025 04:52:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLqq0HSziphIF4gY7jkSa/7zMDAewp7/5b6DkIKpjYL1yIcxKWQwPQ10nRUjdRU/WgBdtqyw== X-Received: by 2002:a05:6000:23c8:b0:3a6:d95c:5e8 with SMTP id ffacd0b85a97d-3b60dd7aac2mr3879028f8f.35.1752753142142; Thu, 17 Jul 2025 04:52:22 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, David Hildenbrand , Andrew Morton , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Dan Williams , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Jann Horn , Pedro Falcato , Hugh Dickins , Oscar Salvador , Lance Yang Subject: [PATCH v2 3/9] mm/huge_memory: support huge zero folio in vmf_insert_folio_pmd() Date: Thu, 17 Jul 2025 13:52:06 +0200 Message-ID: <20250717115212.1825089-4-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250717115212.1825089-1-david@redhat.com> References: <20250717115212.1825089-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Y5TXmE1qdGBfuo4UYH0z0C4uxuZTlxmI_yGfLIZFYqA_1752753143 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1752753170328116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Just like we do for vmf_insert_page_mkwrite() -> ... -> insert_page_into_pte_locked() with the shared zeropage, support the huge zero folio in vmf_insert_folio_pmd(). When (un)mapping the huge zero folio in page tables, we neither adjust the refcount nor the mapcount, just like for the shared zeropage. For now, the huge zero folio is not marked as special yet, although vm_normal_page_pmd() really wants to treat it as special. We'll change that next. Reviewed-by: Oscar Salvador Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes Reviewed-by: Wei Yang --- mm/huge_memory.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 849feacaf8064..db08c37b87077 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1429,9 +1429,11 @@ static vm_fault_t insert_pmd(struct vm_area_struct *= vma, unsigned long addr, if (fop.is_folio) { entry =3D folio_mk_pmd(fop.folio, vma->vm_page_prot); =20 - folio_get(fop.folio); - folio_add_file_rmap_pmd(fop.folio, &fop.folio->page, vma); - add_mm_counter(mm, mm_counter_file(fop.folio), HPAGE_PMD_NR); + if (!is_huge_zero_folio(fop.folio)) { + folio_get(fop.folio); + folio_add_file_rmap_pmd(fop.folio, &fop.folio->page, vma); + add_mm_counter(mm, mm_counter_file(fop.folio), HPAGE_PMD_NR); + } } else { entry =3D pmd_mkhuge(pfn_pmd(fop.pfn, prot)); entry =3D pmd_mkspecial(entry); --=20 2.50.1