* [PATCH 0/1] Hierarchical percpu counters preparation
@ 2025-12-24 17:38 Mathieu Desnoyers
2025-12-24 17:38 ` [PATCH 1/1] tsacct: Skip all kernel threads Mathieu Desnoyers
0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2025-12-24 17:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Mathieu Desnoyers, Mark Brown, linux-mm
Hi Andrew,
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.
Thanks,
Mathieu
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-mm@kvack.org
Mathieu Desnoyers (1):
tsacct: Skip all kernel threads
kernel/tsacct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] tsacct: Skip all kernel threads
2025-12-24 17:38 [PATCH 0/1] Hierarchical percpu counters preparation Mathieu Desnoyers
@ 2025-12-24 17:38 ` Mathieu Desnoyers
0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2025-12-24 17:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Mathieu Desnoyers, Mark Brown, linux-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.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-mm@kvack.org
---
kernel/tsacct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 6ea2f6363b90..5c153106e642 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -125,7 +125,7 @@ static void __acct_update_integrals(struct task_struct *tsk,
{
u64 time, delta;
- if (!likely(tsk->mm))
+ if (unlikely(!tsk->mm || (tsk->flags & PF_KTHREAD)))
return;
time = stime + utime;
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-24 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-24 17:38 [PATCH 0/1] Hierarchical percpu counters preparation Mathieu Desnoyers
2025-12-24 17:38 ` [PATCH 1/1] tsacct: Skip all kernel threads Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox