Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5744899imm; Mon, 23 Jul 2018 05:28:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJGLyssVVqZudLNnvDmED8jxMEhx6JFhbEPcBxbFFed3ldtxQOIrkL1C822A7tKibkxm9s X-Received: by 2002:a63:b43:: with SMTP id a3-v6mr11921380pgl.50.1532348899707; Mon, 23 Jul 2018 05:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532348899; cv=none; d=google.com; s=arc-20160816; b=Xux6zJ59TiTHBZU3IjsFDaQ58TWxatTXytt12I2afUpzARjEUf0uNNAmLkAAvZHJ6m JCy6SS50L+EWeSjGUAvMwcQCimkgjqcaa9LCTcA1DLMubC6AbXzAt8wqf/xAlcPXfR7a fh+uJ/c88DZ6YajwMJzyNwlk7bXEbSmfRvrbksQgqNlFzkxzQqdgHUY+lD9snnJfzG52 HT9DoP2WrjkkG6Id8QmCahkeudgBVE+DzDGktixXG8jlVnlrCxPZ+juUB8H654yenM9O J0DiHpQUpuATKoa1ZqQ5BBXpX0F/qIZpB0+KNokEr3ElzQg/gqK0kitWjqQUtUtv/Qvd yTag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id:arc-authentication-results; bh=Svn0jthdRHpx9QaiEmk8qH1b4nNG6Pgx4hmDg9ZkKMs=; b=GFRezVXgi+4aR1oHqITzcS0j8NU6kZ8d47H88CC2XkvzBJibeIDY1167uJUP35iW4M 2aY2ewCTUYzthloze8rffeLiykz/UOnNmRUM5nSUPA1i8FmUAaJmwww8IWxK2O27UBK3 c2u8euo+vSjzTYcmuNHHV2q7+oGkxP23n44L2SRuMMx9YyN9HzqNbO/5/vsVqRBMhxxH t/4ki8PCpLCLpycc2TLiscJcdegVGSOEzqW7r4P8J8GJOPKcXGl4GNjekKP69MEhVALL r6NvAkM3wjGR5xrTXCwtOO6OvU7l3e4YAJH5qNEUPbFMuODprSmToU/fdcMC1CHss4F3 K9xg== 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 v190-v6si8728797pgd.668.2018.07.23.05.28.04; Mon, 23 Jul 2018 05:28:19 -0700 (PDT) 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 S2388407AbeGWN1f (ORCPT + 99 others); Mon, 23 Jul 2018 09:27:35 -0400 Received: from shelob.surriel.com ([96.67.55.147]:52698 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387882AbeGWN1d (ORCPT ); Mon, 23 Jul 2018 09:27:33 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fhZur-0001Eb-Dv; Mon, 23 Jul 2018 08:26:17 -0400 Message-ID: <1532348776.26425.7.camel@surriel.com> Subject: Re: [PATCH 4/7] x86,tlb: make lazy TLB mode lazier From: Rik van Riel To: Peter Zijlstra , Andy Lutomirski Cc: Vitaly Kuznetsov , Juergen Gross , Boris Ostrovsky , linux-arch , Will Deacon , Catalin Marinas , linux-s390@vger.kernel.org, Benjamin Herrenschmidt , linuxppc-dev , LKML , X86 ML , Mike Galbraith , kernel-team , Ingo Molnar , Dave Hansen Date: Mon, 23 Jul 2018 08:26:16 -0400 In-Reply-To: <20180720083016.GN2494@hirez.programming.kicks-ass.net> References: <20180716190337.26133-1-riel@surriel.com> <20180716190337.26133-5-riel@surriel.com> <20180720083016.GN2494@hirez.programming.kicks-ass.net> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-4vkrqBG7jdk4C2JsdnAu" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-4vkrqBG7jdk4C2JsdnAu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2018-07-20 at 10:30 +0200, Peter Zijlstra wrote: > On Thu, Jul 19, 2018 at 10:04:09AM -0700, Andy Lutomirski wrote: > > I added some more arch maintainers. The idea here is that, on x86 > > at > > least, task->active_mm and all its refcounting is pure > > overhead. When > > a process exits, __mmput() gets called, but the core kernel has a > > longstanding "optimization" in which other tasks (kernel threads > > and > > idle tasks) may have ->active_mm pointing at this mm. This is > > nasty, > > complicated, and hurts performance on large systems, since it > > requires > > extra atomic operations whenever a CPU switches between real users > > threads and idle/kernel threads. > >=20 > > It's also almost completely worthless on x86 at least, since > > __mmput() > > frees pagetables, and that operation *already* forces a remote TLB > > flush, so we might as well zap all the active_mm references at the > > same time. >=20 > So I disagree that active_mm is complicated (the code is less than > ideal > but that is actually fixable). And aside from the process exit case, > it > does avoid CR3 writes when switching between user and kernel threads > (which can be far more often than exit if you have longer running > tasks). >=20 > Now agreed, recent x86 work has made that less important. >=20 > And I of course also agree that not doing those refcount atomics is > better. It might be cleaner to keep the ->active_mm pointer in place for now (at least in the first patch), even=20 on architectures where we end up dropping the refcounting. That way the code is more similar everywhere, and we just get rid of the expensive instructions. Let me try coding this up... --=20 All Rights Reversed. --=-4vkrqBG7jdk4C2JsdnAu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAltVyWkACgkQznnekoTE 3oNp5ggAhb/ScHMhsqjYPCfu5/gdUlsB46K5xr9f8ZxmVN0LNF0x4n0AROsADMQw LLsM+EagLWYMdXjKeI5xCsMu2nwcm9aAqdONRkyjGbgIbupzjHNNMqRNa4NxB+dZ t9mMgAbnGv+2HLxbIsb6zhb1ckdHkaLipv8llItk8orYkdb5WWtnvdQC6UHBr+0e 5eJuQiarWkHorhoqlXCh3Zc1ZinxSTlOFzmVAf+Vw0n0qjMcq1pPelsA9ynJPJM+ 9NwXsdodm38ppTpXIPKAQb4NF73JgxtqaUZuPQmiasaUo3czZq67uQZin6v7iC+H g2oK4ygHmep6StVwfzfx/FtsnTsqbg== =BJ7M -----END PGP SIGNATURE----- --=-4vkrqBG7jdk4C2JsdnAu--