Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp26561rdb; Wed, 21 Feb 2024 15:51:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcgT4dx6UkVHYvGVfZ8+ZpwyiPtr6gjOQZ6jV9DyeOQCLnI41qtYtWnBpcfM/oG6LmV+4ISUW39wuwznFhAgm/8C8lpvwz8x1w6iuasA== X-Google-Smtp-Source: AGHT+IEcswlM/gU3RD5j3IfljnOLNi5mxNi9tCIb7/CA5dcnwmJzpm9CJmrl9wFi94kclzWN9xq+ X-Received: by 2002:a17:906:559:b0:a3e:665a:45c0 with SMTP id k25-20020a170906055900b00a3e665a45c0mr7414528eja.45.1708559479454; Wed, 21 Feb 2024 15:51:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559479; cv=pass; d=google.com; s=arc-20160816; b=aY3m12pUPctGcRrYBzm2djM9av86CRmG6yQXqiENZ27tEGFOo7T9sJmT69qwxrgNJH dUm2YInto+hqQb1dZjMN60opLV7sCpqrhPK9uJa/4LgTmN6pKlzui3jkfJeLy9dT95r1 h7iyKQO9z++Jhw2WewzRaccZ5BTdLRFUJvG5WEsQm2Lr4yTX4dzbpZ2q4xqrN8IUlfp+ 8joucbP858G47X29ZOX8visbm/cd2HSk9d9Yw8nTUP3/c7VkKwp/2pNGPXJZisIm83yG uORCPJqKQNRvlGUieqBGyn3zdBx9zgBoFQys6Kx1GnVLhmdf91KayG9AE23M029eqQ/4 vnSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=BsN2kLkfw/HYtPBcnMV15VLIc+YGyi5UEwcGioMpvo7C7iNS7EZ6ZyxTbYtQbEAP6p v7b/+yrx46cYx4Afpft7+vzjBHAJBl/rLo/NQoL1wHKyvvt7KhOcnkl8MPx+yytbZPCd kD+vrU68WlZOf5RTDbIpVUGxAD+gvxu7d6BYJ1QvIhAcjFnvZej9y5xf7zd8PD1xRxR2 ZGOJMGpJJvRX96kiqNJQ5w7PO4ORtMSga0wEnksQLh8yJw6U0Nfy2KafrDV3XCmk10yt vN5S5xkJKBgLcdRsGXK2aesOCF1dKyL++m5utmleD3S4aLzdk/XaTuQsIn57MH1tvnA8 xarA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LgC/KyMo"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gt20-20020a170906f21400b00a3f7f1fcc73si71696ejb.347.2024.02.21.15.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:51:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LgC/KyMo"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2ED8F1F244F8 for ; Wed, 21 Feb 2024 23:51:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3972132483; Wed, 21 Feb 2024 23:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LgC/KyMo" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 CB5C212EBD8 for ; Wed, 21 Feb 2024 23:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559407; cv=none; b=j1DPKqpwaddOGIBGj7pnEjLbOSGcGqOUbeiCpg1ABDhB1WuH/afIcO7w9ifRucsoh5I9iWiJXNkTnvtS/xTrvlHv0tCPYPNJF2tHICn6x/iGL1Cq4NQEphE8XT0ht1sbuuX3WZrX80hyqNPDwvADpXcLk00lPuWMgHBB6jrE+jM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559407; c=relaxed/simple; bh=kuCilgvuAIh9xQxA9Yc9QbjSc9LNo4S0L3J7arnWxXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Seg8a6UIDeQeh06BjSFN32p+W2NDCB8JseJo2CyFa8ftKV+U3zZOPO/gHHL7KdRiCE7T9kRIkOZh78PH+u6ASfheQsQloZLZGWmMbjkCQ5qqopxoFww14X4K4HswgvIdv28nUIozDD8ipnb1YbFHez3D2O1qeq/RPYm3Yb2Db+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LgC/KyMo; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1dbf1fe91fcso34096775ad.3 for ; Wed, 21 Feb 2024 15:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559405; x=1709164205; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; b=LgC/KyMoozmyO4oXLVBr62ZbpCIIufqufHT80D2orEwyE/eaXu+Eqa5/u1RMMyDnu+ yDKe/MHODT98BV+umht4rYfU1ZrLXUToA6enMfzs7oDUizM7NMZmmA70VSmGsjDPTLcr pcQVut8HoYojsUDmM2Pi7RAFYLm/iNrHF5xVCofWzS4YkCvgJ3kbenrLT7PkUlWaehP7 FsCQbIcqNg4R1PtTeWNwj2J7GwfEh9zaKGn7UmYTsiRt5AM51gUlwuPTJzp/84I/QMr6 rILRVI3h1uRdaGtwaPRVe2rieVPSEg0SVYDPCqIyosexkVHdCbTw69jncE7dTEf6Slxb NTaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708559405; x=1709164205; 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=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; b=glN/j6rgmzPLezkraJkl6YPtVeuk603d4wL69smOCMZARXUrRnoIwjrRTmgPtAO625 0FDX62A8J4mqBTZPNuCRuhnhAy7wxsrUNH9da7jhGF+C78oXkZiFdXxy5LURlC7rRL86 SsrELBPE8q3C8YLBjOrw7tvFTn1w1Ngon2lupOkYWcm53Ku6aBqf3QmjRafYuOYUJJ3H QGzZEfYonpcXnMC0UMKjynRWqHu2SVtGeZucYsjHrdg3dMVhJq2OfypPrndNHZmleyU4 bqsBUp81OV25hDbjv8Rg1PgpaibeW7qtYPOdR5EmMRTiQm6D/QQXJDl9eZXEJ4e0Mqf7 wBSQ== X-Gm-Message-State: AOJu0YxQDHpQBTVsuyc4Krl5BZxs/0f6ZpESlALZwhHUevfyD1SkC9JX 5enRBdsL3OqzGBNMiSeV2kps0SjkQMPdSlL8LN0gSVsB8sRwYhsM X-Received: by 2002:a17:903:110c:b0:1da:1e60:f9fe with SMTP id n12-20020a170903110c00b001da1e60f9femr22926959plh.54.1708559405036; Wed, 21 Feb 2024 15:50:05 -0800 (PST) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id jx3-20020a170903138300b001d752c4f36asm8657794plb.78.2024.02.21.15.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:04 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev, willy@infradead.org, "Vishal Moola (Oracle)" Subject: [PATCH v2 5/5] hugetlb: Allow faults to be handled under the VMA lock Date: Wed, 21 Feb 2024 15:47:32 -0800 Message-ID: <20240221234732.187629-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221234732.187629-1-vishal.moola@gmail.com> References: <20240221234732.187629-1-vishal.moola@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hugetlb can now safely handle faults under the VMA lock, so allow it to do so. This patch may cause ltp hugemmap10 to "fail". Hugemmap10 tests hugetlb counters, and expects the counters to remain unchanged on failure to handle a fault. In hugetlb_no_page(), vmf_anon_prepare() may bailout with no anon_vma under the VMA lock after allocating a folio for the hugepage. In free_huge_folio(), this folio is completely freed on bailout iff there is a surplus of hugetlb pages. This will remove a folio off the freelist and decrement the number of hugepages while ltp expects these counters to remain unchanged on failure. Originally this could only happen due to OOM failures, but now it may also occur after we allocate a hugetlb folio without a suitable anon_vma under the VMA lock. This should only happen for the first freshly allocated hugepage in this vma. Signed-off-by: Vishal Moola (Oracle) --- mm/hugetlb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ae8c8b3da981..688017ca0cc2 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6354,12 +6354,6 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, */ }; - /* TODO: Handle faults under the VMA lock */ - if (flags & FAULT_FLAG_VMA_LOCK) { - vma_end_read(vma); - return VM_FAULT_RETRY; - } - /* * Serialize hugepage allocation and instantiation, so that we don't * get spurious allocation failures if two CPUs race to instantiate -- 2.43.0