From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84F57C98306 for ; Tue, 22 Sep 2026 05:35:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C549010EB55; Tue, 22 Sep 2026 05:35:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="VQS5CPWR"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1920710EB12 for ; Tue, 22 Sep 2026 05:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790055306; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j3/indgfaSaWc6lWBv7sZZH36jWcDt4waMnqUjoKZgQ=; b=VQS5CPWRqzGS58O82hPZzXW8492UTAchvT4Ny4pzwxjXnEzTb/XEbe5YjFk4Adl9WSdhP/ 1cNoyEPGNxHz3Ej8Lar+4Kunw8DFDdnKryzYF5opBAjC5d9baDoxJGRD01Vrg8AkjcDRmb GdkC0qUaBDpLEuzonmayUSm5UXRwtxI= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-STZtmWqRO-SuHsSfvkdDyw-1; Tue, 22 Sep 2026 01:35:05 -0400 X-MC-Unique: STZtmWqRO-SuHsSfvkdDyw-1 X-Mimecast-MFC-AGG-ID: STZtmWqRO-SuHsSfvkdDyw_1790055304 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5b4fe10d092so2566869e87.0 for ; Mon, 21 Sep 2026 22:35:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790055303; x=1790660103; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=j3/indgfaSaWc6lWBv7sZZH36jWcDt4waMnqUjoKZgQ=; b=ngCQWR7gpdGlSP7dMZ/Mx0t+dGw72Uk9KnGEOCiTA6y/8Pf9uHI/2RsKFP5rOrRhFv LC/ygG7dOBhgNM+fbrKwx7h4xEIBYBpR3Me9qUJ+kX+oSwHwVHpLhr/VwxC2to1Z2gE2 +oENPf6hJkFC2IHVvAXP9UYrd1deitD4Jk7t3BoTAS8LEDjIQbb2S3kjIdkfKZT3/Rkb Fnw+P2B/WyEOVbeXkiIGuFF8CgzhWDO/5Hj0440TCCVbjJydyyqD7j+FSGLdz7DH8PKO QdHqml1KOpVwDd6mSuUAl8jKholusaxr9G4jOsOyzM8mQopyJwjUa6SAb5/US+7Z+u8q s0TA== X-Forwarded-Encrypted: i=1; AKwUvBwmZ0eFUEvrtzFYj+1pjrmxuFcFgmxhr3VAsfba4v3UWU2uZASUvHj+c0cA6H6/Mvn0BQ3QytWGuA==@lists.freedesktop.org X-Gm-Message-State: AFuF++kwFnD/IdzkcUTd4b4UxPdVlwLZRKKky68HUtARHYbQ++Q6gC3/ eTXRoNZVsXAsx3qHi4pWFRUYqx0dR+IgU99TNwQOAwK1yD0KozkJRUbhapMzwdqh9LrSf8azbev vIE/uYzDVKi0pGv+VZyLrxvYoJ8YR6ZutqEo53Vc+DkuCK+VgUxPqvFTaTmOPVUYvNuQ= X-Gm-Gg: AYBFou2920I3uu5i39iJzCAyXt3cUqPCXB38ABWYo092gxkVsnIpY0CcGnpEBrzsn4v qRyPHj4Eu/IJdrych7dNUNSLIlRdTJaq13YvE00vSGhK8LKMtjcKk+6RVCjQnd1zgFnPkpNLwrE 6Qw5ri/MIcA22S+gGeSS5hlshuwQ27RYBy4IbyndriHwVpUWEokPbYB6Zpj6qPdUUuqmxzUc8aG BO9DmNgnGGgeve/MDukHHIO5Qc8JJvcMGjdy5wo3wT42ROFSEnlWIk1nmVv+cuLrQiOBMlpzOtV IXF7AJgFnTufwV5R820IupAtPW2uW2vFXLkCC2n7EvL0hv3Nzx9A3nKhBD+7EkazWPYr5ehWK85 2Tf3ZZAJPaBFHocyYQVsPUKJllKgD6yA= X-Received: by 2002:a05:6512:110b:b0:5b6:183b:d215 with SMTP id 2adb3069b0e04-5b8c195af81mr3584658e87.60.1790055303498; Mon, 21 Sep 2026 22:35:03 -0700 (PDT) X-Received: by 2002:a05:6512:110b:b0:5b6:183b:d215 with SMTP id 2adb3069b0e04-5b8c195af81mr3584632e87.60.1790055303030; Mon, 21 Sep 2026 22:35:03 -0700 (PDT) Received: from fedora (89-27-86-246.bb.dnainternet.fi. [89.27.86.246]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46e0966sm191742e87.55.2026.09.21.22.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 22:35:01 -0700 (PDT) From: mpenttil@redhat.com To: linux-mm@kvack.org Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Mika=20Penttil=C3=A4?= , David Hildenbrand , Jason Gunthorpe , Leon Romanovsky , Alistair Popple , Balbir Singh , Zi Yan , Matthew Brost , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko Subject: [PATCH v14 08/12] mm/hmm: add lazy MMU mode support for migration in HMM pagewalk Date: Tue, 22 Sep 2026 08:34:17 +0300 Message-ID: <20260922053421.4092027-9-mpenttil@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260922053421.4092027-1-mpenttil@redhat.com> References: <20260922053421.4092027-1-mpenttil@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: x_ps_EofdQ0c5B1y_8jJSPUBGnydei25p8Y5aouR5vk_1790055304 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" From: Mika Penttilä Add calls to lazy_mmu_mode_enable() and lazy_mmu_mode_disable() while doing migration. Cc: David Hildenbrand Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: Alistair Popple Cc: Balbir Singh Cc: Zi Yan Cc: Matthew Brost Suggested-by: Alistair Popple Signed-off-by: Mika Penttilä --- mm/hmm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/hmm.c b/mm/hmm.c index a1459bd34c04..a67a23e54551 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -371,6 +371,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, /* Report error for everything else */ if (hmm_vma_walk->ptelocked) { + lazy_mmu_mode_disable(); pte_unmap_unlock(ptep, hmm_vma_walk->ptl); hmm_vma_walk->ptelocked = false; } else { @@ -394,6 +395,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, !is_zero_pfn(pte_pfn(pte))) { if (hmm_pte_need_fault(hmm_vma_walk, pfn_req_flags, 0)) { if (hmm_vma_walk->ptelocked) { + lazy_mmu_mode_disable(); pte_unmap_unlock(ptep, hmm_vma_walk->ptl); hmm_vma_walk->ptelocked = false; } else { @@ -413,6 +415,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, fault: if (hmm_vma_walk->ptelocked) { + lazy_mmu_mode_disable(); pte_unmap_unlock(ptep, hmm_vma_walk->ptl); hmm_vma_walk->ptelocked = false; } else { @@ -510,6 +513,7 @@ static int migrate_vma_split_folio(struct folio *folio, if (folio != fault_folio) folio_get(folio); + lazy_mmu_mode_disable(); pte_unmap_unlock(ptep, hmm_vma_walk->ptl); hmm_vma_walk->ptelocked = false; @@ -1135,8 +1139,10 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, if (minfo) { ptep = pte_offset_map_lock(mm, pmdp, addr, &hmm_vma_walk->ptl); - if (ptep) + if (ptep) { + lazy_mmu_mode_enable(); hmm_vma_walk->ptelocked = true; + } } else { ptep = pte_offset_map(pmdp, addr); } @@ -1178,6 +1184,7 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, flush_tlb_range(walk->vma, start, addr); if (hmm_vma_walk->ptelocked) { + lazy_mmu_mode_disable(); pte_unmap_unlock(ptep - 1, hmm_vma_walk->ptl); hmm_vma_walk->ptelocked = false; } else { -- 2.55.0