Received: by 10.223.176.46 with SMTP id f43csp2561479wra; Thu, 25 Jan 2018 11:47:16 -0800 (PST) X-Google-Smtp-Source: AH8x226wk2Cs7vkeHw8sm1WYxtT6hlhu/8a7p5ZnYXntsGbRa/5FyFCyQwGuT4PtjbVbiJNuOH+h X-Received: by 10.99.97.69 with SMTP id v66mr14548230pgb.307.1516909636760; Thu, 25 Jan 2018 11:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516909636; cv=none; d=google.com; s=arc-20160816; b=leF1Bd/1d6qRuSzVP5pkI6WKfQDysPyVHWmO5c1StVJ/itBP/csL7xZoutbqvsM0t8 QGwh7QMr4nOEF9qI9cnUjKtSHq/kFqpuBcDzrHLyQeNWJx5rOwz3YI5+CpIaweq5+3CY A+agolp78j3Nfj/lISbd8d3Th52wgSw0IPhx0pKz3sup3mHHoTLnSJpYabpT8GRBalV6 K3GKA+qOFvuES7VYkmQm85zujD/9zImT03jrAjqklozHe0Qvrxehb0Ucr4UK4BpIS0tQ 2S0ljDM4KwukgF1Rc+ZPpaQSZUbtp/alrb2cyVG5ERkvwMzJufsTlSeopWOObcnRCjGH opaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=f17nl83Xo506b+Rf80a55gzyXSNuzmRJAakbIYdIs7Y=; b=eyQV/mZJo3tfQrjhu1UxFzWd+ZjJgS6BG8g5Q2GVqCtkFfaWt9Ht6qo634YZIah5xD 2ewMQWDNNsqTh6c8KaCE8UP5Iq514+e5frshllf0JmniRJU6NJJBuMWlIIo+wj0xRuwD g0j8zy578BTKpF+bSah3fqOj6oLML4lblHmAkyYBLqXfALfNJuhsflJpV1g9UG9i0DfC sxwIDShvqV/YGxWyeYolURuvb3vlkMxV8JI7L3balGyULsObscezEh8kIIenzl3f4cS8 2fW3cToPSRSqj5SxdwvdmQ/HZ7oQvh2cCUgTxgn1N6FyYbJRGfRybsczDKxBmVABAfuu 8Gbw== ARC-Authentication-Results: i=1; mx.google.com; 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 u4si997424pgv.364.2018.01.25.11.47.00; Thu, 25 Jan 2018 11:47:16 -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; 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 S1751355AbeAYTpW (ORCPT + 99 others); Thu, 25 Jan 2018 14:45:22 -0500 Received: from mga07.intel.com ([134.134.136.100]:33292 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108AbeAYTpU (ORCPT ); Thu, 25 Jan 2018 14:45:20 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 11:45:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,413,1511856000"; d="scan'208";a="26364718" Received: from ray.jf.intel.com (HELO [10.7.201.17]) ([10.7.201.17]) by orsmga001.jf.intel.com with ESMTP; 25 Jan 2018 11:45:19 -0800 Subject: Re: [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process To: Arjan van de Ven , Tim Chen , Peter Zijlstra , Andy Lutomirski 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> <679180a8-cd7c-9200-224e-a93f0af77db7@linux.intel.com> Cc: LKML , KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , 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 From: Dave Hansen Message-ID: Date: Thu, 25 Jan 2018 11:45:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <679180a8-cd7c-9200-224e-a93f0af77db7@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25/2018 11:34 AM, Arjan van de Ven wrote: >> 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? > > how do you know the last active mm did not go away and started a new > process with new content? > (other than taking a reference which has other side effects) We couldn't think of an easy way to prevent mm reuse other than taking a reference. Think of it this way: the mm getting run poisons a CPU. We can either go at exit() time and do IBPB on every CPU that might have poison from the mm. Or, we do IBPB once on each CPU the first time the mm runs there to make sure that no old poison is still around. Both of those require per-cpu state in the mm, kinda like the TLB tracking. That will not be fun to get right. It also adds overhead to the common-case exit() or fork() paths. Also not fun. The refcount just eats a little memory for the mm *itself* but none of the actual expensive stuff: VMAs or page tables that hang off the mm. It's also zero-cost at fork/exit. The going-to-idle cost is manageable and *certainly* outweighs the cost of even one extra IBPB that we would otherwise have to do.