Received: by 10.223.185.116 with SMTP id b49csp3212803wrg; Mon, 5 Mar 2018 16:40:54 -0800 (PST) X-Google-Smtp-Source: AG47ELs8efiS3RgJcRiAV77rQv8utyfPNeajPgdDSug0ART8h/PFryo6H1b8fpya7MAzjYIzmvHX X-Received: by 2002:a17:902:7c11:: with SMTP id x17-v6mr15003956pll.59.1520296854631; Mon, 05 Mar 2018 16:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296854; cv=none; d=google.com; s=arc-20160816; b=tT0pEGXgBv94hi2Y6BvgNFP6FAmXJualL0tdG1AVS1ZLgb0xx0pDblvKSTPXbMYHu3 DUuMN0humv8zyOEtUz7JZQKpCtESQgEn8PQV940u6xjAy4ezUpSmz+BEOnGTyxMQqWfb fvQnr+i7kkMq0ipMDiH4EivgtVFkBowue/8QEqbojaj5ScFSoU5hSGMRylCqVbRrVZqT nnbR6ZIq18/Eo0C6D9sxvMaHV1vU1mqFzKF93of8b2Enk1ibJ0kXoJa0XWGLrHiuGxMV e23oDlzR9R45CMtWbfbCITRFX5KI2jWKXbjL2NlGyy868pHy4XpWjaMZXAOX/Y7Ob6TL b8aQ== 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=sCNMOQUDZr8V+yMvHHAHJYfQsXYhl0J+/XMnAI26+6Q=; b=X4rUXI7EjPvNMYnFZgqXPWU4utUzZiw8O2SLIROH5oVtNnvFiXxuqpLQO/wXjY63Md p7JY2slA279t/EE+kuDQ+A4zDqd2d9gCNDMypuiNW4sTPp1EURy3BxosAK4+1hA3qCOx Zz2u9lB3UY9pzp+ikhK6aak6sghUSUC0U6GxcDRhPPh9KIikMIgzubY8n8h2KidxniMQ T9eYtn5TXkDtG2+SXg9sRRjZTRUjyf0eNj0l/DnoXwOBijeC25SLvnVGHzLPVFtONvJR yvSVFKaH5AW4DJZzVqA3TCBd9zgF/ubMw9opqU7aMA06XxwFxcXJV2WrgtqKYVXqUg2y 9VaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=uF2hyP+h; 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 o11-v6si10197394pll.158.2018.03.05.16.40.40; Mon, 05 Mar 2018 16:40:54 -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=uF2hyP+h; 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 S933511AbeCFAix (ORCPT + 99 others); Mon, 5 Mar 2018 19:38:53 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56218 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933046AbeCFA0S (ORCPT ); Mon, 5 Mar 2018 19:26:18 -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 w260Lsnq034967; Tue, 6 Mar 2018 00:26:13 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=sCNMOQUDZr8V+yMvHHAHJYfQsXYhl0J+/XMnAI26+6Q=; b=uF2hyP+hN2vH/NEMc87J7xsDv9RNaULyFzJKdCNTft8DeDfRJAPjShLCE5TkHHrUZd0V 1B1JWdJHPc5t0FWTxKibeidwpwuyhxUMboYJEcrvJ0LoLDeKUqCQTLdzO73oBP06gi0O xLhP3sJhPMJvTlQ76WlQBP6eqECmWO2ZHpeM2k36whuI12/KMBjQ8odnwrIlZl2TorgX YcrrFZt/c0DMr+di3CXE+ZQkcel0+ZkChAHijDNYkWlzMtaJpjR/WdVStC9wFRENEGUg IKpUcGc2p4QGF6MC/7chLM1ENCUKQSoJPa+RQtdt0SF45DmydYCqoV0GlI8pARnzF5OX ew== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ghe3kgg3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:13 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w260QCRh023176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:13 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 w260QCN7029066; Tue, 6 Mar 2018 00:26:12 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:11 -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 16/65] x86/mm: Reimplement flush_tlb_page() using flush_tlb_mm_range() Date: Mon, 5 Mar 2018 19:24:49 -0500 Message-Id: <20180306002538.1761-17-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 ca6c99c0794875c6d1db6e22f246699691ab7e6b upstream. flush_tlb_page() was very similar to flush_tlb_mm_range() except that it had a couple of issues: - It was missing an smp_mb() in the case where current->active_mm != mm. (This is a longstanding bug reported by Nadav Amit) - It was missing tracepoints and vm counter updates. The only reason that I can see for keeping it at as a separate function is that it could avoid a few branches that flush_tlb_mm_range() needs to decide to flush just one page. This hardly seems worthwhile. If we decide we want to get rid of those branches again, a better way would be to introduce an __flush_tlb_mm_range() helper and make both flush_tlb_page() and flush_tlb_mm_range() use it. Signed-off-by: Andy Lutomirski Acked-by: Kees Cook Cc: Andrew Morton Cc: Borislav Petkov Cc: Dave Hansen Cc: Linus Torvalds Cc: Mel Gorman Cc: Michal Hocko Cc: Nadav Amit Cc: Nadav Amit Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/3cc3847cf888d8907577569b8bac3f01992ef8f9.1495492063.git.luto@kernel.org Signed-off-by: Ingo Molnar Cc: Hugh Dickins Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 3efba6062a410a2a65fc9d6f53dca63db2602e65) Signed-off-by: Pavel Tatashin --- arch/x86/include/asm/tlbflush.h | 6 +++++- arch/x86/mm/tlb.c | 27 --------------------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index d9ee4674c235..f23ee750bb68 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -289,11 +289,15 @@ static inline void flush_tlb_kernel_range(unsigned long start, flush_tlb_mm_range(vma->vm_mm, start, end, vma->vm_flags) extern void flush_tlb_all(void); -extern void flush_tlb_page(struct vm_area_struct *, unsigned long); extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long vmflag); extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); +static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long a) +{ + flush_tlb_mm_range(vma->vm_mm, a, a + PAGE_SIZE, VM_NONE); +} + void native_flush_tlb_others(const struct cpumask *cpumask, struct mm_struct *mm, unsigned long start, unsigned long end); diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 95d5b4fff799..77fdf801efde 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -332,33 +332,6 @@ out: preempt_enable(); } -void flush_tlb_page(struct vm_area_struct *vma, unsigned long start) -{ - struct mm_struct *mm = vma->vm_mm; - - preempt_disable(); - - if (current->active_mm == mm) { - if (current->mm) { - /* - * Implicit full barrier (INVLPG) that synchronizes - * with switch_mm. - */ - __flush_tlb_one(start); - } else { - leave_mm(smp_processor_id()); - - /* Synchronize with switch_mm. */ - smp_mb(); - } - } - - if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids) - flush_tlb_others(mm_cpumask(mm), mm, start, 0UL); - - preempt_enable(); -} - static void do_flush_tlb_all(void *info) { count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); -- 2.16.2