From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8D7733A9629; Fri, 4 Sep 2026 05:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500373; cv=none; b=X8Wrch4qR7vZE4Dg3RO6oygfDUnNhmW9LZdNkp7DtmsQMZNJ6TCmJAwwnAImn0SBSraFfBE50iGuvxGUxvhf52gflGv76s6s6H0MI5PGuNALB34E6HeapWJ/VqW2JZx2gG2hvxJRFFwfz36U/Mc38HiP9+y+MKb1eZIh2ai9BKw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500373; c=relaxed/simple; bh=bImzgPG5FxmK0+WoQz2Nh6qO6cTtyRi4HIJ87L7tSJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SR7ZvD+WE9eyph5gCrXlkU/pdtK2Fxokxcs5nIL3DoABN4gQDNdyM3/EJkOIu7fNIztHtmjMZSjAgGfCqW4SuegVrt8S8UbWKm+9KN4g/LBAIk7ffITDNCFzlinpNd4eM49qurQkQ2l2/VW7G/9H8MfFbE/mbDHJl6M27teC2hk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=u3hypK+T; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="u3hypK+T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F8891F00A3D; Fri, 4 Sep 2026 05:39:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788500372; bh=3B+JNRS9AWVaEWAG1/6XM2pX9naTNb+07HCT1tfMOhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u3hypK+TonAl/qdVw8UxnDDZmHMQZcHBZLfcXBTtM6lKfTMK1I2Xmow5NAkL6HVdc jFct00WrIcLrmzQGTch3G85/S2CUlhW2iHtBWAM1kOWrZDto9DVcEgWt+jVOXhNd2m jmvbRgUe0KV5d8TT+PiQWUOWwx4A3zSnEbjrVHKk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Zi Yan , Gregory Price , "Paul E. McKenney" , "David Hildenbrand (Arm)" , Alistair Popple , Byungchul Park , "Huang, Ying" , Joshua Hahn , Matthew Brost , Rakie Kim , Andrew Morton Subject: [PATCH 6.18 034/552] mm/migrate: report RCU-tasks quiescent states in migrate_pages_batch() Date: Fri, 4 Sep 2026 06:53:11 +0200 Message-ID: <20260904045748.601670766@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045747.813364717@linuxfoundation.org> References: <20260904045747.813364717@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao commit efe8f86c0916f0f74eea74ae21a3b37f728c6bad upstream. migrate_pages_batch() unmaps each folio before moving it, and every unmap runs the mmu_notifier invalidate callbacks. On KVM hosts try_to_migrate() ends up in kvm_mmu_notifier_invalidate_range_start() -> tdp_mmu_zap_leafs(), which is expensive, so unmapping a large batch keeps the CPU busy for a long time. The loop already calls cond_resched(), but on PREEMPTION kernels that is a no-op, and involuntary preemption is not a Tasks-RCU quiescent state. A long batch therefore never reports a quiescent state, and the migrating task (e.g. kcompactd) becomes a Tasks-RCU holdout, stalling the Tasks-RCU grace period for minutes, which is common at Meta fleet: INFO: rcu_tasks detected stalls on tasks: 0000000055349ecc: .. nvcsw: 1157401/1157401 holdout: 1 idle_cpu: -1/56 task:kcompactd0 state:R running task Call Trace: tdp_mmu_zap_leafs tdp_mmu_next_root gfn_to_pfn_cache_invalidate_start kvm_mmu_notifier_invalidate_range_start __mmu_notifier_invalidate_range_start try_to_migrate_one try_to_migrate migrate_pages_batch migrate_pages compact_zone compact_node kcompactd kthread Use cond_resched_tasks_rcu_qs() so a quiescent state is reported even when cond_resched() does nothing. This has also been discussed at [1] Link: https://lore.kernel.org/20260727-kcompact-v1-1-bdfefddd6874@debian.org Link: https://lore.kernel.org/all/amdWVTs0WKOxguxP@gmail.com/ [1] Signed-off-by: Breno Leitao Acked-by: Zi Yan Reviewed-by: Gregory Price Reviewed-by: Paul E. McKenney Acked-by: David Hildenbrand (Arm) Cc: Alistair Popple Cc: Byungchul Park Cc: "Huang, Ying" Cc: Joshua Hahn Cc: Matthew Brost Cc: Rakie Kim Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1821,7 +1821,7 @@ static int migrate_pages_batch(struct li is_thp = folio_test_pmd_mappable(folio); nr_pages = folio_nr_pages(folio); - cond_resched(); + cond_resched_tasks_rcu_qs(); /* * The rare folio on the deferred split list should