From patchwork Tue Feb 20 23:14:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13564725 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 CB173C48BC4 for ; Tue, 20 Feb 2024 23:18:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 375476B0074; Tue, 20 Feb 2024 18:17:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 338546B0072; Tue, 20 Feb 2024 18:17:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ECB86B0074; Tue, 20 Feb 2024 18:17:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 12F216B0071 for ; Tue, 20 Feb 2024 18:17:59 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E2A474060A for ; Tue, 20 Feb 2024 23:17:58 +0000 (UTC) X-FDA: 81813747036.01.6851941 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf15.hostedemail.com (Postfix) with ESMTP id 45A9AA0012 for ; Tue, 20 Feb 2024 23:17:57 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WzyGwoOC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.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=1708471077; 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=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; b=3/xJbHLM/4pJwMvNxx/nqwGZO3UPjVCcvPG1ZFwwKj/5eKiuzijMMoRx9YwreRrJPyd3e3 qRdj/86/pdYcpb5tkC8p8Q840EHjfon6oXNNg3rZz4gP72jlyvZqQ8Q6Zb5EJBvI540+Fn vjC4+pYMc1DNKUbur396NeSb3p+t92Y= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WzyGwoOC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708471077; a=rsa-sha256; cv=none; b=kIWKJtbiYr7/nz9nHl5W9OsiiiQT4C7MulTnyixkR0eiZQgByi0bPf2YmrcKd6WKHyY8lE fiEjB7ykeDETYSffGtXz0Q59/0zcPdNwx10MR/cJj9NKYzFQgWtsKz1D5x7oNP/c8btbRx y9OxdDpxuaWoulKJvCC7v9xHJjiMJ5s= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e3ffafa708so3026876b3a.1 for ; Tue, 20 Feb 2024 15:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708471076; x=1709075876; 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=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; b=WzyGwoOC4xNb86CuU7m+ZRY0HaysQ1ifukEQ/d4FOob+d+L7xF6PhGVBJ0fLPN1UsG Gy6VX2aBXCBt1dWLGyw/1vg4Qg2QlBZVj9FB1O0iL5lGJPIlGyWKhiT9BL2Cf3ATl5m9 BM9e7z85066SiC+FpXRv+kNVMlL5piq/Igt+raJ1rIN8VxqGnj4EUWvJpYPaGfRQGgxB 1iOJSUCyWt99DxlIHSCT1km9dfYJ+KmWXm5Q+ZbaNlalh9MvMgDwey6hEkfT3H3KDkdm S33qmJ4Y+G7FRsB86DhXMxXOIfJ27jbopGZQMWw/kh6WxmnjYUIRrd8Hhgo85R/cLu8w /fMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708471076; x=1709075876; 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=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; b=htXC3aJ9iRdet71nhbusdx7gh3jhLTnNH3U532cQJrPURGatP46H2fXcFC1fhILmrC xu2O1VStb1toDSKlllOZ3cKjg0QUOHCWc5LzC+hClgT7CM87SrJHRD4T7SFC0F6/i+6v w3tQkZak+PU4kINy9JCy3hT4FOW6oRgwUXtzPJfH2pydE5FNSrXFw1cDVZGbdGL90pdO D4cfzzNfEXoFhuScqnG7nfAjVja6QyhmrGaiWMUrj8cWzKaeYnRbH5wyuQD9wPnzXFsG t/+89ec/bqxysAs44ocZCizce7iKgTP+Ae1lsZTGCvQnk6/XeVBb8aGnK4Va2zRBq9i1 tDgA== X-Gm-Message-State: AOJu0YwJsxy9ZmmuR9hlcu4snpiDitHORnZV2m2ewt5wOtA5wMhHvcqS zc4dXPJbSGN2TYQGijdse6p2yRzYQwzc+E/Dr62dpkLXMhSs0u/G+E3K8++R X-Google-Smtp-Source: AGHT+IFeVa9iBxvsSpbEiIeYAtJicngo1Z4fESwQ2XBwkVGNXaE9jzVuGxav+9PKFoCevZ1IULDQ/Q== X-Received: by 2002:a62:c312:0:b0:6e1:338d:e01c with SMTP id v18-20020a62c312000000b006e1338de01cmr13801818pfg.1.1708471075876; Tue, 20 Feb 2024 15:17:55 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 15:17:55 -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 1/3] mm/memory: Change vmf_anon_prepare() to be non-static Date: Tue, 20 Feb 2024 15:14:22 -0800 Message-ID: <20240220231424.126600-2-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 45A9AA0012 X-Stat-Signature: c6h3wf1qgxhpfcqit667ns6uhkxjstrd X-HE-Tag: 1708471077-511633 X-HE-Meta: U2FsdGVkX1/xjhZnf8h8tB/BZEBw3Ykq9OB4uX/h/DqnaxOkUFPoDGIuzBZ4aL/WZppVxhbF5sDKvJikjc7RxGSpPATL4ZnqTJhTQBg8elujoI0W6czXN2apA55z5b14e0ECEuv/vUm8JShbV78GxZmmdJ+WUODmfPc4vx6q2EqATn86UnuK2xHcMOfTNEQBFKM7OIRipovECSfk3FY9328lJz/fzBaunrow7YCyHvigSsN7Ik94Jw1lFTlZ2BHVKl0ojMZ3L6XCk2Q2aifuAE6bjYxRYHavj1CBmcpTSrVFBlgIpChrkGeJiQhYl2ie6hOStgnTL2/b0h5hc8yQSwZUfoQC1v3Q11KCABQBKH2NvbhBcip4lgje30lJYSx1stxSN+ljpW+epgGxmBr9j0PQvuy6PSyZBYmFuVd/33XAcA1vYD7SzkCXHn7DS+ZRwIcN8UUoH4nE95I53lK3t7MsZejJLAThsnqrJwf7VtFoE/xzlGX38B+b5QJY7Kcw3U3nQA0TjVIPe5XBo+ws7+uJ60UEzXFcRQSk9sXr56i9F+zw6lnttR85pp4NXP2LODRvHFdo0a2ETBwJpgok+erWhgTddMSuZXUy11JdI0wOY/FUnjiPubqRk2G3RR++kdE9++AKvAAZQSA1mEr+QlAYAXyjy1w8xWT7XErfMUQjSKoqkCvNdDVEgedybNPZri6GtPduS5BBeP6TgXJM1BswVE6/4UoNL27qBQ2AQXA35T7pGN6uhPwWO4b2fAznGElIXDnUGtNTtG1pSuhv78euzOFaR+sk0Z+JuFrN5oQ8SfCZP3rTqXNKlpNqEm7pRqMp7R77ZATZAPCjh3uzT/Q0OSO9TpzJkZfeLgI/IfGR7p1j9EA050VPlSirM4o0h5Czu/fyy5vxyqJmzKATvqtjryxBns4e4mO893FlAR32QwNTlR1JVTwRsgyp8nn58Hs4N7Z3X9sstOmgFBr wZuILBfo J54sdv+/HFWhhC/UYMD547rrxu6hWmNEnzCgwQ7zMPRSqc/ro7w1eOm6mqoXEnbRHdCbdYLHSH7/sCSEPlgBOk+8t4apb9RxdwEn7QXzg3Z9z1HnZAxHnVl0WaLWCUt0SKxtwhvw7j8CZOb4SVfD3pwz4JE2pFlMpytnC+bqP39eU5HiEhYeEvtDwm3TXYa597tib0HeWYZgR4wW1wsuGKw3o/EBoqMWBlV4gGjOnH55hk4fvjFRRKVeNElkaJ1QfAL/31zwSWUeDiJI= 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: In order to handle hugetlb faults under the VMA lock, hugetlb can use vmf_anon_prepare() to ensure we can safely prepare an anon_vma. Change it to be a non-static function so it can be used within hugetlb as well. Signed-off-by: Vishal Moola (Oracle) --- include/linux/hugetlb.h | 1 + mm/memory.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index c1ee640d87b1..9b45edb6e303 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -272,6 +272,7 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); int hugetlb_vma_trylock_write(struct vm_area_struct *vma); void hugetlb_vma_assert_locked(struct vm_area_struct *vma); void hugetlb_vma_lock_release(struct kref *kref); +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf); int pmd_huge(pmd_t pmd); int pud_huge(pud_t pud); diff --git a/mm/memory.c b/mm/memory.c index 89bcae0b224d..c93b058adfb2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3081,7 +3081,7 @@ static inline vm_fault_t vmf_can_call_fault(const struct vm_fault *vmf) return VM_FAULT_RETRY; } -static vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; From patchwork Tue Feb 20 23:14:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13564726 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 16C23C48BC3 for ; Tue, 20 Feb 2024 23:18:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 376036B0071; Tue, 20 Feb 2024 18:18:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 326406B0072; Tue, 20 Feb 2024 18:18:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ED876B0075; Tue, 20 Feb 2024 18:18:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 127006B0071 for ; Tue, 20 Feb 2024 18:18:00 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CDB24C079D for ; Tue, 20 Feb 2024 23:17:59 +0000 (UTC) X-FDA: 81813747078.20.7F0471C Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf08.hostedemail.com (Postfix) with ESMTP id 0A5B816000B for ; Tue, 20 Feb 2024 23:17:57 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QWqUXPM3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.180 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=aW/E5QzrtW5KWaWO1KQggPctJlLZibTAzJ7k8sLAf4k=; b=DL3Y7HVAudwjKpr5OtWsMDYTtqnts/PBvt/z5eHDFWoR9hX5qYuozA1ph/5z868JCFLw/N n7U/Np6qkvCAt2UqYrWRNLOZNsbc2l/4vp65EiSt5opWUYt4pPbApArkeF/doMvIuJWzD6 aBbrhQT5Y5afgzeeyZcbl51Fc3lVfVs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QWqUXPM3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.180 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=T9P4Bh7u+MRAhax6BuUeKsLdefClRxxAbFq1fsUOUBierGoFG0AM5KDxNXRr7/ZozsQDv5 mfHOQVlczTbV5oZKM4oLRRv8HHPo6xTn/vpHLfpy7byi8ILrl+J1wga4td+IxjoXzDuRsr EQKhtTosBLBHiu+Nqtv/ECutUIU0Ccw= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e457fab0e2so1536512b3a.0 for ; Tue, 20 Feb 2024 15:17:57 -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=aW/E5QzrtW5KWaWO1KQggPctJlLZibTAzJ7k8sLAf4k=; b=QWqUXPM3DLwhmaK5IDfCej8+FiZtoG9i+QxqfxuttfS/WJfKvDFcXslboGDg1v7QzX YZ4hhj3BbDbyXL0bzriCLsADZAG8hNSGDqdsKBF1P5EMAAfde7EXfcMnSP82bi7C0/zA KSFOYFw6iyxFxYcBaNmSseL9vstGOZVH5jiO0KXZI2dWAEeSFSxZe6XP1WH+sMv39KnH 8L8tOv6lMSYVo8L8gkyWHVLProT/7o8Wcf22zW91KGdMSTTRMCl0qzHEZDIPWzIRZBus NHKtf+/lD9rzaUuD0MMgfMoHT/iqKWG8k3eRapybCqco1c6N36HwPgUh5wVedH4Dk1Ob jUyg== 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=aW/E5QzrtW5KWaWO1KQggPctJlLZibTAzJ7k8sLAf4k=; b=ANFjeAZosZZBDL0koliooDonjwRVhjl4GQ2SDNAwb4HdOJ/RHjFI/H3P2wk+yNZRF+ Hzjg4GE8ZDuYrZpHEWgrWLqt/PBbk8fDlT/fqG9+BDB4hcgNjUmSZY2fMbxDr82rSBXs FfWS0gUU77SWWmCm1uXK+UpgOqeE8e8A7B2jqCburGExkM2EWr/ZuH+4coa1gHhVSpaW E2qfx/MJVDO+jYPjJISYS1NRly5upOrWlKUXAjumYhe3LSs4oXRttDCsI4eHxEypeWbm /cz4GkPn4WFq4pwXyFz30EzaX4MdXPQzQpLIq3iHdE9ZfPR1FuAVpNGTdtzkGroCznNW tlHQ== X-Gm-Message-State: AOJu0YwMGr/CxXAxXtwXFtwI4bPTuuJTjRsU9JXppTk8oFT9VL48Xxbb E6QUfBlbQ3r3NdesqiKBoAr/pl36oXxA0SyWPFEcCNGBRHAPADUgV4re7joT X-Google-Smtp-Source: AGHT+IFPXuxHXTsoKb+rhglPR7fJPhGLbyzZMpYsYJF/K2X4fA7iFxHEPv599+mEA0511+dKVVlSEA== X-Received: by 2002:a05:6a00:4c98:b0:6e4:66a5:2870 with SMTP id eb24-20020a056a004c9800b006e466a52870mr7967423pfb.8.1708471076681; Tue, 20 Feb 2024 15:17:56 -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:56 -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 2/3] hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare() Date: Tue, 20 Feb 2024 15:14:23 -0800 Message-ID: <20240220231424.126600-3-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: 0A5B816000B X-Stat-Signature: mn53qrt46i35zxxkq4u9gnz7jkae7a5k X-Rspam-User: X-HE-Tag: 1708471077-471125 X-HE-Meta: U2FsdGVkX1+Jhp20kNet7L78ilu2okqM9MKZNqFACCxJmJ3x56lvTaqAiok/6JjifhMtYf5bxcfD8W0/IXU85RhGHrb5ymq3e1LFUSjO0DLIiZC1jibMYyJGzOSGDxU5fYJ7Hp8SV/BjjmlLg4KI/Z2Q7T57di/cB8k7ry9gSmtCD/rRRQav2DXV4+FWXbUunVI64Hbxh6x1lCrkAX922RRaLKP5q4KXPMeLYrVdpyq8I8MOmyPGdQeehWkYhuNxOQ8xwtC1m06rD2xo8DDi2SSZ9Vfsc0ZLAf/juK/CIIchIUzSlGGSxDbYPOFa+JMA9JlWb0FTeIgs5EIrD4MfLOnXDLImgAdqu+DOG8Zx0bw4ZKGBMbEnn0f7nYEz7JTxTBW9T4MXg11kur4bbAa/DtnfOM4Z/1WIFg6C4NYHLguHs0sVGqTaUKHm5ou2JccWmBx0MfGMEt+4Pmv0kPVdry8WMCVLy9WPEBHzgK9QjyAUNASFg+we7i2UB9DWxLmN8hlcrJQ8ycr1S1UnyH5+xpAU13DUDPT8c/Y71rbEtlIt2y+XlTNa3l28cATF8TO0UoyeTMg4jex+6BHkqQ1cnRN/3/EER8WEH69tH0MjBa+s26nTNI2+dE46PZF/ICEiW3pdYhA7qX1ng1XRscpfM07ipENAg13o1cFrVEgSH/IcqaVqszVQ7RJiDLkU9wn6ocCfjfUctPRtDYgiCU0mE68gTOemItpQNzHRHwFDaWwnDfnddTlDpPNUBTSNvVer39THIWSt2ijobvxu78fE+lQxF0NdMs2Vg6yO9vN3yQjwLNMyhf94awkolOzLh275LEv6/NTvfjZ0AYVrmOCoOPk9X7cOEm7k4FsOTOh/OVPw/K6N4i0WTtTEVKPmk21LVO/4YseUELW8JZyDwLGdZ1e2Yf/2P4CGdJFNgJBj3NV1C68nkmAImuLJuOGfqP3e4hr32ydtaOsG68XGytx LB47/nwl +HB7/CUsrqeb/EFaUjbCKhCjumO5xVQWPgGvYdNG/TqhOvl+1v0bxuPvGzEkiEQFPmt1gegqMndY2L3ncKTgjot/8BeAhHjkspTUuVMdv+mpeOZy+LosDUZjOLVuL8/ojvfrwclSRqxLQ0SBPtA0OICqLqMmCgJXuf/FsRjWbphKokHx+txzcDDy3nVCNwdVzfHaO7KDxh5QC2R0pbqNmaQUnThsSSXV92oABcM1C0P5aRQv53+qdkTzEQ/RrJCxMGDR6eS1cASD2I7gDmCVbu2LvR7qe9PL9X4sf/0mpFLfWwqJkBltjWq8la9NK3jPSjRKOWMPdR+4XV/sQGhrMHRhrKWDGZSW4xCAIPMj9KkkynW8oCjJg3s4Cqgr+jcCdTNzUMdGfFB44OR6QewttsIgeHLtG0CPh1thq91pega3ujX521PGL/MCnBKQgAbTqFtPCWNXpy+XmB30ZO8Uug1OvA7IEIkOx8WBUqHXAGOAVFpQCes2DFjc3++baAjVH8yPg7cqCKK4L3kQg4F13mgpuRMHj8QWj5jsZ4Io6WT+MJd4j0WXN6Vw3H+QTa+JnCWBV2UUud1RYKNo9XwQttPPpZw== 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_no_page() and hugetlb_wp() call anon_vma_prepare(). In preparation for hugetlb to safely handle faults under the VMA lock, use vmf_anon_prepare() here instead. Additionally, define a struct vm_fault at the top of each function. These can later be used to convert hugetlb to use struct vm_fault - similar to mm/memory. Signed-off-by: Vishal Moola (Oracle) --- mm/hugetlb.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ed1581b670d4..10f57306e1f0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5834,9 +5834,15 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, struct folio *old_folio; struct folio *new_folio; int outside_reserve = 0; - vm_fault_t ret = 0; + vm_fault_t ret = 0, anon_ret = 0; unsigned long haddr = address & huge_page_mask(h); struct mmu_notifier_range range; + struct vm_fault vmf = { + .vma = vma, + .address = haddr, + .real_address = address, + .flags = flags, + }; /* * Never handle CoW for uffd-wp protected pages. It should be only @@ -5960,8 +5966,9 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, * When the original hugepage is shared one, it does not have * anon_vma prepared. */ - if (unlikely(anon_vma_prepare(vma))) { - ret = VM_FAULT_OOM; + anon_ret = vmf_anon_prepare(&vmf); + if (unlikely(anon_ret)) { + ret = anon_ret; goto out_release_all; } @@ -6119,7 +6126,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, pte_t old_pte, unsigned int flags) { struct hstate *h = hstate_vma(vma); - vm_fault_t ret = VM_FAULT_SIGBUS; + vm_fault_t ret = VM_FAULT_SIGBUS, anon_ret = 0; int anon_rmap = 0; unsigned long size; struct folio *folio; @@ -6128,6 +6135,12 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, unsigned long haddr = address & huge_page_mask(h); bool new_folio, new_pagecache_folio = false; u32 hash = hugetlb_fault_mutex_hash(mapping, idx); + struct vm_fault vmf = { + .vma = vma, + .address = haddr, + .real_address = address, + .flags = flags, + }; /* * Currently, we are forced to kill the process in the event the @@ -6221,8 +6234,10 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, new_pagecache_folio = true; } else { folio_lock(folio); - if (unlikely(anon_vma_prepare(vma))) { - ret = VM_FAULT_OOM; + + anon_ret = vmf_anon_prepare(&vmf); + if (unlikely(anon_ret)) { + ret = anon_ret; goto backout_unlocked; } anon_rmap = 1; 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+tjQYHolVKumBSm6gkVJ5EJEN7gzQN1SLyHy2pVeHy3LtM5O3IvO9GgYMMIcM/LrqYjyzOdPf3/6qbmi4HqunnoBgtwjbaQegA8vlMBfRKfH1wIbrfcVWEqPCa9H0iW+T54Z90kzHmE5H6BAHSnKJRgVy+c5wLM0L3jY7sijCItWbjPEPN/vZNtP/4ZEGTYwx+tudXT4O5etupep6/uhgGTGyfHlkc1ZSsTEMNQNlK0EmweXu4ZHV9O4io4CTLfjiEBkBOK7H4bbo9IdQ/2v5uveLALCFl1HyoXgLc577aTh2W15i40JLa1ju26xfXbWvzEIXTHa2HO6WQ4n63uqwS1LHFiN32LcMmA/XDxoSU7cYHrtirnWwxB7ouk50JQf/uCIGm1IwfmqbYRoXsLsKLGfvVOW4AKKkIm8PLQd6CcSfCPVyFSwLqAPGsviuWqIZ9pWOfk/okq6C5oLZGpGXR0THmA6AGB7QvYzODMBZ3/7GWf19sfWTH5BAyElhIBN1T0kND+/VEgMtpckNHyAtwHs2vnT35PkVJt15jhMzGiAfmPFiuvo5GvjGLNBWKQLd/qPmkXqvY6qRKX660uKSlRXPGCtDni+Z29aqHD+JKlX4Y6e+dsODW3VVeTUo zJTpBtQl Xd23Mg4IbRnvW0Znn7uAgkUj64KJa6rlqPZxWGDW2QVKbBvqcdgMVuOH/xG1b5/WL5sU6YUn+/zlGlUpWpr7W7gVBumvnMR/So2B9o0sEgpq78FwRyQ1SVtO1dav7KzIVYIUhWGq6QpCcDKGV3gg5ijiWlISei3LFmqLLkJvxDPvMK/Nqk8Uob9zgRkMqsMBHYEsZOdQnlc5PckLJ4ee4KMKJpiyDXj7n4u1CytMVXgTnYK789KJyHobPfFnuVv/sa6Xr/6zYa6jcZudjIGMQd33QZ8eUMsRIMyH6FOZZ+OrcCUpl6VIO7Gl5Oj9oyb+M+N+Sa12dABLetsqZmthoNGPP+7wbEflouCZxNkpe3nORJ1W/cm3MIFzpZz286Ez5OZCNGqtFv97PpGLMlHw8qCDIxn+YT5Iv0kFTaYuOGdDvvbaTvrjk4XgHo41ZIaHMyMDDseh9eZfXa8W3uxqXs0bj9B4LNKRjjmeOOm/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