Skip to content

Commit 5e65b5c

Browse files
compudjakpm00
authored andcommitted
tsacct: skip all kernel threads
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. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mathieu Desnoyers <[email protected]> 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]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e8eef69 commit 5e65b5c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/tsacct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void __acct_update_integrals(struct task_struct *tsk,
125125
{
126126
u64 time, delta;
127127

128-
if (!likely(tsk->mm))
128+
if (unlikely(!tsk->mm || (tsk->flags & PF_KTHREAD)))
129129
return;
130130

131131
time = stime + utime;

0 commit comments

Comments
 (0)