Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3311124imm; Tue, 17 Jul 2018 02:37:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpekvw4e0GD0jF7QiCR6PEc255GvI7vzP6s3ydLi6aT7eK39lhday31DcHQ1OrQT6e1jxnkk X-Received: by 2002:a63:614d:: with SMTP id v74-v6mr878741pgb.328.1531820252161; Tue, 17 Jul 2018 02:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531820252; cv=none; d=google.com; s=arc-20160816; b=OhZdjwi8qbAAjeutW+KapS0snLat7EaeHCGI7yBHBGoaAnl+n7klttyX9OvAHOqcMg aN419vi8D0HeSbzfOagtYoJ7za6qv0jsQZQpr1+DQy4uKthyNSbdmNakvUlHLW1Pk22k rcCjybKX7ztpm5q8Lj6xgzGConNKQaZODdNXIsJevfm/dZS7Z1c7L6HuaTs0Hrh3xJuj L/PGSgC7hpvr5rrDbg0LJv5yhnqpuWthat/XIieSxSt6+cjp+tYqPwF8DIuqjXj4nOBB AX4SyRSSKH0qrNalBERQR+WIUeVmMxzXjGIECFB+mr2f51WP1xmbzHwYfvrxK877e5+6 ZcfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=OGUv+Km/xWHk3/o01UstfMQtYgWFi/IhGBYeiGKyXow=; b=KFzV8isyG4BsER8Te5N21niGuq6L+PhfpaleZMfGl+MZq8OuNs3jGzx2NvCA7QSahs c5JFqaGPNpZ6+ayAT+/svJeuVnsMJBU1/x1E+thnS2S7gU5oesvUKQPdu0mlTesSjXa8 DaRsaOysTg0tl3yFwkGSXNJvO4N6a1OJVvdy9Xbf8xUV0wbdAJGpknm01yCBix4qTSZe fjwoH5UNvy+fH3s/Zl64zXiXH9e+6gXUbtr22j/ldC+65IbNM0QMwpn8OLAcbSdGiRpc WEXE7U73q7RHW8HSBOFX4YiEkHE/wNiUuIdOw+1+TNeLQp0FwQtUaIWJbJs4jbpJXU8v QmTw== 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 h1-v6si462495pld.485.2018.07.17.02.37.17; Tue, 17 Jul 2018 02:37:32 -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 S1730567AbeGQKIS (ORCPT + 99 others); Tue, 17 Jul 2018 06:08:18 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43603 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbeGQKIS (ORCPT ); Tue, 17 Jul 2018 06:08:18 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6H9aCx21463667 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 17 Jul 2018 02:36:13 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6H9aCes1463664; Tue, 17 Jul 2018 02:36:12 -0700 Date: Tue, 17 Jul 2018 02:36:12 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Rik van Riel Message-ID: Cc: mingo@kernel.org, riel@surriel.com, tglx@linutronix.de, dave.hansen@intel.com, hpa@zytor.com, songliubraving@fb.com, peterz@infradead.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, tglx@linutronix.de, riel@surriel.com, dave.hansen@intel.com, hpa@zytor.com, peterz@infradead.org, songliubraving@fb.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org In-Reply-To: <20180716190337.26133-7-riel@surriel.com> References: <20180716190337.26133-7-riel@surriel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/mm/tlb: Always use lazy TLB mode Git-Commit-ID: 95b0e6357d3e4e05349668940d7ff8f3b7e7e11e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 95b0e6357d3e4e05349668940d7ff8f3b7e7e11e Gitweb: https://git.kernel.org/tip/95b0e6357d3e4e05349668940d7ff8f3b7e7e11e Author: Rik van Riel AuthorDate: Mon, 16 Jul 2018 15:03:36 -0400 Committer: Ingo Molnar CommitDate: Tue, 17 Jul 2018 09:35:34 +0200 x86/mm/tlb: Always use lazy TLB mode 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 --- 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 3aa3204b5dc0..511bf5fae8b8 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 e4156e37aa71..493559cae2d5 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -379,20 +379,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); } /*