Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp253645imm; Tue, 25 Sep 2018 20:59:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV62rRn7bU314GG1S0Hqxa9PZi0MCsrKd52YrE5meUdZ3+dc1nFshziKnDFkCjoyOVkeiRKyn X-Received: by 2002:a65:40cd:: with SMTP id u13-v6mr3718319pgp.334.1537934381463; Tue, 25 Sep 2018 20:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537934381; cv=none; d=google.com; s=arc-20160816; b=pzmpFXm9VDevSD9101qziklaAPkvbZYk32un+3LImWQxR1TN8Yo0xyeOwpMTkHWHgh DeUm7ziUSyHHaFvU1fbSezJFTtZUuVPSpf6t5ObuszOWhTScVDx95DKWIBorxkd8aHae AQUFCMOgEMZM7BZRDuJ9FqjLZw2bZ0CRQ0VRKxSXmrYI/GKUFwO3n3X8h/FGz1J4B1oC kFmTAywA9NAcAEAJvAGd9A6dkyT1M4wYkTXFcaNSNRt7Kvop3ev2Z/iIWw+cPw/QK4RR AVDksgIfW11j+RwEpOLpcalOM4l35+QlQBsoa/JT6RigUd+6PBLSFdQv3KhWRLblBEIB 1cCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=aLI6SCyibNJynMMANA7ZAtkK4BGP5DlMEPtRIQ3CoYM=; b=JEJF2OX4hjVIadGe5s9yg8NsnnAhQ9/KldgyFJmGbJQvI9Sq8qeLPSmExHvJjNiyYX IMNBZn+WxRo+17atrz6lZUNGImTk6miyyGyJXUlejb4LIElUNdlLIuWmAbRENAqIAtql pl5M0/bJ0jqunqp/C/gpvOq+w6QBlEiymACTamjwiF7QjJGUlb5kS4aMqguovL4PAqKa 2dr1U+vI1uhSrZrYa+03jgMdP8I/xRcDlJ0Zk2Rd5cFxNVzsw75v5g1CGRuTojPJxaya jdUx+iYZeAZ9sIUGtFUtxC/xmm91n/CzVRGYocyjNwMPLjcTbKaytTx4+U5+UODyuJyA zoqg== 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 w17-v6si4167017plp.335.2018.09.25.20.59.26; Tue, 25 Sep 2018 20:59:41 -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 S1727017AbeIZKJ5 (ORCPT + 99 others); Wed, 26 Sep 2018 06:09:57 -0400 Received: from shelob.surriel.com ([96.67.55.147]:49994 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeIZKJz (ORCPT ); Wed, 26 Sep 2018 06:09:55 -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 1g50yN-0006sG-Pl; Tue, 25 Sep 2018 23:58:47 -0400 From: Rik van Riel To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, kernel-team@fb.com, will.deacon@arm.com, songliubraving@fb.com, mingo@kernel.org, luto@kernel.org, hpa@zytor.com, npiggin@gmail.com, Rik van Riel , Linus Torvalds , Thomas Gleixner , efault@gmx.de Subject: [PATCH 1/7] x86/mm/tlb: Always use lazy TLB mode Date: Tue, 25 Sep 2018 23:58:38 -0400 Message-Id: <20180926035844.1420-2-riel@surriel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926035844.1420-1-riel@surriel.com> References: <20180926035844.1420-1-riel@surriel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that CPUs in lazy TLB mode no longer receive TLB shootdown IPIs, except at page table freeing time, and idle CPUs will no longer get shootdown IPIs for things like mprotect and madvise, we can always use lazy TLB mode. Tested-by: Song Liu Signed-off-by: Rik van Riel Acked-by: Dave Hansen Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: efault@gmx.de Cc: kernel-team@fb.com Cc: luto@kernel.org Link: http://lkml.kernel.org/r/20180716190337.26133-7-riel@surriel.com Signed-off-by: Ingo Molnar (cherry picked from commit 95b0e6357d3e4e05349668940d7ff8f3b7e7e11e) --- arch/x86/include/asm/tlbflush.h | 16 ---------------- arch/x86/mm/tlb.c | 15 +-------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 671f65309ce7..d6c0cd9e9591 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -148,22 +148,6 @@ static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid) #define __flush_tlb_one_user(addr) __native_flush_tlb_one_user(addr) #endif -static inline bool tlb_defer_switch_to_init_mm(void) -{ - /* - * If we have PCID, then switching to init_mm is reasonably - * fast. If we don't have PCID, then switching to init_mm is - * quite slow, so we try to defer it in the hopes that we can - * avoid it entirely. The latter approach runs the risk of - * receiving otherwise unnecessary IPIs. - * - * This choice is just a heuristic. The tlb code can handle this - * function returning true or false regardless of whether we have - * PCID. - */ - return !static_cpu_has(X86_FEATURE_PCID); -} - struct tlb_context { u64 ctx_id; u64 tlb_gen; diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 6aa195796dec..54a5870190a6 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -368,20 +368,7 @@ void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) if (this_cpu_read(cpu_tlbstate.loaded_mm) == &init_mm) return; - if (tlb_defer_switch_to_init_mm()) { - /* - * There's a significant optimization that may be possible - * here. We have accurate enough TLB flush tracking that we - * don't need to maintain coherence of TLB per se when we're - * lazy. We do, however, need to maintain coherence of - * paging-structure caches. We could, in principle, leave our - * old mm loaded and only switch to init_mm when - * tlb_remove_page() happens. - */ - this_cpu_write(cpu_tlbstate.is_lazy, true); - } else { - switch_mm(NULL, &init_mm, NULL); - } + this_cpu_write(cpu_tlbstate.is_lazy, true); } /* -- 2.17.1