This means that you are in the kernel thread.
In linux, kernel threads do not have a mm structure. The kernel thread takes mm from the previous user thread and writes it to active_mm. So you should use active_mm instead .
More details:
in / kernel / sched / core.c you can find the following code:
static inline void context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next) { ... if (!mm) { next->active_mm = oldmm; atomic_inc(&oldmm->mm_count); enter_lazy_tlb(oldmm, next); } else switch_mm(oldmm, mm, next); ... }
If the next thread does not have mm (kernel thread). The scheduler would not switch the millimeter and would simply reuse the millimeter of the previous thread.
source share