Received: by 10.223.176.46 with SMTP id f43csp2631502wra; Thu, 25 Jan 2018 12:47:20 -0800 (PST) X-Google-Smtp-Source: AH8x226b6Dqq45t+5QNBwRYA7bt4c8967p7iI9S33/w+9F3Nxm8dmgnTX/RFnE9yvmlV60CCxVc8 X-Received: by 10.98.11.17 with SMTP id t17mr17150274pfi.201.1516913240596; Thu, 25 Jan 2018 12:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516913240; cv=none; d=google.com; s=arc-20160816; b=NPJe5JyKNKrBzv1fcB/KsbD1UcWN7JESdUUgpG/OnasGuYPlkNXUL5v/4/ZlVYRrTQ ZR/VyE4YkQkJyTyO6kOemYv2Qz35CfN9QFmauFlItrJmaoi7GSuwwFnP+PcML+WM/zvW ePvuXyoDrTvBQX6Nadfh6tR4TY+ejhlax1D3v0US5vvvtksirP+H8H5LZmDrvZK4QcYw VhCrj1JFLqIorRRhut1TDADYI9V/RsUKp2S/JuvNW0TQNEnQVorAzDoPmWsiqCuVNmNs GsvHM6Dp4/e21ob3DVGKdpnt7yeCQgR4aLuFdcug50kHYYwiJwgaJln7VaJkgvfC0yVF S2Pw== 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=VFe9oGhvVlc7Tlvy7rbVMV1qhLBpahgG984CbZIvz2c=; b=fUeUhTulxqEV+PD/cBO2TMbo9ioYKFkSNkJCjrHfuF1WMdHjAR+wOhwzFVUONj0EHm cA5oDvQeYUZTuxpiqm7QfGHCo5WFF2eHxjtPj+ApyZMUQ75tQ8eSkVQsmS6iJQ9+Smx2 2Cb0ZK2l+RJn5V7F9kQwf9ssO1sc1fSOTtlBd3YR4ebyCbTAGET52/GB5l/QcRDSKv4X +1BKNzx/OD9qNGV6XV6Sb68wky6eGHq34k66HaK/etWSmVxywnltrr+7uKKssdkzuq6v ZcZUyzY4pCHaCkPWAomYR4gzeVdAQPXMR5Xyboljx1B1m/5H5UVo3Kf+BBz6IwNSsViP MUKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Xc2NHS/O; 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 u23-v6si2565037plk.516.2018.01.25.12.47.02; Thu, 25 Jan 2018 12:47:20 -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=@infradead.org header.s=bombadil.20170209 header.b=Xc2NHS/O; 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 S1751220AbeAYUqj (ORCPT + 99 others); Thu, 25 Jan 2018 15:46:39 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:37461 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbeAYUqi (ORCPT ); Thu, 25 Jan 2018 15:46:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VFe9oGhvVlc7Tlvy7rbVMV1qhLBpahgG984CbZIvz2c=; b=Xc2NHS/OC9KoO4uSB82TjMqpB Evy7h165tbmwXnHjWH5nr6rYdaFYtOQtgF06Y0newkBC8qJtVitpeRwEf8PmGq9nwfN6N8ioQHX00 sFAMuKN3pbW4JRgrTJkxx2BSxQMrZ3QNRaFQGzLMNzIU6eFJ6C5b/9cfWDe5vpVhAigO4W9F4Mkgk UiXoGex7nfU5AHPbloxkjmgOhVUFs+Jz/mDbzeipdXigf25x5QdIXTmGagqCPdKl8/mdI6VeBPaNo p82AUc0HJorsJYp3660ylyA4wYk+SXQFd1+Uz6xlSqtgz5K59ny/Uvl64y9AmzBso2Rg8zAya7tgn ToZmufHXw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eeoPk-0006B0-7l; Thu, 25 Jan 2018 20:46:28 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3093F2029B0FD; Thu, 25 Jan 2018 21:46:25 +0100 (CET) Date: Thu, 25 Jan 2018 21:46:25 +0100 From: Peter Zijlstra To: Tim Chen Cc: Andy Lutomirski , Arjan van de Ven , LKML , KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , 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 , Radim Krcmar , Thomas Gleixner , Tom Lendacky , X86 ML Subject: Re: [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process Message-ID: <20180125204625.GN2269@hirez.programming.kicks-ass.net> References: <20180125085820.GV2228@hirez.programming.kicks-ass.net> <20180125092233.GE2295@hirez.programming.kicks-ass.net> <86541aca-8de7-163d-b620-083dddf29184@linux.intel.com> <20180125135055.GK2249@hirez.programming.kicks-ass.net> <20180125164139.GM2269@hirez.programming.kicks-ass.net> <20180125181852.GL2249@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 25, 2018 at 11:32:46AM -0800, Tim Chen wrote: > > This patch is not ideal as it comes with the caveats that > patch 2 tries to close. I put it out here to see if it can prompt > people to come up with a better solution. Keeping active_mm around would > have been cleaner but it looks like there are issues that Andy mentioned. > > The "A -> idle -> A" case would not trigger IBPB if tlb_defer_switch_to_init_mm() > is true (non pcid) as we does not change the mm. > > This patch tries to address the case when we do switch to init_mm and back. > Do you still have objections to the approach in this patch > to save the last active mm before switching to init_mm? I still think the existing active_mm is sufficient. Something like: switch_mm() { ... if (prev && next != prev) ibpb(); ... } should work. Because while the idle crud does leave_mm() and PCID does enter_lazy_tlb() and both end up doing: switch_mm(NULL, &init_mm, NULL), nothing there affects tsk->active_mm. So over the "A -> idle -> A" transition, active_mm should actually track what you want.