Received: by 10.223.176.5 with SMTP id f5csp1478137wra; Sun, 28 Jan 2018 01:57:13 -0800 (PST) X-Google-Smtp-Source: AH8x224hB2a1OqI2as9/pnN/3XiZo1+JpOGMKUzp0BA7XauE5tDMoFDTu3aNo45hw95qOJdpMdoN X-Received: by 10.98.60.67 with SMTP id j64mr23993306pfa.217.1517133432920; Sun, 28 Jan 2018 01:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517133432; cv=none; d=google.com; s=arc-20160816; b=yX7li5jhPzYuXUOjC3wMIRs9GpqIrwj0OZXnV9s0hBqTkzJw0RYQ0FpRzbQiWdsDi4 ekqDUz9bi6zsCrihe8ipol5yxlUqSSt9v4XOBNLLEtZjHOC3LFuRKXj0l7TBsbIt8Sc7 IFNbzsxzlnWgFE3NmUHi/q2LXG/faxPOryenpk6BQ6m3PZwGbfSHiuPuF6Hf1TZAgchA 5n0U+Jm0ULGooCmbxAnIq0DHZYgx4aElr3HIq5fyTZDGDsdSlr7a9r37iEHUceOHLEyu 6wcm7PYopMhh1Ke2xzXVTP8SYSyEygbzlTFoeX3DfWGNNy6tdYu8cCJXFyTLgcMCG4bM aTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=sMAxUxcQgqxsTDU8UfZUPyHEIMYmcRsKAxdYhDu8TVs=; b=UxeXeiqbrmmd+W6MpV7/ntaggxSo0u4voDBzhuGBYzJqZQg8RIVcG08FU+FPCUt0V4 2k3QnLMjZ5MwXFklRwXQIi9XXXt3qOB4IxGgDip3jnCbWaIqdMbV8WwAzjIAJA2Ga3q7 yERGP0K7/bZ1oCUsIRFHZo6/Zf2Ggm09ib/VuXbpi4xPt3Eo4dCkE4SaktClEsJ4iHNY +8btg6M3n0Y5o/yemnz3SoeSZAKVmsoozOVboXzqK8eOm0OX02nV9F/q/S1ArVXGXBaL GDdYGVXhNLpCUndjuwnh5+eA1z1nNuL+Mu6in5UzXoI8tAadAuyRFvD3wRTQig0Fiq9J PsKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SEJcCHte; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si2566152pgc.651.2018.01.28.01.56.45; Sun, 28 Jan 2018 01:57:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SEJcCHte; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbeA1J4Q (ORCPT + 99 others); Sun, 28 Jan 2018 04:56:16 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37827 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbeA1J4N (ORCPT ); Sun, 28 Jan 2018 04:56:13 -0500 Received: by mail-wr0-f194.google.com with SMTP id f11so4072097wre.4 for ; Sun, 28 Jan 2018 01:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sMAxUxcQgqxsTDU8UfZUPyHEIMYmcRsKAxdYhDu8TVs=; b=SEJcCHtefeta0QfQJlsjIzO27c2P8d/d6/xzJZUkdzzByeWw1TXVr49U5dH6EzKwhl AMIg/cYSndqkGI/KHF1ion/QU1YJW+q+lZBb+QmyaDYmjYTFS/a6sofC+VestUC4boPN vtvcdAX3bTNN2OG3yCVSNetvGx3nobSCTiIq0i+3Citd+s82cUZ/PEl6KjNMrmK+Dnul 9xeicUtugjukcQP8yhof82qveLMyksMU2xxmXyPW0ft+h4jr0uUaqEr1dxQPT/X1dnPk YBrhoxwCKsbHn8IcU3adZ8W52/8hd2KKNCmgKp2u2ZUnLFtvJZuocgRHd6uJFsPBotcx j/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=sMAxUxcQgqxsTDU8UfZUPyHEIMYmcRsKAxdYhDu8TVs=; b=lFq2+/cYQNZROTA+27F2q1V2k9YSidoniwB7AgNpPiYGPkD9CZSWOGhh+0Kj76S8Q1 2jBixe9BbWPZgha9lyJLj2k5qrMdhBITYYVaXfLlhm0daOI69Z4Oe7zkgTXVz0/MSGs5 qENzAesn3Hz+npsMbPZTOP78ZjWXyjEjg0cRr1hyeT3IuH98W/L2k97Q7yk5xmVhOmzz VbF/s1dYK0TxrOwmkGBW8T5+M0SVc/sXvHfqLDS5OOPj0ZgFJOhe8zv14rx0MiVYzMgq V5NZfO6VKKh+f1vX+FenksotEF+xdhHMlU54Ayt+zCL1L6U2ByjOk3T9TCN0JWrMQ/yI vLCg== X-Gm-Message-State: AKwxyteH6/C6LCN5z4mXpTgGDzb6nGGXOu6mWdAwYuaRzmJz/THVBHox Q1m5VWh1CBPcltbHstSRmpw= X-Received: by 10.223.191.7 with SMTP id p7mr10787955wrh.34.1517133372732; Sun, 28 Jan 2018 01:56:12 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id f76sm6109597wme.2.2018.01.28.01.56.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 01:56:11 -0800 (PST) Date: Sun, 28 Jan 2018 10:56:09 +0100 From: Ingo Molnar To: Tim Chen Cc: linux-kernel@vger.kernel.org, KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Peter Zijlstra , rkrcmar@redhat.com, Thomas Gleixner , Tom Lendacky , x86@kernel.org Subject: Re: [PATCH v2] x86/ibpb: Skip IBPB when we switch back to same user process Message-ID: <20180128095609.rfcnv3itu3clrkru@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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 tip:master. Thanks, Ingo