Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp26408rdb; Wed, 21 Feb 2024 15:50:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUfckFy2iLPQmPDYSDPJckCZZD2XPNUmOp0N5wr/mCxGEY3M5CCcR9j9S8T5qrSf595OcS9f7h8vz4LgzGDEMSbHi67kgXOoWdAtm7etg== X-Google-Smtp-Source: AGHT+IG12W3+2FPdS+9CqIB4ByC85DexabsRT6n6mJnFwqYyipTaf3v1GTGXNUVjtePI4g8hKLb9 X-Received: by 2002:a17:906:e2d0:b0:a3f:f92:ebea with SMTP id gr16-20020a170906e2d000b00a3f0f92ebeamr5095854ejb.5.1708559447719; Wed, 21 Feb 2024 15:50:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559447; cv=pass; d=google.com; s=arc-20160816; b=V4ED2IxDoX7QefraiPfLGbc517W31JuwDsBTjf3O+k7NsNucpKsBasc6GfE2DX/7Kd jFtOO2rc0ud6wESnal5UsAyRFwTJfjHSJh/WQnyXpR9Rg2SzzACvtMtNTjm2FlHRRLE1 2Gtvs9ezPrUhBADDFYM3xv51AZ41wXrZZBdc1qx6fAZDDOxG7ySpsZEU9josiLzcigRc P8a7fK+1kkNh9ifxA4s5d0/4EoU2ykL/yO+fWJ2PEOc8wWSAZ2KyT4ltrMm+tjlulMSb F5Uskyh4vPm9/BNbNJQTiTlXLWpQ59TUii9YPyLG9DMCFMBhM1kQGyuaLme4aWVIi7Zh zCqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pW0shPvwYrN8ODFgTcl6EvNguHwyyx6gBjAHCZnk7do=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=ozWFjJiGbzvK5Uj1xRtbbG24Rpaldc8JZ39ntFyLCCMsm9+nfKM/DRRbUy/G6u8W/b ooGUV+NTf5/HOHQrBr/ah0dQHEYzirrKRazi2G+HieSR9XkVsD6vguWWUJUCfyx2EZg/ T8cIApQ2BjQvQnZpGnm8uhNjvI3hHqWVAhCBVs7UiRkDhBBOq8UHFVEmOdautiNx2MwB V88GTwGPXO51yYfS92l9Bh+skZqVwTG2lZiuNYpe2uVtF/ZFBEA2pR8lcqcwrUGGVAKI J7UemD9JyttiPUANATH0xxatXY/Akeg2VaT9uazPtWl9qpXn/KDDsNfGEdS8r/j9vbDy Vzqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=b4Oi6Tit; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75685-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g25-20020a1709061c9900b00a3f2f6786e7si1051093ejh.448.2024.02.21.15.50.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=b4Oi6Tit; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75685-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 505DD1F24402 for ; Wed, 21 Feb 2024 23:50:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0259712E1E9; Wed, 21 Feb 2024 23:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b4Oi6Tit" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5B5A12D77F for ; Wed, 21 Feb 2024 23:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559404; cv=none; b=fOyCndru5THQ6V/HCxWOPXCr00UrwcW4a7WFjXG7WX8CF6BD5GhT/+fqr+7ayLtoncm6eAuH/RrOdntx5knMW5iJJBCIDgtZaLf1DPGWAF28Ab8C7ozy/o8dtrNXVLBoYsIULptzCwSTPx+SaHpDJWGBm2gUXjRubUH1n7HsW9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559404; c=relaxed/simple; bh=9I24s70ML12HR7yAYgWnA/yzcgx2UmcSmZ6qGRMVJj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YbUFWcm3QDZLnzEz4pOMRdiYdHzr8rlGpvvRhTKZRubVJQrzrPqrKk9QTtQoeD0W3+xnUXLcHrnasSJRrLrPUdInDENl/jq34OEO7Ki1EGCPPWEg4SJ+Ndlz3CD/GTLEDbzWVrg5it4daqJncnAz6ZtqBYEeIL4mF4lNBychGBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b4Oi6Tit; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so33956435ad.3 for ; Wed, 21 Feb 2024 15:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559402; x=1709164202; darn=vger.kernel.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=b4Oi6Tite/aRDjIPYFJ4cAgqcToTWM1kmI1GjMsqSEM4aMhZ5iZbfvdl+vKazlWy1i ZQ5VV08gg+AOQitiwHEeI0kJlJw21Bjn1H1ylyna9TkhoFS4bGWkBN9Xf8RqLzrrEmz3 kkOj7iCBDV1j0FaH37XUj3DdZq5oWYf7GTx/YfDXEHY/6LfIo/ZX4KFDFCsdoTCjjGsf d+rZikWdsTXMRhHr59rrgnNaIlDpoQ4qmhxWHD9dXJfH78vmEiWf2PJcKRzOQ8lU/Mb9 rKGXuY1zdDTe2YPtBmQKfHxVTAHBFddinXxnz1Ohd8AUOn3XryQKJ9I6G/sJka4kFYvj 5k6g== 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=QgBPSvmUqsh5T+6wM6mMVnvO9pJHdqVE4wpPA0pixGbbMXL8OHTrPzaDtayIkWFouI KBfqLlZMdr0/t3/SkJtzhtdZa4xbhGSVvOSnOQA9juwiCC/sULslAUM+/HS2eytlR2X4 mS6UVbXk0p+t3sw3u8koxyYgEdG+Rerr9GaKSHYDyfM231eaIyWFr3aO3xfQq180BZlZ NnaQ/JYi1kpUej2FwZPAQTEHR5Iuu/FzUrdsc58SFge0eEGSqitPXi2Rc4c/tFfl5v9t G1sxY90yBpHiHl5TKHd0MYZTiNo/60533VkQyIQHY7j1f6BxXJJBkB9L7mvGS3WUFHJ+ BQIQ== X-Gm-Message-State: AOJu0YwN5pcjMckcl56LaIwBsFhKpwcUsTnB1Yn7ka+kCP2sOSrQq6VT j8y3ssDPFcqsYObkjNHNh0V0xNQGXgyIC47nXy3K+OQmzuyl38pV 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.43.0