Received: by 10.223.185.116 with SMTP id b49csp3214074wrg; Mon, 5 Mar 2018 16:42:45 -0800 (PST) X-Google-Smtp-Source: AG47ELvNWamPbfLuH4nvWg0ABGrTXM3W9g5ciDKJo4QjAokx/H+eM2T3tcELXdSqNHlE3IgMzoqY X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr14208768pld.28.1520296965546; Mon, 05 Mar 2018 16:42:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296965; cv=none; d=google.com; s=arc-20160816; b=bLbVZ+l06W2BM/WR9gAubCUPWQmzmxGI6R7RItW81exbiUEDkTXKZLxJilVXlJ3KgJ 0mO+GNgAy6h6Qy0NbKckm15Er4iR2LbgxgQGYWqzms5t4cZNUIhLXnqnDSiTEYwD1LBC hMrNvBXHHaVyhUsv+oVdPhHNxBcDsaLi/i/U+Rv6BHdiZ7YOzv3nIAMJdRlYquc7+kAe +OvABbKKaIMUg8O8vW25rmgOmqFfWfn6hYmdQcxgW85PiQH30erCCZDJAhI3+YpIaJZm MgZh+jvtjJ7fbcJ9llVxEEIi6xg1R0WdFWj5ZXoacMMGm2oEaF78+SWdPzRB6UD6AGrp tvjA== 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:to:from:dkim-signature:arc-authentication-results; bh=Q+ufNThHBu+wgxR6EICVZyufyKyfGhPqMc9d1GhjYxo=; b=QovtNvO76Wcz3ZxkjkqBLmL1Tdda0RmFO5AWzsg7PMwohTS7YqWj02HzpBfHG/ReZn jcb4mzJoAmWxC4GTxrEiw0uagNuG6C2lpudMeIpZvpWf/A+T61OiSrLHFPyChE9UMqq7 huTyGhjGBfpUs9CWqvOmj52NgU3TO1PccnHUQ+SYu9Q73WcKz90jtP+XxfvsLIrnGexz huH4DT1pCOxpvW9Mf6w5q+C1DhI7p26lLsuY/KaZTVBecSz1LaMz/Aq3KPVBH+JO+/i5 D3OWqJNQWWSj0CzzpGGEp3P6aAIE1bUelEXx25MCky7QXFZfkyVgsFayDhPEgTTJQwO8 Na/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jt38k7fg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si9017890pgv.456.2018.03.05.16.42.31; Mon, 05 Mar 2018 16:42:45 -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=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jt38k7fg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933307AbeCFAj5 (ORCPT + 99 others); Mon, 5 Mar 2018 19:39:57 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56200 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932977AbeCFA0Q (ORCPT ); Mon, 5 Mar 2018 19:26:16 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260LgUw034926; Tue, 6 Mar 2018 00:26:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=Q+ufNThHBu+wgxR6EICVZyufyKyfGhPqMc9d1GhjYxo=; b=jt38k7fgVTFnrm4+j2SANnQgUU4LayEI3R+1YGgZpgyhZ6zNLG/ua5NCoQqbo77HZBvj Hx8mdusb24uh3427T/QGsHwxJdKMUg+xN59ibRYxqQah1MW2iDS0XtPSoziFUyIJjJPJ xH9IgExdnq1YT2lINpjJhNJI2x/d1wqRhnF6a8GNi89yswgsawemN1gZPjA/vAKscHEk lzdv4ggP8rOXJKVJYunzLL5n/zgq0ZD8kcDyByVvQDnLeehBYS4tSbH4XkpvwmUB9Q18 RcTv64ItXKwyBZ1sYLsXn6MBca2AM4OZtAfIFnBJAuu8IxLv/gCHBjtUneY4D4b7ZO8I DQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2ghe3kgg3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:12 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w260QBOI029828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:12 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w260QBqW029060; Tue, 6 Mar 2018 00:26:11 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:10 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 15/65] x86/mm: Make flush_tlb_mm_range() more predictable Date: Mon, 5 Mar 2018 19:24:48 -0500 Message-Id: <20180306002538.1761-16-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Lutomirski commit ce27374fabf553153c3f53efcaa9bfab9216bd8c upstream. I'm about to rewrite the function almost completely, but first I want to get a functional change out of the way. Currently, if flush_tlb_mm_range() does not flush the local TLB at all, it will never do individual page flushes on remote CPUs. This seems to be an accident, and preserving it will be awkward. Let's change it first so that any regressions in the rewrite will be easier to bisect and so that the rewrite can attempt to change no visible behavior at all. The fix is simple: we can simply avoid short-circuiting the calculation of base_pages_to_flush. As a side effect, this also eliminates a potential corner case: if tlb_single_page_flush_ceiling == TLB_FLUSH_ALL, flush_tlb_mm_range() could have ended up flushing the entire address space one page at a time. Signed-off-by: Andy Lutomirski Acked-by: Dave Hansen Cc: Andrew Morton Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Michal Hocko Cc: Nadav Amit Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/4b29b771d9975aad7154c314534fec235618175a.1492844372.git.luto@kernel.org Signed-off-by: Ingo Molnar Cc: Hugh Dickins Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 9f4d1ba1d407e56dac833aa0b11c60f952939e1c) Signed-off-by: Pavel Tatashin --- arch/x86/mm/tlb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 262abde154eb..95d5b4fff799 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -285,6 +285,12 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, unsigned long base_pages_to_flush = TLB_FLUSH_ALL; preempt_disable(); + + if ((end != TLB_FLUSH_ALL) && !(vmflag & VM_HUGETLB)) + base_pages_to_flush = (end - start) >> PAGE_SHIFT; + if (base_pages_to_flush > tlb_single_page_flush_ceiling) + base_pages_to_flush = TLB_FLUSH_ALL; + if (current->active_mm != mm) { /* Synchronize with switch_mm. */ smp_mb(); @@ -301,15 +307,11 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, goto out; } - if ((end != TLB_FLUSH_ALL) && !(vmflag & VM_HUGETLB)) - base_pages_to_flush = (end - start) >> PAGE_SHIFT; - /* * Both branches below are implicit full barriers (MOV to CR or * INVLPG) that synchronize with switch_mm. */ - if (base_pages_to_flush > tlb_single_page_flush_ceiling) { - base_pages_to_flush = TLB_FLUSH_ALL; + if (base_pages_to_flush == TLB_FLUSH_ALL) { count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); local_flush_tlb(); } else { -- 2.16.2