From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 8C4643FFFA7 for ; Mon, 27 Jul 2026 13:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785160243; cv=none; b=YvB2gxLdtJWc47epU2K0XJ4jMKMdQtG+pqDWKo9d0NeYl143/+KlTqqIIXNX6EDn/Pn57OsN9Y8PJob2B+40iHb+mMW6yXmUxkzYdIvVWGvhZttfADizxr+pp1viFcWzHf1vsq9WHZXlV/KFlXDNrlF8uNCOAwgGYyV+cSmgKp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785160243; c=relaxed/simple; bh=4F8yLxC+1awu82XnfTaO7vCW1QjPo6xO5LUWzXQAoIs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=Rvi3Uwvu2UOvhBCLE0gPlZoyH74j/ANpIlDo2HeIHZFZiZyI4McoVgaHQ7mw9fy1d38lFGgpwQLrJ7lP9oIvU1pmIibY8dsvQ1ZOuf4P1dR8MphOI2NM833VegsHjOCkyArqT5Hl7MJibvBlJf08/dj+8Bp3QUqR1jHrKo3mzTY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=m5QDCRHM; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="m5QDCRHM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=+6V3TdS0YDSjUJhRfZObdautWIi5ma3BndxnY6cBifE=; b=m5QDCRHMeWDFpZJSbFbV/Tqw6F jXnu+vOBupe8oScOnAMlxHUqgZpBcfzSMFZpsowaIGv9NLN5aA2EaTLteok62WRKetJAvCZZukuDa bA7sbBtojBOGIk1wgw9y97kaBHUKw93itPnJI1f9qwPt5IFJxtOmAKj6Wmwy49RD8NA5Vvr8T52gq Gry4NnhcYz7+ECrY82JETtJH9HCnXvBm4gHVnuLm2aVG0wcoU00y4IzFt4MIZTGdu3xXvhbzRmpTt 6TJfSz+5iUKt0RHh32aLOHhC/zAfLuvzzJNKpW7Rw1lTe73KcMZqc9/19ssdnnhJHTQ/isLRraeiW Jn+6/HBg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1woLiq-006wTB-1J; Mon, 27 Jul 2026 13:50:25 +0000 From: Breno Leitao Date: Mon, 27 Jul 2026 06:50:19 -0700 Subject: [PATCH] mm/migrate: report RCU-tasks quiescent states in migrate_pages_batch() 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: 7bit Message-Id: <20260727-kcompact-v1-1-bdfefddd6874@debian.org> X-B4-Tracking: v=1; b=H4sIABpiZ2oC/x3MUQqAIBAFwKss7zthEyzwKtFH2VpLZKERQXT3o DnAPCiSVQo8PchyadE9wVNdEcIypFmMTvAEy7bh1rZmDft2DOE0MbJzHAPLOKIiHFmi3n/V9e/ 7ATNfINhaAAAA X-Change-ID: 20260727-kcompact-ff0550fc0ebb To: Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , paulmck@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2086; i=leitao@debian.org; h=from:subject:message-id; bh=4F8yLxC+1awu82XnfTaO7vCW1QjPo6xO5LUWzXQAoIs=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqZ2Ict8M+uRryQAOiTXZWQuoTGZCqac/XH429v vfWLwbJ3D6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCamdiHAAKCRA1o5Of/Hh3 bVJgEACns/hBBLj1C0xnU4aeQ4PXCGgCyJM9z29He1siJFODaAKsUB/bxBNbE510LyRIKTloTVW 01XjgrVJxlg+srXTP8FK9O/G/rwFDDt3uSohuG/jTN8J/sA4Cm6tqZuROe3tG89TN4DAgVc6n2/ I+iq/LM0CCiMQ/8LJ4O91+aOElQSAeADWUC6pJiF+8G/zU1dObu/fP2Bd7F4NLBIqZvNbqnlqYG oLqaIQkzFa/lZrBejbJV1GKmSt7wrFhkzG6ajtIOoEGR6J/tVTxO6+iq1l13P531qz+31UGzdhC JXTjisDasNwB6BKPLwDe6zt9qvJ/Zjx0LY5dtDhgP7lfavom6vKYmpC4SuVliyeb/IGwN7pgWj1 Sbo2DkD2EL3DytrLseKnlK43SrcFNAyI1SPoqg6WWje388LW20fKcqRswo7FNla1oBRN/1JpjMq Os8Az6SiYM5j5MVbWMpL+2cV4fX1DmmRWVZRdjEQfRICMCezsfMJovzdSTlda+v8O+WLLlvygVy N1uI20WuB1ILAXkfoSE10N1H9x7eU5wwJgnwaMMtLaMFYhP1wLymvQ3h333nAQ+cHmrwiKj1Nw9 JscKdBzmmg5HKfUlzDIX+Ng5wI4X6z4bkm1tmTP7nsh824Xg+dv/ShoVtIO10SgG16yibGUfobF MOz8rbFF6/Bq4Cg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao 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. PS: This has also been discussed at [1] Link: https://lore.kernel.org/all/amdWVTs0WKOxguxP@gmail.com/ [1] Signed-off-by: Breno Leitao --- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index ab15a4dddd047..b937cbd764808 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1843,7 +1843,7 @@ static int migrate_pages_batch(struct list_head *from, 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 --- base-commit: c5e32e86ca02b003f86e095d379b38148999293d change-id: 20260727-kcompact-ff0550fc0ebb Best regards, -- Breno Leitao