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: 204496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1363824dyc; Wed, 21 Feb 2024 15:50:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjdS9Ooh3p6s6NRHhR4ZD6D639EHdwzFpdITlz8lQFEgpnvgpycVDpWlIQQHwMvbAx9MUrqrqC7t1AmqJdUxHO79N68w== X-Google-Smtp-Source: AGHT+IGa6icchrWg/skqhf2MLa5N4u1GCMXLtIsUEcNZNr5D5p4+HmEzD6+7nhwPgaZsjz5kANtG X-Received: by 2002:a17:903:40c8:b0:1db:b09c:6d0 with SMTP id t8-20020a17090340c800b001dbb09c06d0mr18063830pld.64.1708559435449; Wed, 21 Feb 2024 15:50:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559435; cv=pass; d=google.com; s=arc-20160816; b=N9UL8XY6LZdQbt+6+bEyB0CC1GLE58mmTwza3GRabm9ZCLvg9wg/dI72207MjbJgSb 882wK6So19V3YxqN89jQ6kodNadBqUvxdO/ztNWaMORiF2uX+o5X3TC9Kx52ftuv/jx9 81lNiyWigzf9zSr41/3OF55srwKInTuLIH3TQcCCRPGcmw49TldN75UBaSihek+M6Ieo n6ptXpJMBtHE75pjufo1EbHPC6qoGPJzGsYDV2eUyLldmbApm0vG5fvg6BlG//eGOKz0 VQpcFePYJa7A6Ird9TguBNzeiO9ANyUdL66c4trgc4q+u165nouqfoBX9cPQwapIbB4o 6OEA== 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=D9r0dNhUKJEdGKYYdAqMzZgO1joAP6x5GpmEzjGgfls=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=S2rWdiB7nVL6buSjz2i3jg3MfL+UttAxK5RGGME3MsibNaUoX3IqIs/bUYq5OmTyp9 1Whoa7OwEZG1C15S/34Ntj1uYS/EWe8lIxAYd2e0B27QhOxQvyFM7eW5PxJZ0qNiDjcx aDkUX90a8ePJiF6ZXvUNbCmEGsSDFX6pwHlDok4yONO//uwBERzL8oVPIvc79qBN0qRe j0F3KATDhbMF7fq69Y1IM7JgaS6SqARABkJ+mBAzz5E3wHNOQz6OPr+dIkGO5l6w1h27 OJYmdmtMsnVWmdlJ+7TpFq3VftjXrJGp7I5p/4xjLi0VnJLk8UtgRt6GQoMEgOA57rV0 zr7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VepxDnJb; 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-75683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75683-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jg6-20020a17090326c600b001db7eb50fc8si8932367plb.273.2024.02.21.15.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VepxDnJb; 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-75683-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75683-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 486BB282B6D for ; Wed, 21 Feb 2024 23:50:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFA8512DDB4; Wed, 21 Feb 2024 23:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VepxDnJb" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 0AA0312AAE4 for ; Wed, 21 Feb 2024 23:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559401; cv=none; b=Se3/iLlXuOMPVfLBMd1yJ13xpS12txZI0EUk3WRN7UFjfQBZP7uRaI6Kwbs0qrLB2KX7d+swZWujBqkauUjMJtU4JE71b2a0/KLeHi8c6vOGWsAquh4GnWzsBv/IQ/imCCzFwLaDfWyA3Q+dX3JQt/7nNlmudRicQSZ/9TU7zYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559401; c=relaxed/simple; bh=JKcwE0zsOsh6vK/ygPXzv/3swhs7TMsE30/0uIhDBZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tiz+M1AER47ov5W57qdxzLzCpjZvpkxdalygLIBw0j+MaQzD0/2X+INeIKt0igRSxpGBAaWhMdA0sJIKzBzw2BsPLrNnxwtdK/sieG/Ckblnl9ysJ3gagJ4/G9ZWhEVwTMDUj3GzSaZm5vSV6PIvzl2VbRFOdMIGIvV6dzuoYGQ= 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=VepxDnJb; arc=none smtp.client-ip=209.85.214.174 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-f174.google.com with SMTP id d9443c01a7336-1dc49b00bdbso1657645ad.3 for ; Wed, 21 Feb 2024 15:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559399; x=1709164199; 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=D9r0dNhUKJEdGKYYdAqMzZgO1joAP6x5GpmEzjGgfls=; b=VepxDnJb5Wn21JYy7a5rspPJkOkKNAQJ0mtJISEP01l+ggPObyMNOkup+EMs0d9ZCO LW/pc+4VsmVRUzU4GyNdOQ/J3JqDd4jm3aaJqxPM8s12MjbAE75uB5ZSRsiXqozI+/Ye gQuJLV2WD45Prl1An458gg+8foQ+lqTzCkA9hHEnwnBY2F8nTTf2RSM9nD7Gt8D+Cozv Sawe8pd3xatPCZnL4lSnxRr7gMYQv5e11ec1zrPS11LFah1yaiYcfdrrYHvQa007AbV5 5Q2TAXtPj/efQDdo8OtFZKpkH3YoOu58yBtq1flEXwaHzxyYyy4NipL0lXOSG82QodKB qxyw== 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=AuTDxqwO0ZKcjrZVmaFAFWxejW3cQ5lLtAqBu6RCAvKgUCJ0QZ33A4USZdvpJpVAyZ uHSoO7/kW5eR/xoCYPQo9hN+2Jb68AhblHG7KkxI5FnxfQhmp18HCux/NmxckMiLFPA6 T9rRlK04exl2aRSNfSSINZypdlWM99BSyq1pyE9BIMMaydkJuVqHiOir6mP6nQXAFDSF rrc82xripODiSCgrR92f/BswQFYXgo6Xm/gpnevr8VNRL2VffHI85iKt1n+Hx1NWvxKB au83j23BapzJPB03PV8eF6WZnhIdLq71WZW8/NZ2Ak91hgcvtYyqp167k7ZeMFf82NDY 1FRA== X-Gm-Message-State: AOJu0Yy3OJJiy+VDRq+wFlCx64JBesOI6ZBK3kJQsbdIqkDG+vzSB2te FLdVtsBomTDdRLrPWqmIhqhBIbgzacizmKBSZjBf7eO91g1aZFxa3sSIxxu5 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791554418872043726 X-GMAIL-MSGID: 1791554418872043726 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: 204497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1363932dyc; Wed, 21 Feb 2024 15:50:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdxuqvK59SuwO6UizsnxtbBUn79YmYb4MfUfGa+Vl8WBOnT+5o6ECq5SLMaTWIFTGDL4s1sJL0a1LP2nHV/C+NzpJEQQ== X-Google-Smtp-Source: AGHT+IHmIoMDZkKPLQJCkPDUwExT7RlOGGNMVHBxDRwCGDsFX7buBXBjz6pGyKVEFnANin9prlio X-Received: by 2002:a05:6512:1243:b0:512:d86c:1e32 with SMTP id fb3-20020a056512124300b00512d86c1e32mr1630617lfb.63.1708559454231; Wed, 21 Feb 2024 15:50:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559454; cv=pass; d=google.com; s=arc-20160816; b=f5JzMZmbhi5YIUki1BmeZ3Xs0Doj+cMHd74ZLnUj+0A4qx18oLs1GDfAq4OMXVTbkm DSFToLPJqHGgGhKV0yoc435usXeLQ0KZoLbpdaOZJ9q1sf6ZN1yhQnwafyVQvUMdbmxq OndjL3j7Ya8ykRNQ7QviNYKdCT4dVOtguiLJY38R4af0I6WT8vDl2BkfiN/XL96ymUjf Z54DAd7U+FzHBcBDixjkB8lL1pHUEEIwJfh+k695p2by5JcRuMO1X0CxxzIp/FHi2oLX JG+1A0dZKFbi1KLje0kWzKzfKupR3z6Lg2JDUD4audXYf4kfiULjVYE+HrRvM8jAP2XT h/mw== 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=+yscKp0AJANlReZg8MRza2RJbrRIz7yBwKbuUCOLUH8=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=BlsCbh7q2NX8J09icgQncHg2mnqR+a2Uc0m/7uNcxSHROnAA2jZCv3z7gjDzsK7Jii o5+XKVJbsAMHcsfDqY+8rPadjX3F54xSrXEzrx/2YOmSestfbIe3NMv4dOqs6F5I63aY NzhI0NMTomsA5aB+q/plE4+/BuiaUxCHIx9Za538aq/h0D08dwNRoj7K1rb9xwBFD5SR dhthdk3dPqajVOiusmYkQvlCWjyPpCFEhDoRCAjXFNLrv25mAaQh/IC9MM8UDqYPieV/ xN9VzDFTf7eU0fx7tUtIjblRzYsWH5/1pljW0vr2hbVQmiYY5Cdov9RMjy1h51u+HkYI w2IQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q046JbFT; 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-75684-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75684-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t24-20020a17090616d800b00a3e5d50ed0esi3751534ejd.93.2024.02.21.15.50.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:50:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75684-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q046JbFT; 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-75684-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75684-ouuuleilei=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 A6B901F243D5 for ; Wed, 21 Feb 2024 23:50:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A264C12EBC6; 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="Q046JbFT" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 5D2F612C809 for ; Wed, 21 Feb 2024 23:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559402; cv=none; b=YlULQX/J4eRyr24qUvYGmWffUZh9EPfOXQLdb+Va4SoDXmPfs8h2V3SLFXKcBQfwY0E63e0XygDbSoq9PXAQRVyleuuWWKi0tvNH1uP+Jy7DZjGbJOQkvRw3EP1C5FCUjSXgCXLLhWojSx+ugsRnJuO/xofn0R/xV90iVWQ2p0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559402; c=relaxed/simple; bh=FAgtlGGDMtr8yiPvIUkNg2PdKKRtVVWsau7z48QcBII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EjYfQi3ji/oRMFB0etA+JazCxO3CNTVCcgcfjOOh2BBei1vuSGm3bvxa2iuEyauAjzPVkgFQaqjgyDla9VzwlR916EMnKpkSCmQdNc0zhZOxUW6zywiNS9DIFgHhVHbrhFObjYNo9orwCJQhXkp1qG9zQid5PBNUB258qwbuQic= 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=Q046JbFT; arc=none smtp.client-ip=209.85.214.175 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-f175.google.com with SMTP id d9443c01a7336-1dbb47852cdso11308895ad.1 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=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=+yscKp0AJANlReZg8MRza2RJbrRIz7yBwKbuUCOLUH8=; b=Q046JbFTfKXqy1RWrIT6BrlaXF7ajxXLrWGRYAJRvUWtZDSFChQiPygmTwukgug9qu VfMfo4xvk8g4FdERXQ7b227uhLQH7sw8VPSo13lQ/IsM6aSTI4BHgTNNfvuyt+7J15ML KuPJRTQElmSrb2tzMIVCNpopGwH9MYs0XMbbJdDwG63H8SHsx/IHlRnWw2hC4sdEsPay 5Qi9Bh9Jb5MPlRs2ZdvuCKwfakElnP/hfbezZL6FIl5zmw19gnLZRVxVeNoNmM1xj3nr Y4+6SvX7/JcyTAUCc5CozDQ5JZUrAFrhIfUKQu2OHn8Ckrf5byqtDoVMZznfzStyGWd2 JQyA== 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=YsZViXcMZcoq8oyH3SmnPVKWqeGEBoLUYUhgT5Rdug13xSTQEG1andczj1X+sV79M4 EXr9h1Hd/u68+Ja+pmZjd+0TDhvlnrFcleXzBzQicryJryJCtcAWXcSaAE0IDUKn55ks g2HjVNoG83HYXImo1kGbvGuwmxL9fyEyiFmKNnuaWmUZkepbt1/YRv2ga30ZtE8D8uKT iXBmPAyNdiad/0gEJ3CY9w9tfRseBvNaACmqLv1w7NQSmKIWa2ZbHZJMYQXtW36MU+4Q EIZFT+gU2bvT6ecwakH4vvYvsHybUsbiCtdVNrMK//m2rMnKv/PX6RTCMHEP/KXPH9Ym DyRw== X-Gm-Message-State: AOJu0YxXtjht9bi5Djjd0NfHbqz9TIdXWzXKR5a1V8RwIvS2lZkmelZq 43Z8HppgSYHcnrnX7zrWwjlndWOIgOaerQSVgI2z+2NzIqdnzVhd 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791554437956560320 X-GMAIL-MSGID: 1791554437956560320 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: 204499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1364328dyc; Wed, 21 Feb 2024 15:52:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWqxOyy79TV8eozNKDIWnDa8lHt0WA8AIgMkE4+xyh6GAuWOcxeoNEr+nJjC7ZUfu2gPYrObEFlp/Hc58O1ddoW/d03sw== X-Google-Smtp-Source: AGHT+IGQ/ZeV8yc1KR/xhHUHPcudS68rIHS8yrlYjTfie85QUgOprd+qH/SgfqGP5+00/EBuCJJ3 X-Received: by 2002:a05:6870:2214:b0:21e:5008:cf62 with SMTP id i20-20020a056870221400b0021e5008cf62mr23827585oaf.21.1708559529218; Wed, 21 Feb 2024 15:52:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559529; cv=pass; d=google.com; s=arc-20160816; b=gdq7B7vHJjWa/kY6GElkmNlQb/+b/qCPDf5dpwV13YczPRe5qtq1FDZ29bXSe9m3zY MsG3+yVMRTCikRnTX7SAQioX8SjXxZuuwAorBS9VfFklMz/Ts0Wd1mlggjCRyqG/l885 86iScNkW+mGuDn/19Ha11RLOpBH76PwTKCZG3k60aq8gTpNT2tHvxc9Mk0QHUu663VNb th+dIKtpIEA6Jmsl5RfkzMt1Cn93zIaFqouEkaOMOtSdK78Rh3KvTJDyV0ZACLzKpPzt thzT8pkKrPgWWSaUauhr6RKI8G8RLvojHWzLpeeVNtuF7kAYeYs7Yvwz7ka7n+WIQ2da 0Dog== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75685-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s15-20020a65690f000000b005dcbbecab93si8979903pgq.401.2024.02.21.15.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:52:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75685-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75685-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DFFD8B2277E for ; Wed, 21 Feb 2024 23:51:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0461712FF9D; Wed, 21 Feb 2024 23:50:07 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791554516692802568 X-GMAIL-MSGID: 1791554516692802568 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: 204498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1364064dyc; Wed, 21 Feb 2024 15:51:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX21n43OoO5ssnUJhEHGUakF8MFRrpQeQ3iW2qJsDsPMYxRzulpj+6KVax3K01jRvTNLiwO2pXWgqZmr9g2Aqdz0s8ucg== X-Google-Smtp-Source: AGHT+IE9oeYKiBJtnYDOUObK+Pvbl6x3YZ5JAC6PeM25UgzxH5Y1FsmUydq8wrwuFq0L7W6U5P0A X-Received: by 2002:aa7:d996:0:b0:565:10cd:835 with SMTP id u22-20020aa7d996000000b0056510cd0835mr1611820eds.28.1708559482540; Wed, 21 Feb 2024 15:51:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559482; cv=pass; d=google.com; s=arc-20160816; b=sdqcxF6Lj58kxKvQe3CYCKdsZYB/q6hHNECKIyRRdCA4qaH448ExgEcpKBEgbanI9D 3Nwb9LVzXHO0YCsBy5n9f9oDOvmlvNaw62vGwLapSc9hvilIjZxDesfOM4p/piWv4dhE JFhjU0KCm3fEFSPF4wA01H9smHIVT5DTthkMlT8OV2oo9BB402c/bbMCyhcuEe2QFsFu M/9X0Xwitg1qRr86qrmgVneqaLBZk0fDNxEJ/UcJVtPi9PMNHvsl7wDa3ThOEbKsd5pE ECrP70X/uO0ybZjIh7BT67Q3rHTsTOG8ZqnWyOt0wZa4bLsdwnaT5f5vvxvzICgok88M kUdw== 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=Lre+UqQQHJdTu6yMn3GijLQ4gMqXOjZ+IEoJS056n7k=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=MK7NkWp2nJDk8VLJdDZ93SDPstUV4HWizgRQOsKJx+boyZTPd6jMJvryHJ/2Si/nm0 OmfZYz1/eP3IzXyBDsiylqjngIyy2D/MnmBP+dNp3XoGH/mafM6Ap4lxgvjcR7pES2jo I8gO2qRNruU03Af5fTNdskAI+EQwjF5mNHK6qgqsap5csRNeVC7Le2J4F+c/5NZR42wn OhUpQ1PB4o7RWQls/2RlkWxN/RWeRGkePuCZcjbI1QUOuRaEuJbjK9uQCKy3H3OSMlYb qg1/M0n71eEH8HOwj5AvXpereKyj2nZMqcr9sbqXNGSq0WExNPv6dIcUboYqrT17EniK vIEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUTXxe3V; 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-75686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75686-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v3-20020a50d583000000b00561d43bb5f2si4690504edi.387.2024.02.21.15.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:51:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUTXxe3V; 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-75686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75686-ouuuleilei=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 2B3B91F24361 for ; Wed, 21 Feb 2024 23:51:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E32E132C23; Wed, 21 Feb 2024 23:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JUTXxe3V" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 1D3B312DDBF for ; Wed, 21 Feb 2024 23:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559405; cv=none; b=a7AHBgRohDWCC1qW8FUNUHX/gUCufbv+00au/UBkbRYYrD2TddZ+AZl0Di4hWpQeV+Uq0bc5KMfMUYAYKCP+41Ob4Wi6KgOCoeyQKS7Ej81AaOGu+8eC1pMei7EPYLCEy4dd2BOy7/TNB6k77le7rc9TXysjpgLF71D03XZ3BmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559405; c=relaxed/simple; bh=XJuffzEnSNsKJ3424e4z6pRxfuv0ZSk9YKCo6w6QkXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aqrnIHChCIPdoZewYYyuPCDBckhOM4QxpAV6EZp08kUZlDpbP7d8oHZihUoVzw+twwl8s/NOMEsxwWBNeK2ZxJktGcOnHbShokILeZlz2+NXAv/11czhzVjd8DYs0Gvyfr8t2+NkdvLndAyBwlGeXLJbHM/wDraOjjgDymaH0YQ= 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=JUTXxe3V; arc=none smtp.client-ip=209.85.214.180 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-f180.google.com with SMTP id d9443c01a7336-1d51ba18e1bso12930705ad.0 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=1708559403; x=1709164203; 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=Lre+UqQQHJdTu6yMn3GijLQ4gMqXOjZ+IEoJS056n7k=; b=JUTXxe3V3B3NiQcRIjnkJ4afoy78xQD5DeWFZUsj8s51ZGtMTbZYeSSM7ozrNym+pf SI6NhHXgsFpexqtsOXM330c2qSB/fuA+xCZFihB4k4elUGsMhk1lChCgL7B+HfXam3Eb NuA5JKCRpYvAIcyif7rTsg+j2Vh+1Ao0v61iH0KPC5B8blcWdIG56PizsiEV5/aVB76C EkkvpH5ZmjIMw7kA7+HSSmkAa/V1zSumR1LZzzIHWgjINiD2C7DUB3cDLpn8iZBNnbGQ uF86omCfk7PrfP/b/DN7toJc2WvNDaHQYwjgUyTLTViuBYk7xTRoyT21RxYfZXqxHW6j cPsg== 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=Ic6uMtgJeoDfNifoT7kXI/UhBjRsoMhCbMhxt2piADf+DpH514S5Nv4Y9Padj6JXM1 uppeV5k/SPUIOSlLyvs9UPZRbpxDk0uQyLja5vCNoWYtoMVCNZaJg29VPFJCHd2+nyT5 VTjf2wDcHPDRgB82NrmoN8uflL3RqZjB9Pqyj6KwCwiO4nbD6RSQzJmVVuy5OY9gqWu6 jDnBxBEhelu5Oa1swgWIL+gI3tsELg33dQNO0c/WAWmVJOmCWDTz8cmuahoeOJZOMBVp Zix3bk0uZHp2z/G/478EkZc9+eHGXGfhhj1rL0u2WLCZI93Bq9g4lLv1avmTeQzMZXFJ 4pxA== X-Gm-Message-State: AOJu0YwTg62NCwMmzy+ybY0mBrgkbt1FBN/VundYkSO89Z8sqQyd1MbB RoWaiB0W5bZAwHR8VDdUUPChZQSvu1A1nlRvXvQpE4CrdhXvvXzkF0gs7Ua7 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791554468154920589 X-GMAIL-MSGID: 1791554468154920589 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: 204500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1364483dyc; Wed, 21 Feb 2024 15:52:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQS30UH0Zd0YJk1kOm8GruaVWLqEp6wBmvnDwNsbEU9Jc9Bw0F3E6bfAEEOmGXYO47nsomdrqQ907QzcqvkE7OpKk89Q== X-Google-Smtp-Source: AGHT+IGRp1eUbAt/qR02ZsvrMHmD4wJzbjYqxtU/IOGvQgXRNeAzy4+uoW+3eiwMBJV52R5I7SSa X-Received: by 2002:a17:90a:d511:b0:299:d779:23b4 with SMTP id t17-20020a17090ad51100b00299d77923b4mr6291392pju.48.1708559558176; Wed, 21 Feb 2024 15:52:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708559558; cv=pass; d=google.com; s=arc-20160816; b=YVelF757ZpHjLAz+g1j7j9UxcjuzzshzQWsZiXCsgx9LSdwFlrhPRXxlgwqSntIxcl KSZMbMLhGTs6zjOmOffnxClP2RiilEOeOvlU2Jh1dxxcShXnwxJbe7FCx5RlHPWxxKPS JXmUZ9Z09xiFc4oyTbV+Qxn7DQSUYUysv6AwnqlLOKrGYWf8Jq53wdSrvptHegqu4mpS 8hZ5rq21S/4OiexO9A22b84tpnXe8WbV3Og1/wayRgrAJbp6Ivsp7p3XXSP0J5Dab8Mn e2Vr19nVqt0q0dosl+ceEf/Lhr2/klaKx5rHId148+apFZtvhr5jzmPf4annFV6qAA4z 5sqQ== 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=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; fh=bYkyQ6TEkHmoVFeA4uBytIaOo1w6qWAI42GBNQ/IGOk=; b=BsN2kLkfw/HYtPBcnMV15VLIc+YGyi5UEwcGioMpvo7C7iNS7EZ6ZyxTbYtQbEAP6p v7b/+yrx46cYx4Afpft7+vzjBHAJBl/rLo/NQoL1wHKyvvt7KhOcnkl8MPx+yytbZPCd kD+vrU68WlZOf5RTDbIpVUGxAD+gvxu7d6BYJ1QvIhAcjFnvZej9y5xf7zd8PD1xRxR2 ZGOJMGpJJvRX96kiqNJQ5w7PO4ORtMSga0wEnksQLh8yJw6U0Nfy2KafrDV3XCmk10yt vN5S5xkJKBgLcdRsGXK2aesOCF1dKyL++m5utmleD3S4aLzdk/XaTuQsIn57MH1tvnA8 xarA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LgC/KyMo"; 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-75687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75687-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id pg15-20020a17090b1e0f00b0029a3bbc9244si786592pjb.39.2024.02.21.15.52.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:52:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LgC/KyMo"; 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-75687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75687-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DDC91B23B9F for ; Wed, 21 Feb 2024 23:51:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B073B12C802; Wed, 21 Feb 2024 23:50:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LgC/KyMo" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 CB5C212EBD8 for ; Wed, 21 Feb 2024 23:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559407; cv=none; b=j1DPKqpwaddOGIBGj7pnEjLbOSGcGqOUbeiCpg1ABDhB1WuH/afIcO7w9ifRucsoh5I9iWiJXNkTnvtS/xTrvlHv0tCPYPNJF2tHICn6x/iGL1Cq4NQEphE8XT0ht1sbuuX3WZrX80hyqNPDwvADpXcLk00lPuWMgHBB6jrE+jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708559407; c=relaxed/simple; bh=kuCilgvuAIh9xQxA9Yc9QbjSc9LNo4S0L3J7arnWxXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Seg8a6UIDeQeh06BjSFN32p+W2NDCB8JseJo2CyFa8ftKV+U3zZOPO/gHHL7KdRiCE7T9kRIkOZh78PH+u6ASfheQsQloZLZGWmMbjkCQ5qqopxoFww14X4K4HswgvIdv28nUIozDD8ipnb1YbFHez3D2O1qeq/RPYm3Yb2Db+8= 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=LgC/KyMo; arc=none smtp.client-ip=209.85.214.177 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-f177.google.com with SMTP id d9443c01a7336-1dbf1fe91fcso34096775ad.3 for ; Wed, 21 Feb 2024 15:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708559405; x=1709164205; 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=sSphF0hTHN6hhmxhntDhI8RCYH5xfOdNqWBCuNfZ/qQ=; b=LgC/KyMoozmyO4oXLVBr62ZbpCIIufqufHT80D2orEwyE/eaXu+Eqa5/u1RMMyDnu+ yDKe/MHODT98BV+umht4rYfU1ZrLXUToA6enMfzs7oDUizM7NMZmmA70VSmGsjDPTLcr pcQVut8HoYojsUDmM2Pi7RAFYLm/iNrHF5xVCofWzS4YkCvgJ3kbenrLT7PkUlWaehP7 FsCQbIcqNg4R1PtTeWNwj2J7GwfEh9zaKGn7UmYTsiRt5AM51gUlwuPTJzp/84I/QMr6 rILRVI3h1uRdaGtwaPRVe2rieVPSEg0SVYDPCqIyosexkVHdCbTw69jncE7dTEf6Slxb NTaw== 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=glN/j6rgmzPLezkraJkl6YPtVeuk603d4wL69smOCMZARXUrRnoIwjrRTmgPtAO625 0FDX62A8J4mqBTZPNuCRuhnhAy7wxsrUNH9da7jhGF+C78oXkZiFdXxy5LURlC7rRL86 SsrELBPE8q3C8YLBjOrw7tvFTn1w1Ngon2lupOkYWcm53Ku6aBqf3QmjRafYuOYUJJ3H QGzZEfYonpcXnMC0UMKjynRWqHu2SVtGeZucYsjHrdg3dMVhJq2OfypPrndNHZmleyU4 bqsBUp81OV25hDbjv8Rg1PgpaibeW7qtYPOdR5EmMRTiQm6D/QQXJDl9eZXEJ4e0Mqf7 wBSQ== X-Gm-Message-State: AOJu0YxQDHpQBTVsuyc4Krl5BZxs/0f6ZpESlALZwhHUevfyD1SkC9JX 5enRBdsL3OqzGBNMiSeV2kps0SjkQMPdSlL8LN0gSVsB8sRwYhsM 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791554547639759532 X-GMAIL-MSGID: 1791554547639759532 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