From patchwork Tue Feb 20 23:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13564727 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 F2295C48BC3 for ; Tue, 20 Feb 2024 23:18:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1545B6B0075; Tue, 20 Feb 2024 18:18:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B5D26B0078; Tue, 20 Feb 2024 18:18:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E96C86B007B; Tue, 20 Feb 2024 18:18:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D3EDE6B0075 for ; Tue, 20 Feb 2024 18:18:00 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 970B914081F for ; Tue, 20 Feb 2024 23:18:00 +0000 (UTC) X-FDA: 81813747120.16.731C5C0 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf28.hostedemail.com (Postfix) with ESMTP id CE355C0002 for ; Tue, 20 Feb 2024 23:17:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B7QicXKL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 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=1708471078; 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=WrT4PFTPEBdVnQtB3JqEnMTnzuYVsnDN94ufDiP3ix8=; b=cZkw1SYnhvKhCQJDXaFpgMg6yO5TOTaRTDdsQA8vAKcO62MoWpWnJYZPhdTABaulu32xga zl834YncifgnISie0ddJ6NW0NkC/vlKdaJ5fBYqqCzzXeHzsVSsJE84z5NO0sU5TWcs4uo 170G9AJBCIahlJWZQAViErJfNMPcQC0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B7QicXKL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708471078; a=rsa-sha256; cv=none; b=DgYRI6WlODKJbNZVsepRnF40Kmst2xcYe1PS/xe8M7gq2SiBXpKHheN/o4+6Bao2J+cVrv NmT/73VlPTKRpnq8Ov9GIcdVHzMCzW6wnOPPMABk6ZNP6bFrSzdpdu3TB963p/T4TVdJHQ +OznxZA1dpeAXEdtZmdbLEmsf75Ke1o= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e46b5e7c43so1375866b3a.2 for ; Tue, 20 Feb 2024 15:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708471077; x=1709075877; 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=WrT4PFTPEBdVnQtB3JqEnMTnzuYVsnDN94ufDiP3ix8=; b=B7QicXKL1Nr/VHUpwHqnJKcBxcpN4eiLq3RU3ZzkaZGXAXgw3IpIkEt214sdGLS1Cu QpAMqtFVM1IWvExbb34Ugk6Y9sfFbd8hwNGTNTKDWXNRckLTL95TGQ3UmgZXE6sS4k6Y 4IkxoYPjkQMlRcLCi3gN2JAFGq+Piffk4PHWuY78C2zD+Zt9iAwsvkt2vEpORCUTO4Xd lcYQkAjA3/s4gzLR4gjbvDwJplSkmnZweU07ayXnMXQqqX+9BKmQJrxNL6GVQxRc1sDC hhWggmAQjtIr/AFPe2elEnUG4I/cvo6u/7/bC/xLKuWrs542Avl9uW1/cHWUjA80M0Se ux1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708471077; x=1709075877; 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=WrT4PFTPEBdVnQtB3JqEnMTnzuYVsnDN94ufDiP3ix8=; b=gMVgjvKPTMXSUBZCkJzv2/tofwbBPtW8eYYirb51vvaFJ62tFuL5nBhNCGUXprqhPJ d+u0K4yTuoMrE1C7PpFyAOeK7nUPxZikKESQ5pDvtJRsf+SaAisAmNtWX4CZbck4ZJWv fUJqcoiL06zcTreuc908AaNMns/iCesG77B/QH3KKeoqTGKo/u5h+BEHEEAmOcHTRpe+ rJhr/fRgPkorjAjTwuV+tRKqzr/KLyOdndmiYA8aof0Dqp6cujrW8rQt92LR0yDpvlp8 h3LoNx0Eqw17Ghm5Uo4m7Drm5nynt0sqSMUAGdJIBxFbNuUnxq2x0bbGX63VG6czVcor 0Afw== X-Gm-Message-State: AOJu0YxKDVIsLN6wHfw1IERO7dxhqvc38TEBmvtMlfrOet70JAaN6AUt 1lbNl0rkGzYZg4M1oZHQgasky+NjoYJWHC4EmubB0tCEJXV2QyMdMBPyakk8 X-Google-Smtp-Source: AGHT+IFKKyG86+3BcYGfCtYk4B+BIzlGb+TUrCSTONtmVN/+s7J3gVwj8UxkSRj+/w/58I5OyBVGAw== X-Received: by 2002:a05:6a21:6315:b0:1a0:785c:58c2 with SMTP id wu21-20020a056a21631500b001a0785c58c2mr13278203pzb.61.1708471077457; Tue, 20 Feb 2024 15:17:57 -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 x16-20020aa784d0000000b006e13a5ab1e5sm5317803pfn.73.2024.02.20.15.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 15:17:57 -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, "Vishal Moola (Oracle)" Subject: [PATCH 3/3] hugetlb: Allow faults to be handled under the VMA lock Date: Tue, 20 Feb 2024 15:14:24 -0800 Message-ID: <20240220231424.126600-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220231424.126600-1-vishal.moola@gmail.com> References: <20240220231424.126600-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CE355C0002 X-Stat-Signature: 87x5axw89ijngo3tkhh5kn99ppr9dnzi X-Rspam-User: X-HE-Tag: 1708471078-474904 X-HE-Meta: U2FsdGVkX1+NLgw9HZ6OTJZAlkz3NVQHR8zKEKDDgAfQfJq4UYGlRHFQ9Yhu42MEKBvxzcnqcvZJxsIXiSzCZI/zGdfr70CgENY/cXJ9YvC5b+WP5GC3pR/OesXxtXCARqgGPXSqbJ0Ym9N6kR8Sop2o8AGlzp2sVPy9bGr5KrkrVkQhTu/whg5FplS/wto0Nfd8C06E6inEgxpupFnW6hG1Hl59x94261SlidXaH5TFE3tpMvjv2TS34b+/1JoSDwlA3gahGxC3prQ5ZXdoF9DBKqRpG0+W59RWZHntPF2MdLRt3rVcbCo/J2E4+0wRDMWrqAhGwf+bj6dn1/XA0G+tjQYHolVKumBSm6gkVJ5EJEN7g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IaHMyMDDseh9eZfXa8W3uxqXs0bj9B4LNKRjjmeOOm/5Wc/gVr2Mx3UJlBp0K5v0DNnEufc6NBzcfgDdBakPFd4VE6cvBdNAWH8ORkmI 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) --- mm/hugetlb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 10f57306e1f0..ed472510699d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6376,12 +6376,6 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, int need_wait_lock = 0; unsigned long haddr = address & huge_page_mask(h); - /* 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