From patchwork Sun Dec 1 21:22:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13889652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4091BD49789 for ; Sun, 1 Dec 2024 21:22:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C44D96B0089; Sun, 1 Dec 2024 16:22:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BCD356B008A; Sun, 1 Dec 2024 16:22:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1F216B008C; Sun, 1 Dec 2024 16:22:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7619C6B0089 for ; Sun, 1 Dec 2024 16:22:57 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3D1D7AEA90 for ; Sun, 1 Dec 2024 21:22:57 +0000 (UTC) X-FDA: 82847664648.03.E3C0D5A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id C0CEAC001C for ; Sun, 1 Dec 2024 21:22:40 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NlI2sh0Q; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733088170; h=from:from:sender: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:dkim-signature; bh=KsWvwrfBnqjvbOnN4TJvOMsBkpZZHFy0C0E293ikvrs=; b=5oyXBilVdhTu+TPi3dIZKGgjVXjNxkeYEyEc5nO2gh+fJQ1iQjA52nLqJllXutYGGf8pig RUDD2K9L4HjiihbLRF/PfAuDXbtVV3S1441Xe1fNJFZE4MLhFxrCA6MphOzA76GpV4U9J8 3KXXxyozEjRP2rze9Clapno0PLlIFQc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NlI2sh0Q; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733088170; a=rsa-sha256; cv=none; b=Uz5HTuleyE4coEOBjWvTbkST7hbylesOo3d8PfIQmjnShBXQgajpGvy4JOtLgYoUO3rw2z VevtL9V9IX+CjL4ZQBlrf4MQd5dyxvSLJMbpMhZkkwfVoTNFVMb+qSD9LHVq41Mez9r0jt kL3Uskiyjt1ZbZOYtmvGIOFKOhhAqYs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733088174; 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=KsWvwrfBnqjvbOnN4TJvOMsBkpZZHFy0C0E293ikvrs=; b=NlI2sh0QVW/RKVELuahqqG9WwC8QiEIRYXVXRH6EbZ5MSOaKpZPKDfl8tiJDj1izhfS6Gr 2E+Cg6jG6SmPBgymeWHpFJ+rMeAphsVU1EslgCHH3bEgIFBuZ/7QpdsrmKjx42AzqLejXg 2cvRlFh+3BcVbdurCR8AllssF5GL9zk= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-DaP31WVdNRKnCRJP1_xCsw-1; Sun, 01 Dec 2024 16:22:51 -0500 X-MC-Unique: DaP31WVdNRKnCRJP1_xCsw-1 X-Mimecast-MFC-AGG-ID: DaP31WVdNRKnCRJP1_xCsw Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4669c1479easo58056981cf.1 for ; Sun, 01 Dec 2024 13:22:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733088170; x=1733692970; 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=KsWvwrfBnqjvbOnN4TJvOMsBkpZZHFy0C0E293ikvrs=; b=xJrZcW+OarU1j002tv/mnAGotgij/YOg6p6Z5Nm1iK6yBf7v1gGYE+ZQWYZwRkFlf2 WluYtJXgJXLWe/DhWKTHKb/aSUXe+7wlcS71pTKPMMSqEcGeqi53+umHdnZqfzTlrgji qMQ4JUWvHgKgjWhj6UGqFENaD31NvD1gIeX7fQNheNuP1ShFvcmK/jB9VxW1nfgGw9yD in1uCDsxINoHmyU0vbj+4O+lcypGqwf+0DLQPvi5SWozrcxueKV0Q5RQzZBZoA6TOAhl zwQNiB7PotvPc4Yheo2nYn0A6iTX1swhEDxqrqI/Du2xesd7fUGIauJ5eryXwPdtHD56 LE9g== X-Forwarded-Encrypted: i=1; AJvYcCX4trccvfSbjBrgrmXSLz/S7VtF7zdI1za6iFtzVm+tGU+gjftyk1Z9i9cJ95WcpygVgu0EZ/mkVQ==@kvack.org X-Gm-Message-State: AOJu0YxzMhXELePXzi5payAh0GlCkHuBD2C/E1CQ4GB2bbdjgVrNs3Cx 2nFLASxkrjBLLhaBXzv6fJqZF5+fg/omFZyXl0W8oWgkgRhi6cE1TVvpzucBGETSTOOycJj1SZm 4BDPYxNMyRcSVxH8Ark9ArAMBoZjdQcgqPLU8M+WNwhpV5/5C X-Gm-Gg: ASbGncvNfA4kYavgI+Pjr1+E2RAZr/o0qtPDDluYnfdptT4EGQcyWuYMrKuNYXw09Pq u4V4wcAK4TDjEa6lduAuOuTLQGRTMGG/+auFwklKHkRuGz68klHHPAV3KDauyhYoESJSclatyrI iqeiyW+APsl+2kt1uD2baJoewK4Qygk9+/HjKJI+cy1h4rxwtR6mOA8awAZxVUEJcYsgh5KXStX iJGsOVIqJ7MslE/fVv031Ev0dEggbA75oL54zZJ3ZsIV6BzYdIAX+/lnZv9jvyR1IPrltf+3Qh7 hF4ExbaxftsI4CR2hKaURZmBNw== X-Received: by 2002:a05:622a:46ca:b0:466:d559:b528 with SMTP id d75a77b69052e-466d559b5cfmr148250331cf.17.1733088170654; Sun, 01 Dec 2024 13:22:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTMiVxnYL67fM20hfjxO5Kmh9CkTakr0bybTA/KMxSrhoCBEVkaO75R4et7jq3KR1ig2eA4Q== X-Received: by 2002:a05:622a:46ca:b0:466:d559:b528 with SMTP id d75a77b69052e-466d559b5cfmr148250121cf.17.1733088170359; Sun, 01 Dec 2024 13:22:50 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-466c4249f0asm41278911cf.81.2024.12.01.13.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 13:22:49 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Rik van Riel , Breno Leitao , Andrew Morton , peterx@redhat.com, Muchun Song , Oscar Salvador , Roman Gushchin , Naoya Horiguchi , Ackerley Tng Subject: [PATCH 2/7] mm/hugetlb: Stop using avoid_reserve flag in fork() Date: Sun, 1 Dec 2024 16:22:35 -0500 Message-ID: <20241201212240.533824-3-peterx@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241201212240.533824-1-peterx@redhat.com> References: <20241201212240.533824-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sKpDCUB4u3kLGqGpRGPB6PVnNNcFA50zPdQuOc6kcts_1733088170 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: C0CEAC001C X-Stat-Signature: s3hp69xabtc3sqi5jk3sdfhmb1xt1gi4 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733088160-451404 X-HE-Meta: U2FsdGVkX18u7nzkyhtxACt+pr877GUQ09Ls9h/Byz4YZahyrcuV/h2E9fYBozcBa9NllhG6/CtxXYHsAN6Rs3mCoLGi5auPuYE7j6rhtmCylTPTPwqHWKhCD/tx/D+npg7jBE7xSj+dJE1L50tV6OvoONZUor7vd3HawaSEPT+aTVYGBJCVb/Go5V+DMRIfsVn5nfDhCAu8rR4mnuZuHSM+BV7sxHoWoIvFP6Kiup44X6cj+sGM9DA0UBB5wbaYuJ1rx+TOW+smTaLIKGaWzgphLdNPxhqSmF8KJoeqCiGsHW4/ppcs8LieZOeSvGn+W276m9O8a5YEaWmfNCSdMt+auYJvbLl7nsQPlcu2rHqAfJ8/wTk4WgO35csvI8f1tZYNXyAga/qHquB3ULQf6SZmdjRD7EcspJiFdMZ31bvnm+ol3HC6vZJN+JS7ikk5H6bCCZNPkrTPjhwCHEr4vBqls3aOYOtR8sRrkEItUd4RNaCE+ARJ71VCG5wPHSPiTcWHHpmajGU+ydnPf/+UNW+n5Q4U4vBBPEmvQc78Q1p1nnkM3BBg7n6LXEqo0M2QreGD+av6sUgLKWDFKoi+srflpMqjT8QPFFpSaqACAWdhIk7TCgEKONPJ0GJ4TIOs/enHPTgArhbCJ2WkDYDzZsE7V+YaotNNTOdNaPqFANtUr0U2s0DMGeuVBfPX4t6uIuWNKD0YhMfXfdK1MajxE+1e9GOsfxkVSGYLkFeaQ0EAYjH2FQUMdGCk3q+jxGo8dm5hIbrfT9SSIoSg2ar+k2YAVRi2IUBwewjPQrYcgFx6YR5CxOoTvpOf8Lnrzu8lmNSar6p+RMTSpn4s54EExd+dGpvUlWUHSjUYW1OAwMfopU2M1wNv8DDb5+89a9UxsyPDw0ejJoBVOG2N+gpwdWvIisxhPK1kiXABkLiuWcIPdvrJKk2BQoZf99cpdloNAz1Jiph4K9ZNh0JhPbd Ba/D1jqD 0VNj0D7/r34lLJyb1yOtQkglRcdaQ4Sgs5mXQcCH+XU8jFm90IwTXx4YtnNTV/0+v90w4aWtHm0NXeBdqEPfh/Z5utYGnUAsssr7ZB7BVTm0AahlOHKEjVSsdXmaLSgRnKQe8E3wVRL42BTt/AHxdx0gRnraACOtJKE9hQz3+Fk3K9T0gSM/f4X7o8yHWeIbKpE8pXVwLrcnUtJr3j8YObbfguc39LRfCNysS4EfejFhpYn4Iq5A5UhENOMGBu1ugsEi+/QvAFNKlntAhN7TbtN/Dam/JAjCSsLOqxBW4ewJF1YuXQPKafh7gBwLtJ1uX6/DH5gj78yk8mK9bQb/E6vpaH6fQpmICNrtTO8IbNCasTdWq9bUk49HdUwmBNPDPLytFwZeMe67M7YKSWay5ofpgCVZtWkp+pE4pYm9C9PYRqB2cr0125D9enLPTJID1oq4p89P4wP+VNEzWRE9QynNOMtnvlrVXMvXr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When fork() and stumble on top of a dma-pinned hugetlb private page, CoW must happen during fork() to guarantee dma coherency. In this specific path, hugetlb pages need to be allocated for the child process. Stop using avoid_reserve=1 flag here: it's not required to be used here, as dest_vma (which is destined to be a MAP_PRIVATE hugetlb vma) will have no private vma resv map, and that will make sure it won't be able to use a vma reservation later. No functional change intended with this change. Said that, it's still wanted to do this, so as to reduce the usage of avoid_reserve to the only one user, which is also why this flag was introduced initially in commit 04f2cbe35699 ("hugetlb: guarantee that COW faults for a process that called mmap(MAP_PRIVATE) on hugetlbfs will succeed"). I don't see whoever else should set it at all. Further patch will clean up resv accounting based on this. Signed-off-by: Peter Xu --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9ce69fd22a01..8d4b4197d11b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5317,7 +5317,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, spin_unlock(src_ptl); spin_unlock(dst_ptl); /* Do not use reserve as it's private owned */ - new_folio = alloc_hugetlb_folio(dst_vma, addr, 1); + new_folio = alloc_hugetlb_folio(dst_vma, addr, 0); if (IS_ERR(new_folio)) { folio_put(pte_folio); ret = PTR_ERR(new_folio);