From patchwork Fri Jan 4 17:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10748609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECF851575 for ; Fri, 4 Jan 2019 17:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEB8528536 for ; Fri, 4 Jan 2019 17:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2E7C285B6; Fri, 4 Jan 2019 17:49:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50DB328536 for ; Fri, 4 Jan 2019 17:49:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 623F08E00FB; Fri, 4 Jan 2019 12:49:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5AFE88E00FA; Fri, 4 Jan 2019 12:49:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 252A68E00FB; Fri, 4 Jan 2019 12:49:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id CB9C68E00F9 for ; Fri, 4 Jan 2019 12:49:52 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id g7so27599900plp.10 for ; Fri, 04 Jan 2019 09:49:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=I0kn+QTc+hsJJZq65vl6K/nylT8ZRJRIL8RynYDN1io=; b=rsX2RhksVFrjOt0LjoO74zcJ/H54Tyhsy6+0fTczkou9BLJtKECmvdHTYICaBsnNgO xcSvaBT7rJVg9cAR9a11Qr9HUTyl97gL60c00ebmxFWOPPJt7FYW/vHzwU3DLVZGZJWk k3Wt7OwlSaFK2d+Xk7kEYZ8ySvkaFsuNoWQwXnKOVxEGRgzeRMvDIEFj9HkZ8T/M5jF4 6IQv+HC+L8DHwNoU/o7ksT3pTmdJDtZbhUu6CpKQyHDwvIJuqgGk/SFDgi3jPx13k7nH xOYu9O8ywMOCbAfVWHHykGWyWnhCSwTjfLVNMqncszo41o+hYq5kTgF2gLpwa733qyFP PqVA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave@ray.jf.intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave@ray.jf.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AJcUukcE7Irz9RceIVFZQLqAsuNJVQcMeWxH4bzdBJslWH8lQPpQi4Sl G2riAx2GXoWVJQeUPjM8nbfx3fk8DGHivy0pk12Y/DeLsG9nzkEUTKHF9rN/a8n2wZvXn54gB1V mEPXaR3zLktTU+RHHro+IneCCYkz8tckVXDc3SmeTMoRI2j4Nt4M5zsif/A2wDPMcOg== X-Received: by 2002:a17:902:145:: with SMTP id 63mr51667801plb.256.1546624192381; Fri, 04 Jan 2019 09:49:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN4iZwdI2nay8LKdumzBpDFd6222/fP31l6alfmyQhOICZSdi7tvDuIbyRnrH7bZqKTSaIbg X-Received: by 2002:a17:902:145:: with SMTP id 63mr51667766plb.256.1546624191454; Fri, 04 Jan 2019 09:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546624191; cv=none; d=google.com; s=arc-20160816; b=kFAKV2zUYmBdz9f7TwK4k9TG0FWoSYrT/AWpP08EfVNQDIlQ+gvAt5rA63+rfrkAEM M6dlCD03r+j0XoU3l7XIZdilV01Y0rDuyzg/moC2CO31PpXjUERizkcD9DxxpZQnAs9O 8ERfNHuCWdlm3aatDaztVMRslZZY50uD8A9YLb8zwyctkNBdDuakKmhK+fWUs/0ZJSEJ aB/k4i1/q9ZuGZ1OjkonL6Mu3NcQQQt9Nj8QwHHsdJbfBPtdSKXmVYqEAOOqikS6tZ/D SHQmGEhdDqcWyWln2ej7o2+5wmh898MEHVF1Lc8sOKNnd7XLPcZH5UzBdK5vFI2OsiWa Lr9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=I0kn+QTc+hsJJZq65vl6K/nylT8ZRJRIL8RynYDN1io=; b=zFXBTyhRYMsVRewGDFVSz7PLgB8nSQn8eT52RyYqFP1x0MW5J7aVL8QHFNtEJGN/9a 7s6PqT7wk8C0io2OBk9ZouAkfF0o9gocrEvtoqx3QJgA4XLg4ggX6ofuy/x4e1KxYLhy oLoUTjJDHHdlnT02BFkyV+tjZr9M9oRPwAae57UlOtByL79qLh/NeOowQDNxqib+6Gvp r68Lx9zQVTyzzbAE5j8mm7NLPXHRzyUVlua2DX4nNeRllocnP7NADmur4w0Ifg31LAZj BllT+0Ae+nTZvY+AqOl+iUfoJfUuDPOvbb0P6x7JwkTb/aW4BF4aqz6t1wnp4zljIpk8 0NRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave@ray.jf.intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave@ray.jf.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id k18si13717865pfd.241.2019.01.04.09.49.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 09:49:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dave@ray.jf.intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave@ray.jf.intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave@ray.jf.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jan 2019 09:49:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,439,1539673200"; d="scan'208";a="264448785" Received: from unknown (HELO ray) ([10.251.0.234]) by orsmga004.jf.intel.com with ESMTP; 04 Jan 2019 09:49:50 -0800 Received: by ray (Postfix, from userid 1000) id 6EB62E0641; Fri, 4 Jan 2019 09:49:50 -0800 (PST) From: Dave Hansen To: dave.hansen@intel.com Cc: x86@kernel.org, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] mm: remove MPX hooks from generic code Date: Fri, 4 Jan 2019 09:49:41 -0800 Message-Id: <1546624183-26543-4-git-send-email-dave.hansen@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546624183-26543-1-git-send-email-dave.hansen@linux.intel.com> References: <1546624183-26543-1-git-send-email-dave.hansen@linux.intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Hansen MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc). There are two hooks into the generic mm code that MPX uses: one for ~munmap() and the other at execve() time. Remove them, eliminating MPX from generic mm code. Signed-off-by: Dave Hansen --- arch/x86/include/asm/mmu_context.h | 31 ------------------------------- fs/exec.c | 1 - include/asm-generic/mm_hooks.h | 11 ----------- mm/mmap.c | 6 ------ 4 files changed, 49 deletions(-) diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 0ca5061..61363e7 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -12,7 +12,6 @@ #include #include #include -#include extern atomic64_t last_mm_ctx_id; @@ -253,36 +252,6 @@ static inline bool is_64bit_mm(struct mm_struct *mm) } #endif -static inline void arch_bprm_mm_init(struct mm_struct *mm, - struct vm_area_struct *vma) -{ - mpx_mm_init(mm); -} - -static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long start, unsigned long end) -{ - /* - * mpx_notify_unmap() goes and reads a rarely-hot - * cacheline in the mm_struct. That can be expensive - * enough to be seen in profiles. - * - * The mpx_notify_unmap() call and its contents have been - * observed to affect munmap() performance on hardware - * where MPX is not present. - * - * The unlikely() optimizes for the fast case: no MPX - * in the CPU, or no MPX use in the process. Even if - * we get this wrong (in the unlikely event that MPX - * is widely enabled on some system) the overhead of - * MPX itself (reading bounds tables) is expected to - * overwhelm the overhead of getting this unlikely() - * consistently wrong. - */ - if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX))) - mpx_notify_unmap(mm, vma, start, end); -} - /* * We only want to enforce protection keys on the current process * because we effectively have no access to PKRU for other diff --git a/fs/exec.c b/fs/exec.c index fc281b7..cb99ea5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -317,7 +317,6 @@ static int __bprm_mm_init(struct linux_binprm *bprm) goto err; mm->stack_vm = mm->total_vm = 1; - arch_bprm_mm_init(mm, vma); up_write(&mm->mmap_sem); bprm->p = vma->vm_end - sizeof(void *); return 0; diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h index 8ac4e68..40038d0 100644 --- a/include/asm-generic/mm_hooks.h +++ b/include/asm-generic/mm_hooks.h @@ -17,17 +17,6 @@ static inline void arch_exit_mmap(struct mm_struct *mm) { } -static inline void arch_unmap(struct mm_struct *mm, - struct vm_area_struct *vma, - unsigned long start, unsigned long end) -{ -} - -static inline void arch_bprm_mm_init(struct mm_struct *mm, - struct vm_area_struct *vma) -{ -} - static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write, bool execute, bool foreign) { diff --git a/mm/mmap.c b/mm/mmap.c index f901065..ca9f43c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2813,12 +2813,6 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, /* Detach vmas from rbtree */ detach_vmas_to_be_unmapped(mm, vma, prev, end); - /* - * mpx unmap needs to be called with mmap_sem held for write. - * It is safe to call it before unmap_region(). - */ - arch_unmap(mm, vma, start, end); - if (downgrade) downgrade_write(&mm->mmap_sem);