Re: [Patch v4 01/22] sched/cache: Introduce infrastructure for cache-aware load balancing

From: Chen, Yu C

Date: Tue Apr 14 2026 - 23:35:28 EST


On 4/15/2026 10:06 AM, Vern Hao wrote:
Hi Tim,


[ ... ]

+
+static inline
+void account_mm_sched(struct rq *rq, struct task_struct *p, s64 delta_exec)
+{
+    struct sched_cache_time *pcpu_sched;
+    struct mm_struct *mm = p->mm;
+    unsigned long epoch;
+
+    if (!sched_cache_enabled())
+        return;
+
+    if (p->sched_class != &fair_sched_class)
+        return;
+    /*
+     * init_task, kthreads and user thread created
+     * by user_mode_thread() don't have mm.
+     */
+    if (!mm || !mm->sc_stat.pcpu_sched)
+        return;
+
+    pcpu_sched = per_cpu_ptr(p->mm->sc_stat.pcpu_sched, cpu_of(rq));

I do some test,  when i see many pids schedstat,  such as  cat proc/xxx/ schedstat, there will cause a panic,maybe the 'p' is exit or others reason,  sorry, i dont record these msg.  how about fix it like below.

pcpu_sched = per_cpu_ptr(mm->sc_stat.pcpu_sched, cpu_of(rq));


Right, we have also received a report at
https://sashiko.dev/#/patchset/cover.1775065312.git.tim.c.chen%40linux.int.com
indicating that this issue needs to be fixed. We are working on it.
Thanks for the investigation.

thanks,
Chenyu