From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30A7B343886 for ; Tue, 4 Aug 2026 04:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785817654; cv=none; b=UqJQ9dhO16SjRecWSu+QRvlHwZCyDYCgix0UqKsblGUQHmUndcVw4fe2swodsnE33zataJaRvF4/TwI5bGNY1iTPO9pQZswh3Y69gjglXRMFFZvFHVCC0puaAWerzrDbmR4OaxhaXmBgDUuLSlafEl0vQuR859vCFCAalNrDhfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785817654; c=relaxed/simple; bh=t/Qv0M4+uVMUbM4q8mIjTJxHj9K9KeCjzK5Bua9wiQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hZyht7bRy8Jy7AmedeuSpQIoomahuS7n6I3MBC0Y2PzF6ENCpXyZBmRuCJfVyLp/fmiCWwiLxtiv3bFqDitF9jWk99yHnVXi4b/VEhxQPTvbKQzWIvswR48PbLqF3cmA8WKv8EgFz3qNeZfbqn1v7RRcFeQt02O8YR4XggQNji8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Lkj5FDX7; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=LrjVYUx/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lkj5FDX7"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="LrjVYUx/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785817652; 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=lxWvLz6f1rN1o4scxqJnXGGSQRdc4CCCHPneXFEhe/4=; b=Lkj5FDX7aTCGZr8HUVe4QfoBGDDtkJRQ8iQHkg2yTBD9nTNInzyceJ2sMMZgUem9aMsFNg ZgRyWuixMEHAcWAB1z8858ZjPREa8Xi7lM2sAXVLf0sSjN4vJG1dR599qKx2Kdj0+wwhLh 9GDTa+NEaUBiZ0Zecjh8irkjZQzzwjM= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-270-dB-l48N3Pb-jJ3OY0fth6w-1; Tue, 04 Aug 2026 00:27:30 -0400 X-MC-Unique: dB-l48N3Pb-jJ3OY0fth6w-1 X-Mimecast-MFC-AGG-ID: dB-l48N3Pb-jJ3OY0fth6w_1785817649 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5b2d7c7ec76so1826114e87.1 for ; Mon, 03 Aug 2026 21:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785817648; x=1786422448; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lxWvLz6f1rN1o4scxqJnXGGSQRdc4CCCHPneXFEhe/4=; b=LrjVYUx/ngAnE64IvAe65ZsDujmCB18JmdWa26xOjp98aTk3YWx/SFtaZKVkCx0P/i FAbEClij4rdvoNNiAVyS1CZ4wXb+3SV2ptFcoNkDQPAIL0g4ptzCjb3YkHscx1vipSLs JtVao23B5QgARR/PLbz66VmSW2EmHXiTSbV14dmgFRfC27fGhkakIMT4R9P9MU/bdaxp wenfPhoDJ/HdZ4UUe2k0RfqkBooBZPTbKGZoBct+STdh//8eV5IK0oLgjlskgEcP7lei PaCfxkRaUftfn/2qIA0GAA3fMm0fqNY7+iwbBPVRRMitg/ZHww8y7eLimpmJQSFHmZDq quhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785817648; x=1786422448; 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=lxWvLz6f1rN1o4scxqJnXGGSQRdc4CCCHPneXFEhe/4=; b=U56k5ByD0W+E7Ec9muS2KIhsaCxTHXT1wQ7hI4kx9MX32LIpfnlXE3rdYld59QB2Gj 3QGfzXfJVD61F7phA6Tur2whzIpya5uL1dd9TDizHus9g66FRzveczuyUsg5ELc2ddMc OyB8/h62hu73RgBTAfiAhHIazSEf9+TwDj7qBSBpVhqUo5srP2n7J/vDn4kpw1GQGqA4 n46nwSRg6YJ3mgDxnMGcaMVVaC3tF0oQQREF6lL9jpUhMgJbr/8OKkmhgmpXpvFBaMRu DaVLId0HwjzHhOt5IqvQsmswqglDqXnUSu+HSr5aVFe04qn0MEZrE6D5kwuGeTgfDB8Q UuOg== X-Forwarded-Encrypted: i=1; AHgh+RoJuU7Z5az4A8DdxmSw5ctAaoPYVRCiMSejwk4MrhoYL0w+aQUsXDGscfw19s0Dze1HhVBFgDpwKKzNufM=@vger.kernel.org X-Gm-Message-State: AOJu0YyYpIRvVZ/BK/Y+befGWnvX1nsjO3Jglppmvwrtik3//tcWqq/z 63qnpGovljS9iNWmeheA94gqDz4JuMAHUuZ82teiTXtsWhNomnlmxikexAUeO1+7qvfrO+Min4O GWN6LlCM0G+RtMnnWpgL8/Iqzhlkdqiq3jCZPxlFGvmqKp56GTV7GP94saseWcOP/qIT2ipUBdB 0= X-Gm-Gg: AR+sD119qlGrS1Iej9ux4bsKRiWIZHc16VIXukFKKHXGniqjeToVrAxgHHJrujRCO4U /3ABpRVddXImgmDRgvld7PsNL82hrqPWAwC2IL7fk/FVgHkEcoxcL42tk3qd63Qr/R6FF6uUvls 7e6jhwatiuZyb7i0gTgUN0aI8ApvcV4bzv2KaLmItExywJwjpz/hDZgchqvM6T/TU1VOJX1XdZL jvUUdNTTEJYtU+qru5OXzWC9WoDpR2H+VMmZY6DMShOvRutUK/mHvHXiPT/y1IQY5nrn3cfNNAO X9QtldocNK/t+Ruemh1q9M4fkyN3l5dT1r2+AGEktF6tF8h7fi/4ywyKwPDgSBxvQDWz+la7MIt uzVByqeWBuE7VfTxL X-Received: by 2002:a05:6512:8051:b0:5ae:b86b:71ee with SMTP id 2adb3069b0e04-5b2e4f6d5c4mr1858466e87.38.1785817648605; Mon, 03 Aug 2026 21:27:28 -0700 (PDT) X-Received: by 2002:a05:6512:8051:b0:5ae:b86b:71ee with SMTP id 2adb3069b0e04-5b2e4f6d5c4mr1858457e87.38.1785817648175; Mon, 03 Aug 2026 21:27:28 -0700 (PDT) Received: from fedora (85-23-51-1.bb.dnainternet.fi. [85.23.51.1]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b2e23c46c4sm2311351e87.17.2026.08.03.21.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 21:27:26 -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 v13 08/11] mm/hmm: add lazy MMU mode support for migration in HMM pagewalk Date: Tue, 4 Aug 2026 07:26:28 +0300 Message-ID: <20260804042631.2175585-9-mpenttil@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804042631.2175585-1-mpenttil@redhat.com> References: <20260804042631.2175585-1-mpenttil@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 61b9147fd8ed..631f6b4d52fc 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -368,6 +368,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 { @@ -391,6 +392,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 { @@ -410,6 +412,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 { @@ -507,6 +510,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; @@ -1132,8 +1136,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); } @@ -1169,6 +1175,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