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;