From nobody Sun Feb 8 09:13:12 2026 Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.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 D6ADB26C3A2 for ; Wed, 24 Dec 2025 17:38:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=158.69.130.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766597899; cv=none; b=eBhEYX/GtaO4iWV3VNFSYbcKnEBcg7Nj1xOH4GCn0d40y/UIT3ifmH3r52vgfusXt+fV+oTGc9fG019lwIlg4vkCSXsxR/xzp9B0dwOX60Tpjq5RM267h8Eiqo50jfihUffDKRuBUGBujpdkqlG7sS99yr89aSg4RcDAtlFemkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766597899; c=relaxed/simple; bh=6pYfUraI6xJWAerjPxPZ9xbtgjBFwKODwgIUaDKDERg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iyOdQ3O40HuBd6/J+P0yVg8wE2FMvtgWFKK2UGRWfXnuPwK+QA1W3RYaYDLMLFuOhMmmYjmv2MufR18fSnfRpscbx2DSauCd0IlPiOVLLWGFPm/vAJU7oW87tYTLDldtd9mL7d3IpA3QiDor5NzY4im1u6FxXWtl9gR1H+pw9B0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=Kyc82Oa/; arc=none smtp.client-ip=158.69.130.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="Kyc82Oa/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1766597897; bh=WYwEBLSq3Xu0Bb48syjU2NlyMoZA1eVYenXZFn1Sm4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kyc82Oa/VOQLyVO+gGGs9HkFXez/2+guEVdfui5v984mZFlr/D55Mi3Qaqm8G6slM TVI0uS3vd7ISHi/3nhBScUkW8AFSK29emStu8ovjbRPXxjAi5JDv5tRN800tah1JPe tdDetBfzqZzlapGA73mR+EMpbyBa8T2xb4ycivJvwF4HSqkDOv24pnQl1n+p7re39K r/zX4kOOwKy9MDogr9hux1qOZnBr4MQJZg18MqNzjLcmaWIIwX5tJG2130HpxhoHBt WVG5BSuTxd29Ye+R9vEUZIp2XBRWx/6jBQUAoMkZ20viJir8Kdufrijw9kgKskVFrP cnJb0/EBDzFnQ== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4dbzcS6tbdzfKv; Wed, 24 Dec 2025 12:38:16 -0500 (EST) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Mark Brown , linux-mm@kvack.org Subject: [PATCH 1/1] tsacct: Skip all kernel threads Date: Wed, 24 Dec 2025 12:38:10 -0500 Message-Id: <20251224173810.648699-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251224173810.648699-1-mathieu.desnoyers@efficios.com> References: <20251224173810.648699-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Cc: Andrew Morton Cc: Mark Brown 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; =20 - if (!likely(tsk->mm)) + if (unlikely(!tsk->mm || (tsk->flags & PF_KTHREAD))) return; =20 time =3D stime + utime; --=20 2.39.5