From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FBD2C43381 for ; Mon, 18 Feb 2019 14:17:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41872217D7 for ; Mon, 18 Feb 2019 14:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550499433; bh=to5i0QYXJnXr8R0ip+glezZKoUL8Uyd9lDO2IBx3H70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=O3QX2n0VMN3iU6zFpdBJ1UVIilYLSO72GYINfyaHcPshN07Fmc+/6yjPLrsw7cQC9 tkAZMyWr2BUYdS4Cvymj32cfjW34hWQih/7P93la+5eGj0xqs0wH6Zl89OqlgA8ne1 ZtggGfk/F2eKecmtph/CWCwO9MfnuIiIjsx5FPJI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391413AbfBROKK (ORCPT ); Mon, 18 Feb 2019 09:10:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:53826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391397AbfBROKH (ORCPT ); Mon, 18 Feb 2019 09:10:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 277FA217D7; Mon, 18 Feb 2019 14:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550499006; bh=to5i0QYXJnXr8R0ip+glezZKoUL8Uyd9lDO2IBx3H70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=adjcvm5OR1O7F6/kJMC2TE3GmyvsWPqmUOPP+0Xc+O8FsIRYAPh5ohqN76T5CImyi a8YZCRx3b87r9yqoUVjokkN2cCGhCuKPnVOTe4kOJhI+3HMLBmW83J25V33yOY3blp t+6gjAsHVbZh4mPXy+gUWZrLBiwjJM2MZKrR/w4k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 3.18 046/108] um: Avoid marking pages with "changed protection" Date: Mon, 18 Feb 2019 14:43:42 +0100 Message-Id: <20190218133521.661077196@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133519.525507231@linuxfoundation.org> References: <20190218133519.525507231@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8892d8545f2d0342b9c550defbfb165db237044b ] Changing protection is a very high cost operation in UML because in addition to an extra syscall it also interrupts mmap merge sequences generated by the tlb. While the condition is not particularly common it is worth avoiding. Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/include/asm/pgtable.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index bf974f712af7..e75fa226f08a 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -210,12 +210,17 @@ static inline pte_t pte_mkold(pte_t pte) static inline pte_t pte_wrprotect(pte_t pte) { - pte_clear_bits(pte, _PAGE_RW); + if (likely(pte_get_bits(pte, _PAGE_RW))) + pte_clear_bits(pte, _PAGE_RW); + else + return pte; return(pte_mknewprot(pte)); } static inline pte_t pte_mkread(pte_t pte) { + if (unlikely(pte_get_bits(pte, _PAGE_USER))) + return pte; pte_set_bits(pte, _PAGE_USER); return(pte_mknewprot(pte)); } @@ -234,6 +239,8 @@ static inline pte_t pte_mkyoung(pte_t pte) static inline pte_t pte_mkwrite(pte_t pte) { + if (unlikely(pte_get_bits(pte, _PAGE_RW))) + return pte; pte_set_bits(pte, _PAGE_RW); return(pte_mknewprot(pte)); } -- 2.19.1