On Mon, Jul 20, 2020 at 06:00:50PM +0100, Dave P Martin wrote: > On Mon, Jul 20, 2020 at 04:30:35PM +0100, Kevin Brodsky wrote: > > On 15/07/2020 18:08, Catalin Marinas wrote: > > >+void mte_thread_switch(struct task_struct *next) > > >+{ > > >+ if (!system_supports_mte()) > > >+ return; > > >+ > > >+ /* avoid expensive SCTLR_EL1 accesses if no change */ > > >+ if (current->thread.sctlr_tcf0 != next->thread.sctlr_tcf0) > > > > I think this could be improved by checking whether `next` is a kernel > > thread, in which case thread.sctlr_tcf0 is 0 but there is no point in > > setting SCTLR_EL1.TCF0, since there should not be any access via TTBR0. > > Out of interest, do we have a nice way of testing for a kernel thread > now? > > I remember fpsimd_thread_switch() used to check for task->mm, but we > seem to have got rid of that at some point. set_mm() can defeat this, > and anyway the heavy lifting for FPSIMD is now deferred until returning > to userspace. I think a better way is (current->flags & PF_KTHREAD). kthread_use_mm() indeed changes current->mm. -- Catalin