Skip to contentSkip to conversation

tsacct-skip-all-kernel-threads.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jan 21

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: tsacct: skip all kernel threads
has been removed from the -mm tree. Its filename was
tsacct-skip-all-kernel-threads.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Mathieu Desnoyers <[email protected]>
Subject: tsacct: skip all kernel threads
Date: Wed, 24 Dec 2025 12:38:10 -0500

This patch is a preparation step for HPCC, for the OOM killer improvements. I suspect that this patch is useful on its own, because it really makes no sense to sum up accounting statistics of use_mm within kernel threads which are only temporarily using those mm.

When we hit acct_account_cputime within a irq handler over a kthread that happens to use a userspace mm, we end up summing up the mm's RSS into the tsk acct_rss_mem1, which eventually decays.

I don't see a good rationale behind tracking the mm's rss in that way when a kthread use a userspace mm temporarily through use_mm.

It causes issues with init_mm and efi_mm which only partially initialize their mm_struct when introducing the new hierarchical percpu counters to replace RSS counters, which requires a pointer dereference when reading the approximate counter sum. The current percpu counters simply load a zeroed atomic counter, which happen to work.

Skip all kernel threads in acct_account_cputime(), not just those that happen to have a NULL mm.

This is a preparation step before introducing the hierarchical percpu counters.

Cc Mark Brown <[email protected]>
Cc Aboorva Devarajan <[email protected]>
Cc Al Viro <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Christan König <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "Liam R . Howlett" <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Martin Liu <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mateusz Guzik <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Miaohe Lin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Sweet Tea Dorminy <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Wei Yang <[email protected]>
Cc Yu Zhao <[email protected]>

---

 kernel/tsacct.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/tsacct.c renamed from kernel/tsacct.c~tsacct-skip-all-kernel-threads +1 -1
@@ -125,7 +125,7 @@ static void __acct_update_integrals(stru
 {
 	u64 time, delta;
 
-	if (!likely(tsk->mm))
+	if (unlikely(!tsk->mm || (tsk->flags & PF_KTHREAD)))
 		return;
 
 	time = stime + utime;

_

Patches currently in -mm which might be from [email protected] are

mm-fix-oom-killer-inaccuracy-on-large-many-core-systems.patch