From patchwork Wed Feb 21 23:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13566618 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 86C9EC48BEB for ; Wed, 21 Feb 2024 23:50:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1150B6B0075; Wed, 21 Feb 2024 18:50:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09DE96B0078; Wed, 21 Feb 2024 18:50:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E31EA6B007B; Wed, 21 Feb 2024 18:50:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C395F6B0075 for ; Wed, 21 Feb 2024 18:50:03 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F9CFA107F for ; Wed, 21 Feb 2024 23:50:03 +0000 (UTC) X-FDA: 81817456686.02.827FB7A Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf17.hostedemail.com (Postfix) with ESMTP id A1F1D4000F for ; Wed, 21 Feb 2024 23:50:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YL1KM1FH; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708559400; 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=D9r0dNhUKJEdGKYYdAqMzZgO1joAP6x5GpmEzjGgfls=; b=k32Hr+hTZbOcOZGDjJELMLFLN7wmLVspODT2z8AvEDfRS8HaLqexaNINR1P4CQlO++v+Dx zzFQwqLcX+IJ2hS8XAt8OvTEr0C5JMIVn0PNQhdJ/VXgKwaGIr/ZFWpVTDLVzAeX+6LJio JH8potlP6b4XH9QR3p1BaLw07BQxclY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708559400; a=rsa-sha256; cv=none; b=SiArIDESv0uaxbRNhJ0KtW1MIlvjID2TbxqPu+6RRF8kSVn1xsP5TuPRcknJ9e3EOaFMZu uZ5of9HDlKkwMUbUHl43L5vRDgRaPogsY5uXewS/YVuoeT62cW2ogRgQulvWUZ5cFr8/ih Ue4uUjuE+8QQK6+wIMfOLiuLZP9XHQs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YL1KM1FH; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d746856d85so48084445ad.0 for ; Wed, 21 Feb 2024 15:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559399; x=1709164199; 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=D9r0dNhUKJEdGKYYdAqMzZgO1joAP6x5GpmEzjGgfls=; b=YL1KM1FHnUz7l54X8VjfRBo+3guUChN7M5GjfR/dyaQZLFSa4NiBaOLHUlux9tfbTH O2Gc7UIxAippOZIVqwS/FybcTv6KnSV+15kpIEkuji+/u2hxlWHdDu7vmCQ+S2uG8ri/ Z1h3MBoDyAMswljGTYHKfR2diE1hZVhCOiuGv83ESeXNvRPAqgAgoicRC9NKLLjDjQQU zM0vZQjyu101xX0S5ujeX+V4fBh/HsaRlrBBnxSKs5b8c4hlkahUPF6DSKQLu/ELznCf PrJEh8k9/2oYdWWv7PKGdT2CKfcTW0LOMVHKT3T5UNX/X2k2IS/sLdKUDVbWUcc5URWv mC1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708559399; x=1709164199; 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=D9r0dNhUKJEdGKYYdAqMzZgO1joAP6x5GpmEzjGgfls=; b=v/TUBMkXlvYtIt0uL+O4wmrxYRdAefpDGSCoGfWB9BwMI7qUBNkbLtQoXYTmJQ4Hyj ALhF3QycMSwweMUVevJqVbfLM5uNWCWC0RitrGYksSj+gle+O8pR+CHNIS70oZAOea9w qossDcdJvyIDm9M56gXQnD3QQeoyicb9w5tfoo8YvAxkAPmVF304Ht1LcmPODjvhi4fs yCFUBqgFEQvDEExP0Cg2O3NWdLaOfWmr2w7R6uH+34ZEow1Kp316b/s0rRKBnl5cermX rbTlYKv096/PBB2MV1yFORhZwQlsvRzWWn7rHOcsEI0G08PTQVInFoS2h0J9lpsedsEY egsg== X-Gm-Message-State: AOJu0Ywdbg3xdqfJ8hxhcZAzB2LeeGz3JHu8ZMjrYBvwIl06ElFmZf08 DeufcljLCi0eO1Syeqxwx79YEZwYniNm8cBsQPxYN2whmecFMEKBJAzmlgLC X-Google-Smtp-Source: AGHT+IFr5csdbedkdbc7gfWNEnT4VGUpgBUjTFBU/uVZRy4b5xVJHZlEkUhQBpB/fS9dWQPuHu1AWQ== X-Received: by 2002:a17:902:d4c6:b0:1db:d2f7:68a4 with SMTP id o6-20020a170902d4c600b001dbd2f768a4mr14329598plg.24.1708559399353; Wed, 21 Feb 2024 15:49:59 -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.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:49:58 -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 1/5] mm/memory: Change vmf_anon_prepare() to be non-static Date: Wed, 21 Feb 2024 15:47:28 -0800 Message-ID: <20240221234732.187629-2-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-Rspamd-Queue-Id: A1F1D4000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mgbpfjkps4rzd7kqfy5houfzhhe6r5dj X-HE-Tag: 1708559400-212277 X-HE-Meta: U2FsdGVkX198Hgfh1ZXuovY8ON4yUbF1G/IM6Scvv5ilr1RwXFsbiwP1xLuBfX938PP6QiwStoGlcMKH9J2zp+tlOQTlR2PN4Eycc3gzkBiKcsnJsdU7zdHNRNAEEAkGVCILVgEX3N3QvmjqszOo1SCOMrLKtBxvZmm5/mr2hDwY+4p+HOd/ELJXI10wXRr9/iAroY2J1ml08AiR88zx8a7QhJdmS3uL6sy2aKsq9eY5D7SLyCCQZkAj0uBpoaVn6NIb2BdLuCKyixshc/ejrLsCwrBnHQC2hZpkZRNqw2i/iA4yVhrgdgH8iy6sw/3sPVixICWJJNr4d2m1cLgbf8941pEvM5TknXyCrMfLr2RYIIYZ5h7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qnkUKFhgdwh8XI6qKrv5Fi31iJew8l/nILp0ViWr0pqimHYAWC6F9sERtcNcQq8lVuutEJPkkat0jGWOYAt8zoaeESfOxtlmBLJvm1SPf1jJM0qKZfeUt/bw+GgSMM1ullW2w9z0HQ2RS2b5yw== 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) Reviewed-by: Matthew Wilcox (Oracle) --- mm/internal.h | 1 + mm/memory.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/internal.h b/mm/internal.h index f309a010d50f..b9b6b2bc1663 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -103,6 +103,7 @@ static inline void wake_throttle_isolated(pg_data_t *pgdat) wake_up(wqh); } +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf); vm_fault_t do_swap_page(struct vm_fault *vmf); void folio_rotate_reclaimable(struct folio *folio); bool __folio_end_writeback(struct folio *folio); 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 Wed Feb 21 23:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13566619 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 3C41FC48BF6 for ; Wed, 21 Feb 2024 23:50:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77E046B0078; Wed, 21 Feb 2024 18:50:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 705B46B007B; Wed, 21 Feb 2024 18:50:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 531F26B007E; Wed, 21 Feb 2024 18:50:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 353F16B007B for ; Wed, 21 Feb 2024 18:50:04 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 074E7120C3E for ; Wed, 21 Feb 2024 23:50:03 +0000 (UTC) X-FDA: 81817456728.20.39D4D51 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf01.hostedemail.com (Postfix) with ESMTP id 051FF40011 for ; Wed, 21 Feb 2024 23:50:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Thma0WNF; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708559402; 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=+yscKp0AJANlReZg8MRza2RJbrRIz7yBwKbuUCOLUH8=; b=N8s0cVh4DiSm8NJ4UJFj8RWFjyOPqKhjyw2ESjY6gomn4XcU9bCmc+By1em32EYRwKYMrm 7Fef8xj7P8c9Tq5cgY6TYRP79ezz6XQLDoPga+bdBSyjVmKluPXcD0UcQWjRm0tZ0YQHdz EKmn+JNNqFT7cZz2fO64QQIze+vLE+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708559402; a=rsa-sha256; cv=none; b=qLLIqnNY8d/dH2Y4ATYgYwV2L6AMRsTOPIZNb5XgXycVR0eu8S1OMu4ByPP8ICWvM/N+md iLERe4s/ZgxYg4oRr378IFfjSE6BrYA2NSvhnRA0bv9ohEDblQzc/86rls/W49HdzYxhcz Hz0j9z8a2P+LOwE+MThXYjR93JYdKPk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Thma0WNF; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1dc29f1956cso9383825ad.0 for ; Wed, 21 Feb 2024 15:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559400; x=1709164200; 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=+yscKp0AJANlReZg8MRza2RJbrRIz7yBwKbuUCOLUH8=; b=Thma0WNFfmPKu1KXa3AWBQdQ6nhfd3AoqnDA1oH8fWhaz80VVj/jGw+igollwHOyzW PRpcPaVbtwqzJgZSRW3Jx9EMOzLXwMW61Zl3A80ug0BlPqNVM6huWRbZmc5jQ6wrPgOL oqoXz+Fsh2ilNxcm+DzRPgs/fQULJHSOS8lQfb1U8Q2Ub3dk+gYTYJ+vqWJWK1aQSL+o rVMGFwEDyYPgXKGE7SI1mCGwjW79SFAPjLW8pHj36zXa5Y8iFbF4ovTJ/gba6Q55uM33 DCdAqeaIquMGtciJrBos9jX4n+nqB5exheYF32OvwSpWTurAOaOPhkAtSvwlx56DK7IW uYJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708559400; x=1709164200; 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=+yscKp0AJANlReZg8MRza2RJbrRIz7yBwKbuUCOLUH8=; b=NKFf2RI7tGQTLKP0oJ9GeKrlRmZVE7SvNOMVxwhrk9DsS3wRIaJFtxcgs6s0X3Elvz VzXv2+WKb8gLE8fOVOlFXcX8BY+LLTqhMUb4//KtsN5CdniazfSNnTjzO4jpw9Md7X0X fEFOBmE5mq4uZ+5yczBFgy5pQSpLLaLnU+nFk0g5AfzE3oTYOBPI08pon1Lk/LaRnICM Uf7HT+jJYZp0vLvFcE9N+o6PUTyka8oAJvQPx/HrQycAFXWUIbpYR5ifvZUgZTXZyG79 7rt2msEPNWhNP3nRU0ujQESz376/re1nYKPY/qftLv0NO3Lpc8wjGyStTGVJMRx630Rg 0Tjg== X-Gm-Message-State: AOJu0Yx9g2e91ruXJiwVdmq3JHj+h9bXqnRc4zioTU/eVhfcEVnKA5HB 5G3YDxgTLsUxWzK70XVePOrklB0ldw4kbrfQ9iXHB/IsnuwlbiQ2diCc5SLL X-Google-Smtp-Source: AGHT+IFZIf1O6PqXeRikv0kae6U3RFR5jVDKRbX/kRqX+aBw6Rf505v5O+I9/n7itMhFi0AnJq7rXQ== X-Received: by 2002:a17:902:db09:b0:1dc:139:8488 with SMTP id m9-20020a170902db0900b001dc01398488mr10763038plx.5.1708559400552; Wed, 21 Feb 2024 15:50:00 -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.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:49:59 -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 2/5] hugetlb: Move vm_struct declaration to the top of hugetlb_fault() Date: Wed, 21 Feb 2024 15:47:29 -0800 Message-ID: <20240221234732.187629-3-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-Rspamd-Queue-Id: 051FF40011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: unpcztowoi4ci9oh1xo3j9si9psym7ps X-HE-Tag: 1708559401-996607 X-HE-Meta: U2FsdGVkX1+iQRPxoBGy0Nd8z26oSmVuox15QmByLJBDvTdYPo58rykR0o9R4ZNPDUBCEVM1LyQqHQ/0Sxmt29mQeVEQ7Ee5Z9HevQm1syPwy06+zFIBaUaWAOvJ2F0VxPgvtR2CnmDNaDBa3dA8bNw1xkQTnPRu6GfEEDHpZfSgKn2h1ZsvYLa//Ao5JGhKJH11LWWacuOIRq4Dbj9TzguDU8gvJUHs+XKPWUY/M2iqBVN0gkRmDP3QrJx0PlTFe/HJjZz8sSGnLM0DpvLwdqTElzhIS0/4H7++1eJYd4PwC8HV4nq5Km3/74UWYOfnjycXr0Ke2uR2bLyK4KV7vC22IVSEr5AoeBsuPyOfj4WPpqBhpYsEs8DGcYbFvdwKgOVNnPw8G8FyqkoBjfJwxJPabvKzZ9c1ivAu41e37ZZ2+tYiEfJ+itMsQ3/8ED1Dh6tNfJU5PZMzNL79h2/7qE11QlXlEBFr1USOMs54glbUHldBQB8ajAM2Q598GtU2itNrOTMglIJC6jsI+3woh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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_fault() currently defines a vm_struct to pass to the generic handle_userfault() function. We can move this definition to the top of hugetlb_fault() so that it can be used throughout the rest of the hugetlb fault path. This will help cleanup a number of excess variables and function arguments throughout the stack. Also, since vm_fault already has space to store the page offset, use that instead and get rid of idx. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/hugetlb.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ed1581b670d4..d792d60ea16c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6353,13 +6353,25 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, spinlock_t *ptl; vm_fault_t ret; u32 hash; - pgoff_t idx; struct folio *folio = NULL; struct folio *pagecache_folio = NULL; struct hstate *h = hstate_vma(vma); struct address_space *mapping; int need_wait_lock = 0; unsigned long haddr = address & huge_page_mask(h); + struct vm_fault vmf = { + .vma = vma, + .address = haddr, + .real_address = address, + .flags = flags, + .pgoff = vma_hugecache_offset(h, vma, haddr), + /* TODO: Track hugetlb faults using vm_fault */ + + /* + * Some fields may not be initialized, be careful as it may + * be hard to debug if called functions make assumptions + */ + }; /* TODO: Handle faults under the VMA lock */ if (flags & FAULT_FLAG_VMA_LOCK) { @@ -6373,8 +6385,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * the same page in the page cache. */ mapping = vma->vm_file->f_mapping; - idx = vma_hugecache_offset(h, vma, haddr); - hash = hugetlb_fault_mutex_hash(mapping, idx); + hash = hugetlb_fault_mutex_hash(mapping, vmf.pgoff); mutex_lock(&hugetlb_fault_mutex_table[hash]); /* @@ -6408,8 +6419,9 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * hugetlb_no_page will drop vma lock and hugetlb fault * mutex internally, which make us return immediately. */ - return hugetlb_no_page(mm, vma, mapping, idx, address, ptep, - entry, flags); + + return hugetlb_no_page(mm, vma, mapping, vmf.pgoff, address, + ptep, entry, flags); } ret = 0; @@ -6455,7 +6467,8 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, /* Just decrements count, does not deallocate */ vma_end_reservation(h, vma, haddr); - pagecache_folio = filemap_lock_hugetlb_folio(h, mapping, idx); + pagecache_folio = filemap_lock_hugetlb_folio(h, mapping, + vmf.pgoff); if (IS_ERR(pagecache_folio)) pagecache_folio = NULL; } @@ -6470,13 +6483,6 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, if (userfaultfd_wp(vma) && huge_pte_uffd_wp(huge_ptep_get(ptep)) && (flags & FAULT_FLAG_WRITE) && !huge_pte_write(entry)) { if (!userfaultfd_wp_async(vma)) { - struct vm_fault vmf = { - .vma = vma, - .address = haddr, - .real_address = address, - .flags = flags, - }; - spin_unlock(ptl); if (pagecache_folio) { folio_unlock(pagecache_folio); From patchwork Wed Feb 21 23:47:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13566620 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 0EFC1C48BEB for ; Wed, 21 Feb 2024 23:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A15ED6B007B; Wed, 21 Feb 2024 18:50:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 99F626B007E; Wed, 21 Feb 2024 18:50:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A3656B0080; Wed, 21 Feb 2024 18:50:05 -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 57BF26B007B for ; Wed, 21 Feb 2024 18:50:05 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2574F160BC7 for ; Wed, 21 Feb 2024 23:50:05 +0000 (UTC) X-FDA: 81817456770.15.581A8AE Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf13.hostedemail.com (Postfix) with ESMTP id 8BDAF2000E for ; Wed, 21 Feb 2024 23:50:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Uu7lYuJA; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708559403; 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=pW0shPvwYrN8ODFgTcl6EvNguHwyyx6gBjAHCZnk7do=; b=NibZ3uNjJ5wE/YGMn6u4sz3N7GfHfERAXHOPfkjbXsSyN0Jrm6KDBONfdMfLHwmD2iZ6Ht EI1lhhCNqUt6ZatJ+VR71Rea4X85XOyhS23hzmTvPTP04YtONBrfW/HJQsY1zcjmcIgpOu ixombwctV2dY+Cr0xJqpKPP1NlVleUE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708559403; a=rsa-sha256; cv=none; b=3pI1nANM/gJ/fs/cAsnMXfx8cKiagmQ6RLVlfMEs4CPydYmyD2/bit57fpIfbgEwpW4jTs LSh93e6z2f9MZMhj0mjUYghQGQ/d05lkMZR9kj/ktJ0ogWJMgwfCr6E0O4MfkfZDEHlW/n UMLNk3Y2pHbsITHP+7nkK6iKjSIflvI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Uu7lYuJA; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d8da50bffaso37748795ad.2 for ; Wed, 21 Feb 2024 15:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559402; x=1709164202; 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=pW0shPvwYrN8ODFgTcl6EvNguHwyyx6gBjAHCZnk7do=; b=Uu7lYuJAp//G+RZNgLTeNwzE/TYQx278blK4M4rxoU3pGkUTXIvBb2qn7gmFiFgMqR fe2UkrpwItWpgMBOtSFh4xXUSmVUYnA79jfZKgCzLMVU/jmVjG032FL726JCtUKuPklt YB8x74N+zvkx4+7ajNH7TH1h4IcTLqYB8tYWqsgkta2h4cnAs2OaLQ/i11SHipweK6bL aTBIy8BttEvKKUGT/Jt49Eoq2l7BzN+pyWGSs8+pNkvfk31EDRT+qzmkODQ9Ipwg5GUS kzfl/aN5eNq6H3bi1W9pjzE5gtTkoFVPpvSLWRyv9irbiB93PK46fQLHlIxKrxJPiSIN cxfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708559402; x=1709164202; 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=pW0shPvwYrN8ODFgTcl6EvNguHwyyx6gBjAHCZnk7do=; b=r5R3jz8rlFQQauRGEtsGaUIgcuqC0vGZnibhbceNw+eN7da3kOwoN9RP466zVIV1dO d8eLJtZaXFttDGQ2PIv1OWi+BUvgNkBqoFc42ydsqqirg81uFeKa/l9SvZTYrbHpKoH4 CTqmye8DsNC6PVGfmX4gnOtazuA57JVvQXJPGD4xJIxnuU2MCzOYGcFWTKV3vgdR4cC7 6aWpMSMaXkFEMewspD6fi/mbBRIJZudzdishij8243AZ0TMqQ1g/nIunKKcgIu5yNphI logf2EApinxCXyH6i2aablofBDzyEBr8drzZ+unc8cv88QcCDjTcLPaocdTH6fxxc9qk VC+A== X-Gm-Message-State: AOJu0YzL3h46Z3DRxs9q1o6G74Fs7KNBNC9uWT5uxavwlY21a9gPDEwo 9F/1OXHT3sDcPhKlVyEvrr67YhX95QWNXRRCR5GZPTZLM5Q1ULzk3rlgReKK X-Google-Smtp-Source: AGHT+IEkWuA9z9zlwpJbc1Kta19kKpN2tZu6Hibqp8iAOwkmOQwVY84bMgMA2AlZNl8oNprNMtwCsw== X-Received: by 2002:a17:902:ce85:b0:1db:d120:5cda with SMTP id f5-20020a170902ce8500b001dbd1205cdamr14482066plg.11.1708559402026; Wed, 21 Feb 2024 15:50:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:01 -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 3/5] hugetlb: Pass struct vm_fault through to hugetlb_handle_userfault() Date: Wed, 21 Feb 2024 15:47:30 -0800 Message-ID: <20240221234732.187629-4-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-Stat-Signature: npipd7cr7mdrt8xcyecw4qbgh6ogb3pb X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8BDAF2000E X-Rspam-User: X-HE-Tag: 1708559403-155984 X-HE-Meta: U2FsdGVkX18oouAgqBK0qFqYD0jHcy4rU00vFJVETbEZlxwNqSLmk+P1kZ4yE0Fvi9Di0UubDSjbj3v5fxiylaj9lQJcm0/IT9ZpwEhV2PWBtZmEnS8B7MGJzSp4yCU37V9HsbtVmRC4aFZtuZIIbliEzj2BVwd4FhqJSJ/e876q+GVDSWrfxTMhK1AkIlzKMa3bJ+i/p466BIKIN0nOPS5KZW1y6Oo/6OyiUFdaOpwuutvO8srV5Dw0jMRJ0F099Arh4T6enCyljmSEyRzH37f4b71rUg9Bt+65JfnICJM+17mxKHyu2P93/n0cBDSnP238vSojbUci8qoiaGsxubFzll1dsTROk6l+QyGeJeqYdDjcSMAXGEgXLtdcymUJTF/0MMgi/FEt6DbpYmtiADzamV0InoxzUG6HbXPpTAxRYBUUk66NZLKuIwlR7+NOjU1WBSVZQtVV8TFBQ3qKtwZE04OKCbEpNghCisd59ZXp2GmWGZtcOc97fPMW7Mf7az86HrawmvK7nGke8m5MwvLOR2jZI7KLdEhdTkbO+pP7l0gtJzFFL9gVh2HAjeOX4dcc6JKSUqXYjkPmp/eoOxVaw+qGVpu3ktKgUMkqQR2kaLihqc+dgtMatbhSZB5aAdKY8qr76i5XJIdYCnoArYKrC/shjWwc5mbf7qHH30mi3GhCUVelXpH1kESKS01jumE0N/269/JTlg/zJPlV+n6WP5WTuL8XgYeIG6a5jpK8x9hF55G6kNG2JERssQ2DoDJs9R84OXfK1voHTNynqtqz5zBGI2kCiFU3teuAsqeIlSV+mMwHJ/RnxFo8BTU5Tbdb02zCuck3/0J0jcJVzUJeNk39BhLB9Mk8bgGKC3mgcEoWQln+Gobw4ZSNXf0iNlQhqb1T4oD4Gm9ONmXAJVLut+47vzJwi9WgNauxS8mjm2Kt4TQyQT+nlfP5RTKjvX45dX34/fOV7SPeDSr 2koovPbh ZcVWmt2PD7XAcmZ+/Lqodhx1roN/4xZu1gc5bb0XuYZQdLwjFPs+TVn2aRHWpi/Cs6RJnJUfK3R2GFNjwY78abuyAdXUw/RGqDXyfcN55agf7qytvCyWl9/G9vIns8Dn49C84qJ0T4dUATpTzZWY44fsbyg5OgjraIjHv8wFSbMKlTY0fX8F7d0pdXUGtDpdUYsF73CGt59OjCSuTyC0/wEADQD7YFJiz84a95/p0lBUFiUrAhIAh+5TkULbXjNNj2ANJfEYAa5VozKM= 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: Now that hugetlb_fault() has a struct vm_fault, have hugetlb_handle_userfault() use it instead of creating one of its own. This lets us reduce the number of arguments passed to hugetlb_handle_userfault() from 7 to 3, cleaning up the code and stack. Signed-off-by: Vishal Moola (Oracle) --- mm/hugetlb.c | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d792d60ea16c..70c5870e859e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6060,39 +6060,21 @@ int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping return 0; } -static inline vm_fault_t hugetlb_handle_userfault(struct vm_area_struct *vma, +static inline vm_fault_t hugetlb_handle_userfault(struct vm_fault *vmf, struct address_space *mapping, - pgoff_t idx, - unsigned int flags, - unsigned long haddr, - unsigned long addr, unsigned long reason) { u32 hash; - struct vm_fault vmf = { - .vma = vma, - .address = haddr, - .real_address = addr, - .flags = flags, - - /* - * Hard to debug if it ends up being - * used by a callee that assumes - * something about the other - * uninitialized fields... same as in - * memory.c - */ - }; /* * vma_lock and hugetlb_fault_mutex must be dropped before handling * userfault. Also mmap_lock could be dropped due to handling * userfault, any vma operation should be careful from here. */ - hugetlb_vma_unlock_read(vma); - hash = hugetlb_fault_mutex_hash(mapping, idx); + hugetlb_vma_unlock_read(vmf->vma); + hash = hugetlb_fault_mutex_hash(mapping, vmf->pgoff); mutex_unlock(&hugetlb_fault_mutex_table[hash]); - return handle_userfault(&vmf, reason); + return handle_userfault(vmf, reason); } /* @@ -6116,7 +6098,8 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, struct address_space *mapping, pgoff_t idx, unsigned long address, pte_t *ptep, - pte_t old_pte, unsigned int flags) + pte_t old_pte, unsigned int flags, + struct vm_fault *vmf) { struct hstate *h = hstate_vma(vma); vm_fault_t ret = VM_FAULT_SIGBUS; @@ -6175,8 +6158,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, goto out; } - return hugetlb_handle_userfault(vma, mapping, idx, flags, - haddr, address, + return hugetlb_handle_userfault(vmf, mapping, VM_UFFD_MISSING); } @@ -6248,8 +6230,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, ret = 0; goto out; } - return hugetlb_handle_userfault(vma, mapping, idx, flags, - haddr, address, + return hugetlb_handle_userfault(vmf, mapping, VM_UFFD_MINOR); } } @@ -6419,9 +6400,8 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * hugetlb_no_page will drop vma lock and hugetlb fault * mutex internally, which make us return immediately. */ - return hugetlb_no_page(mm, vma, mapping, vmf.pgoff, address, - ptep, entry, flags); + ptep, entry, flags, &vmf); } ret = 0; From patchwork Wed Feb 21 23:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13566621 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 6E4E6C48BF6 for ; Wed, 21 Feb 2024 23:50:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13D846B007E; Wed, 21 Feb 2024 18:50:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09E856B0080; Wed, 21 Feb 2024 18:50:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE5FB6B0081; Wed, 21 Feb 2024 18:50:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BDA3C6B007E for ; Wed, 21 Feb 2024 18:50:06 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 88D781C0C7F for ; Wed, 21 Feb 2024 23:50:06 +0000 (UTC) X-FDA: 81817456812.10.AB8CF8F Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf03.hostedemail.com (Postfix) with ESMTP id BB27920019 for ; Wed, 21 Feb 2024 23:50:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="N15S/KaL"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708559404; 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=Lre+UqQQHJdTu6yMn3GijLQ4gMqXOjZ+IEoJS056n7k=; b=iK/Gkk8KVDZct44rs7zb+FEP72hne/3CDYHixwf9zoh7RF3MH973THPFqh0BIUZbJh61lV wPd56OZma9fq3a1TiirmbMDIRyfSLbl9daLNI4QjA7ZpyhxY0+hfzxEAlrdRY40I6va4SE WeQotaiYm5pBRu6XGHE2FzC2s4if8ZE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708559404; a=rsa-sha256; cv=none; b=IbjpuSoVXUWL5W3/wERIn/ERloQbqjO7zThG8xkPMMiugs+ucimxm1DLUz3rfzLt+V8/GG mnmNlvhAsoiDdsvSiYI0gcVwDldGq9yUHWdYDpR63i3Bf5lUJlFbHoNR9slwuszM3BZDx7 vbBAic/V9M50xUBxC2VhORp1N7sKtmY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="N15S/KaL"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d94b222a3aso11479215ad.2 for ; Wed, 21 Feb 2024 15:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559403; x=1709164203; 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=Lre+UqQQHJdTu6yMn3GijLQ4gMqXOjZ+IEoJS056n7k=; b=N15S/KaLFjxVQe2zJEqkxpLKqwOEP4oUGjAXYbUfDsXx4KT2sm/UrSy1R8ia1Tkgw1 orm9BYF+zfORWk5SM5BufTaW8zfhGb/bE0OSM4eLaHBUhWubgvRd6Aj24tzUSpwzXido PRaWpvMehDzulrXB2v/u1ko/HO7wG/HXNPopfI5WndDUaPexYSAj9+JPVsM0+yaat2Ft AFerCSr/WCHBP9rETb8ks5EmIMwVCapByhM8xbW4Mjq+dbbNQ5in7q+WLmy2gATf0w+U yK2ETrA3mRwk2aSbHV38rmv7KGzybwRRGXhWkmSOUQoVDXEslqIQDAH8pYn3tMEVlLZt znXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708559403; x=1709164203; 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=Lre+UqQQHJdTu6yMn3GijLQ4gMqXOjZ+IEoJS056n7k=; b=wb9aj1XCyaFPK63stuHrGiEKQOhH4Joklq4jA1kI8f+akovktShZ7Wlvufn7Mwx5cy 73MmSLT1AE0qEf2ikgQ4hD+sZlNlrfywCowzhBlFuQCZ/jiamx+uiU01t2CP2Iz8/sXZ 0H5+uUxqic+5TTQeSPac81Kqx7okfTZc0/NpFY8yBSbPL/fxkjK53oWVYDGtt7Dv4468 KwOjmm4wP4uLDroNuJYU+B+rARw0xL6R1tqOaKYqvEiFR1T7fKpaOdKbJU7nxOdtJZTx Zdl/koViG0Gl5NcF0iQt+KFH6tW3jNuq1RODnOLzzTupozn7EMBmim7/oK68GVM7/krF ivhQ== X-Gm-Message-State: AOJu0YwKk2d6s76uYGdbapMhoYF0AdvoXpf1uTQcb+QzEdNvafEMW4rS md9PHlxKbRLD5t6TYFQkkR5Lt/+M4UWH+lU0Pb+SqCMLJ0N3UzohGPuuwLee X-Google-Smtp-Source: AGHT+IHzBLxTwT83ejaeN5GYbEyyAPkmAr8zn2RrQRiLrYkA/4Vzbw5dz0rbMxD4XQ9QGsj2VVT/sw== X-Received: by 2002:a17:902:ce82:b0:1db:f8ef:a9e2 with SMTP id f2-20020a170902ce8200b001dbf8efa9e2mr11700757plg.47.1708559403319; Wed, 21 Feb 2024 15:50:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:02 -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 4/5] hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare() Date: Wed, 21 Feb 2024 15:47:31 -0800 Message-ID: <20240221234732.187629-5-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-Rspamd-Queue-Id: BB27920019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: w3eupjztks49nty75y778tb8s6yhf1wq X-HE-Tag: 1708559404-282855 X-HE-Meta: U2FsdGVkX1/9BJJFfthMEeEk8CbF9igB4uq4Uw1v663fC9PNawsKIYEn6i6g0PFcqcMcCT4RtWOMYQb7Uc/9wpCfijy/ZFcOUm2pLWYmcDr12pfAWbmMT6FLxfFnCCf9XDbChX0BojcY/yBJNs7tyAtFI3AJKpvs02fc4CM1klIILquzU5EPSoZ3/NU/oA4I2f+ERi6LBZT1g/tKX4IZTc3eXInvv6EvKt09u/drDV9G68qZMeWYb25MF7WBhj7kN265jRPi84yqpOtoLkfCVjL98E1I8IQH28NBnP0iPqfoEohrlHSD0XBa9J4D8DuPiaw+9lEBCqG/3SEkgtw0vj9pbsAfBdjQ+HYFOgzjYjxA7Mjb+9dPIlHAUpRxf2JGM8g8iGoLPUm8dUVAFdaPG7Ci0uuEyZZ8/ZMJDgBwWHpRXT/BRv7p9rCJAp+jK/HQgglY2IHxOwVZfaBE0nygVfPTaCAxroz1LunEb9RD7RnRMC5baaX9aiFD9u74FXyCRVvy7zocR5bLkg4L+jh3RYg05pzw8c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=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, passing hugetlb_wp() the vm_fault struct from hugetlb_fault() works toward cleaning up the hugetlb code and function stack. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/hugetlb.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 70c5870e859e..ae8c8b3da981 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5826,7 +5826,8 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, */ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *ptep, unsigned int flags, - struct folio *pagecache_folio, spinlock_t *ptl) + struct folio *pagecache_folio, spinlock_t *ptl, + struct vm_fault *vmf) { const bool unshare = flags & FAULT_FLAG_UNSHARE; pte_t pte = huge_ptep_get(ptep); @@ -5960,10 +5961,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; + ret = vmf_anon_prepare(vmf); + if (unlikely(ret)) goto out_release_all; - } if (copy_user_large_folio(new_folio, old_folio, address, vma)) { ret = VM_FAULT_HWPOISON_LARGE; @@ -6203,10 +6203,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; + + ret = vmf_anon_prepare(vmf); + if (unlikely(ret)) goto backout_unlocked; - } anon_rmap = 1; } } else { @@ -6273,7 +6273,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, hugetlb_count_add(pages_per_huge_page(h), mm); if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) { /* Optimization, do the COW without a second fault */ - ret = hugetlb_wp(mm, vma, address, ptep, flags, folio, ptl); + ret = hugetlb_wp(mm, vma, address, ptep, flags, folio, ptl, vmf); } spin_unlock(ptl); @@ -6496,7 +6496,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, if (flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) { if (!huge_pte_write(entry)) { ret = hugetlb_wp(mm, vma, address, ptep, flags, - pagecache_folio, ptl); + pagecache_folio, ptl, &vmf); goto out_put_page; } else if (likely(flags & FAULT_FLAG_WRITE)) { entry = huge_pte_mkdirty(entry); 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-Que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v5NKv71MVq17CKaYtZrvnIkUQL9xmUh5rVFcojTqcxY7Pky7qreDg3Tc1v6sLhAJ1Pv5HBkbIP7zg9SHXM8s2VD3lt/q4SwRmHIMPc8CfL4T/nCNIocCT0Ryl4JeZBkVLdbnpiDP5kb/UueSjG2XvUJIH8lR5YrfU1itH0xn4AWU9m+aZFr1AulsVwmbQWzYtRfjolPErOy6lM9d/eONl0PaFFCY5kiLnb2LDR6Kh9WziLilOMTdQuTTojjwey1X7o0hSV7XtwS+markTuPdgwyfOsp7OGJOYbvCcBuGtxT1T0iIaJNONjVeDXRuIYEak+XZ+kvERs5lXR0mUYQSlyF5vMgK+m0NYoXx84YPzLIlAVkPRSHZFXk265P51IoEIuv158MbUv04CWHFZErXrpP3q6N3gEfxhxKUpA1o2/z6Z2nayaHMHwLy2wO3SSTz0uGp0BMaFleDNn+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