On Tue, Mar 04, 2025 at 03:11:34PM +0100, Borislav Petkov wrote: > On Tue, Mar 04, 2025 at 12:52:47PM +0000, Brendan Jackman wrote: > > https://lore.kernel.org/all/CA+i-1C31TrceZiizC_tng_cc-zcvKsfXLAZD_XDftXnp9B2Tdw@xxxxxxxxxxxxxx/ > > Lemme try to understand what you're suggesting on that subthread: > > > static inline void arch_start_context_switch(struct task_struct *prev) > > { > > arch_paravirt_start_context_switch(prev); > > tlb_start_context_switch(prev); > > } > > This kinda makes sense to me... Yeah so basically my concern here is that we are doing something that's about context switching, but we're doing it in mm-switching code, entangling an assumption that "context_switch() must either call this function or that function". Whereas if we just call it explicitly from context_switch() it will be much clearer. > > Now I think about it... if we always tlbsync() before a context switch, is the > > cant_migrate() above actually required? I think with that, even if we migrated > > in the middle of e.g. broadcast_kernel_range_flush(), we'd be fine? (At > > least, from the specific perspective of the invplgb code, presumably having > > preemption on there would break things horribly in other ways). > > I think we still need it because you need to TLBSYNC on the same CPU you've > issued the INVLPGB and actually, you want all TLBs to have been synched > system-wide. > > Or am I misunderstanding it? Er, I might be exposing my own ignorance here. I was thinking that you always go through context_switch() before you get migrated, but I might not understand hwo migration happens.