[lkml]   [2018]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v2] x86/ibpb: Skip IBPB when we switch back to same user process

* Tim Chen <> wrote:

> Thanks to the reviewers and Andy Lutomirski for the suggestion of
> using ctx_id which got rid of the problem of mm pointer recycling.
> Here's an update of this patch based on Andy's suggestion.
> We could switch to a kernel idle thread and then back to the original
> process such as:
> process A -> idle -> process A
> In such scenario, we do not have to do IBPB here even though the process is
> non-dumpable, as we are switching back to the same process after
> an hiatus.
> We track the last mm user context id before we switch to init_mm by calling
> leave_mm when tlb_defer_switch_to_init_mm returns false (pcid available).
> The cost is to have an extra u64 mm context id to track the last mm we were using before
> switching to the init_mm used by idle. Avoiding the extra IBPB
> is probably worth the extra memory for this common scenario.
> For those cases where tlb_defer_switch_to_init_mm returns true (non pcid),
> lazy tlb will defer switch to init_mm, so we will not be changing
> the mm for the process A -> idle -> process A switch. So
> IBPB will be skipped for this case.
> v2:
> 1. Save last user context id instead of last user mm to avoid the problem of recycled mm
> Signed-off-by: Tim Chen <>
> ---
> arch/x86/include/asm/tlbflush.h | 2 ++
> arch/x86/mm/tlb.c | 23 ++++++++++++++++-------
> 2 files changed, 18 insertions(+), 7 deletions(-)

What tree is this patch against? It doesn't apply to linus's latest, nor to



 \ /
  Last update: 2018-01-28 10:57    [W:0.036 / U:11.548 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site