Received: by 10.223.176.46 with SMTP id f43csp1882154wra; Thu, 25 Jan 2018 01:23:33 -0800 (PST) X-Google-Smtp-Source: AH8x224CxhAGxSBbSmRoxJLznmTlTFBgK0UMldpSWx3Ylx7Xv6qOuM1b6d7eE8NknT6mbtmmXPJW X-Received: by 10.99.116.22 with SMTP id p22mr4679915pgc.4.1516872213268; Thu, 25 Jan 2018 01:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516872213; cv=none; d=google.com; s=arc-20160816; b=SpaMj88m+KrQkYgGtyuxVllTv4ToTpUANekua2bpNuwipfenAZNedRU4rPpEFdOw8A NNYEUglqzuuTyO1ay4lfbqZQa2X8SQ9I3WdpWfARnDDLtLiPiUxzvHcRSdTK0tkByOrs iRsk7tRd/Czk3e7wwo82dLwOcVqEuhmfXJl6c2b2eg+65gk93CuyakqZ8K2itBxoCHgP fEH4vcKlunFcpfS0lYr6i5YuLOiOZwwd2YBt1/13qZvWAerM/uLKhzBb49WhuFZo9LZL INcvbUD+GfJHExzOU/BGkbs9D3LE2Jd13Je8P2NGjbWb7hHf+5l6UsBqXODYwDwkDv6m 0K9Q== 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=L7QskcqRY4LE7vBcd/3KLn+lwm4QPD2nJgDjJ8DahTk=; b=hDCfE9aUMOr24urMtIKTjda/RVdghgib2h4+jd9D3WobveZuGAA5kapferJKk6IZ7e GxSoyBzr4WPs0MgMQqvt7ENVg/9khNNZjwZhLhGxohYqJWOQBYUkW8W5Q/pUZPEHi1qG E0g34wYzpkH/pw9zesrneTfSiNBWU1SIDNz6VcoJxjq76mILC6yKpF8peFJr7793WB9d +hnsHnEbYKswqDOKOzMHQJqGWzucrdApnz3iTL2YV3ZppGAYYFlXM2lfg0DQa7+N7gIn /mAm4rT448Fpxifo7CaIQsNR9fz3ivRnBbbGttxTAnwhuO2zk8z3XGwnMC8dS0lNvYn3 Am2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FJABzuRs; 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 m2si4344192pfh.158.2018.01.25.01.23.19; Thu, 25 Jan 2018 01:23:33 -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=FJABzuRs; 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 S1751455AbeAYJWr (ORCPT + 99 others); Thu, 25 Jan 2018 04:22:47 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:55141 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbeAYJWo (ORCPT ); Thu, 25 Jan 2018 04:22:44 -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=L7QskcqRY4LE7vBcd/3KLn+lwm4QPD2nJgDjJ8DahTk=; b=FJABzuRsYFLYyDDplnyWdBnDA TqlUXLAUVrKY2bIR/QMh0KxfiPxrjH0EkhxgTCuLGABQGq/GHBF2MgWzGjC3K482E7WopVHTBLys5 DbzUzekY1vbN5XVO8fUCvJdHEWRaZtlaPTXnnQkH7lxmA2u70lDpQuY14R5mG5UfqgQ+82G6IR+qC p3/5wqLuEpsGrfdgvnkSnvqFJsOny1IvsQLabZbOQnjcl6obAa+ok97f7bP1ZuRcMD+R1hMS8wwBF +o+KIFzXulKuXhzr20FYcbp5zmcR7dWPjO0tM9YHXsAuu63izwN/NYMEXL0qAjEiRYizKu9nOAw2e vvdkJIU9w==; 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 1eedjv-0000tC-2t; Thu, 25 Jan 2018 09:22:35 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 47F912029B0FF; Thu, 25 Jan 2018 10:22:33 +0100 (CET) Date: Thu, 25 Jan 2018 10:22:33 +0100 From: Peter Zijlstra 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 , rkrcmar@redhat.com, Thomas Gleixner , Tom Lendacky , x86@kernel.org Subject: Re: [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process Message-ID: <20180125092233.GE2295@hirez.programming.kicks-ass.net> References: <20180125085820.GV2228@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180125085820.GV2228@hirez.programming.kicks-ass.net> 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 09:58:20AM +0100, Peter Zijlstra wrote: > On Wed, Jan 24, 2018 at 04:36:41PM -0800, Tim Chen wrote: > > These two patches provide optimization to skip IBPB for this > > commonly encountered scenario: > > 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. > > > > The cost is to have an extra pointer to track the last mm we were using before > > switching to the init_mm used by idle. But avoiding the extra IBPB > > is probably worth the extra memory for such a common scenario. > > So we already track active_mm for kernel threads. I can't immediately > see where this fails for idle and your changelog doesn't say. idle_task_exit() explicitly switches back to init_mm when we take the CPU offline, this very much suggests the active_mm thing works for idle too. This means that 'A -> idle -> A' should never pass through switch_mm to begin with. Please clarify how you think it does.