From patchwork Wed Feb 21 23:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13566622 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 3DD93C48BF6 for ; Wed, 21 Feb 2024 23:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E85B16B0081; Wed, 21 Feb 2024 18:50:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0E066B0082; Wed, 21 Feb 2024 18:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5F636B0083; Wed, 21 Feb 2024 18:50:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A6C086B0081 for ; Wed, 21 Feb 2024 18:50:08 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 424671A0BDC for ; Wed, 21 Feb 2024 23:50:08 +0000 (UTC) X-FDA: 81817456896.04.E088227 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf06.hostedemail.com (Postfix) with ESMTP id 6109A18001B for ; Wed, 21 Feb 2024 23:50:06 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X1fsrBxx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708559406; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; b=R0IjEY0NF0z++CLRdf975VGhzntdlkblG3U980MDl+9/PZinJ5ESTjkni0foywGhOTE6Wp WZM2wZfjMuG1nvSIVmi3qxiMoUN46kGWCSicOihnQrSAMfafoMzbkA/EgNw4Wkf6dAYDjE Iy2UHOW7XGHYWuum8disRFkATOZNz5w= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X1fsrBxx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708559406; a=rsa-sha256; cv=none; b=JOtXK4nQzUmBYKQg1sJae3eYEPOwFlkH005Oz0KEzN3/1OJk69zuWm3Vdz1QXmUiZ+FMNV Wm1qwGN9W/LWyF6YjL7kuRMSSo/ANcyFbfK+7TiTFpodapl7uYftRFUTpMYCzWBF8sOfXU R9lJ1dQZKdOK/X/vUIBo9fyIuG73y9o= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d953fa3286so49619435ad.2 for ; Wed, 21 Feb 2024 15:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559405; x=1709164205; darn=kvack.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=X1fsrBxxdZv/yESUMKAK4BzwOePAW65yxmwMjhRQce6RPPP4rUr2rJIapi5aGKjH0v AaTKGsYvGCrQQWFoCs33Sp0X7syRDu/Rsj/t358Cxhzvo0dy/FgxFUizW8o4F76g/2yZ 2Vb/nxxMFe7s7UVHSoF20SM4ogkIoxt+IGXk9LGsn53+BYCS1lGQ/Dgx2EnipV8YpGmI nAPwGEIjvGJBXujFiMqemyeN5Nfp7gjZPCBwiu567ycKgV55ucVU749TQSeqApr92Hw+ RFqNiGQBqDeg3UZ1hg4h2g5TNoIDO8nk8DEMJXICcBaqEwHbXnzsgg+LZroFL2SNer9l UJKg== 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=t9Z2HJkKkr4H1YpGzVRiB98bUfl3Ec3En6SP2XNR7F6lXy4/QSYoqEo7IDqlpWEQZH byS9vJ8zpFgg7nONKgjck9UyBNdaTCmCWx1cV2jmsG5hCUplxmXCs5+deL0b2Xilzgo+ EKnEwY8Qpo1sdTvS0yhMEMSeViQ1exc9d7BNSsxB2ogQvAQd0kBXKjU7OyCZe3xgGTHJ 5uPhWlucl4jnIOFiR6ds6j0fEtz0R7E2fVc2vKSnRIPezY7PYdi3fwlKWHv1Oq4zyN9e 19qfH+kHqIZ2+QS8j4vlktcYaPKJbZfuxPiAe2mWfE+ynZh7F1SlaTFVKt7usfupMrA7 6oYw== X-Gm-Message-State: AOJu0YzqDhpItHy1ydlTU+QnSx4iAuZ7rMeUBc8Kcxeq5mZTzzOy7HUS irJv+iBZRKGS7x8ws8qUFGa971SDJASGADrx3f1hPe39XLxk0vZLtpT9nI5v X-Google-Smtp-Source: AGHT+IFFqAzicIYgkaaVMs06g/rAMIBEgY7J+qJJESuWeEScuRMjcUmETWIKG0itACQICVY/8H3/VQ== 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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6109A18001B X-Stat-Signature: 56weuzchkmkp31z8ri45eij56sei4ic4 X-HE-Tag: 1708559406-361046 X-HE-Meta: U2FsdGVkX1+puEoJlfQtUDun78tLfb8anQyibm3oRXccbei4Rt9ofTfZ9AArcHofy1v7M+RuBDbvQhCs9tnuFvuimr7o0JfsRpHDF9v2+PNj/AqRURoVt5MKn7QTMMi4IB9KkXT19mT9ASJUAPVhhnNC0blzzSoCY/ON4yMw0C8Tkc9SLTDpb2APQ7nzGLXikrqDuPmBKBVOaM6SyrvTMbD8s2PQg5Nj9SYo8hoUkrsqRfeuFxvAT/YRbKNSV6w32820vj2LKNaHXCPRXH/kpwdRocHeoKFwHQl8ndgTk6W7bH3RPKqE/bfLiZPukgkomogrvdqHnA/DWFMzzMO3BO4R7AuEQX8OVWJKCDGtAXEUj+daMj+QvCEC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aFleDNn+8Tu0Vu2YwZTxOvY37d/Z4b42V/Fq1gboPnT1KhuwOol32A5cbS0rrDQ55mtr3sTQCpIKDK2K6QlxgbDTEPvU 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: 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) Reviewed-by: Matthew Wilcox (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