From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2279GGxASdU3z/0kfDyXY5Gar2LqgVbr1u8ib8X67lyTmwYMgNNve3sb0a4ZXlS5+LxElz88 ARC-Seal: i=1; a=rsa-sha256; t=1516872161; cv=none; d=google.com; s=arc-20160816; b=FGJ1ZVeJ0lPDweE5GIGAObCbtVVgM3cQVd7LPcmmeEqtswR4l6n5LzXnocDgXoAfLk TgyTK5NVvBV6+Rm6DQEk2P8MY2EKZQnYRNNChVW5mriUHrElewwtbOh3Yx1KvXp9r1Q3 Ti9TK471gqNsnTYsHxNn7lD38AjvADle4wBru8RXjGJeQ2PJMMo3kAtMUJLkTBZbueho 86efQY5tWZ6QBpt//1iXICZbri3G5cWieCnsAhEVHwaTJx5/V47xBnRzvdwhs8dJJKno 4Sw7S2IRsg7PQZOUGqOKajheNKrQtz1CIQkH2iuvKnhW65GlUkS5rkiYMngfcl99PbEZ UOwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=dM4JEcYaSW6A0SZIJ0m2g6O6aKImcZEv3bd9decNKjxao8Ni5PJ7Er5aB60mQNIwIp bwRPRlM0y3qSCTntzn1Ma9ttLj/IaJf2cT8Zb8YIu+I4+qm0wedDWYoNbpRQJXVKC2lo Cy89MX9NgqUJkT4pNeHSlcrnC+KlzkvZHPEGnQvZSHGsjaqnDjzNXFAmjREjDNzSJbfS 6D/qbM3uwqi411vXAgHjlkvw3YWcWdW8Kopx6jTvhfdGq5Z50awuLJmma41mjeJkxuQq 1w0eCCHLRHnz3Ob4m6vbp3KxHS0DUjB8Nd3iFrhMBP9YTeHi59KbAobYc5BpTgiy6y0o NM7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FJABzuRs; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FJABzuRs; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org 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) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590523944221221739?= X-GMAIL-MSGID: =?utf-8?q?1590555743390559694?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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.