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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no 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 BA4E9C33CB3 for ; Thu, 16 Jan 2020 03:14:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8A76D2465A for ; Thu, 16 Jan 2020 03:14:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A76D2465A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 21AB18E002B; Wed, 15 Jan 2020 22:14:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A3D48E0026; Wed, 15 Jan 2020 22:14:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 094778E002B; Wed, 15 Jan 2020 22:14:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id E16448E0026 for ; Wed, 15 Jan 2020 22:14:18 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id A8DA93AB6 for ; Thu, 16 Jan 2020 03:14:18 +0000 (UTC) X-FDA: 76382028996.04.humor67_42a87514d9848 X-HE-Tag: humor67_42a87514d9848 X-Filterd-Recvd-Size: 2577 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 03:14:17 +0000 (UTC) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D32D92D23A1DF1A05B8C; Thu, 16 Jan 2020 11:14:08 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Thu, 16 Jan 2020 11:13:58 +0800 From: Xuefeng Wang To: , , , , CC: , , , , Subject: [PATCH 0/2] mm/thp: rework the pmd protect changing flow Date: Thu, 16 Jan 2020 11:09:15 +0800 Message-ID: <1579144157-7736-1-git-send-email-wxf.wang@hisilicon.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected 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: On KunPeng920 board. When changing permission of a large range region, pmdp_invalidate() takes about 65% in profile (with hugepages) in JIT tool. Kernel will flush tlb twice: first flush happens in pmdp_invalidate, second flush happens at the end of change_protect_range(). The first pmdp_invalidate is not necessary if the hardware support atomic pmdp changing. The atomic changing pimd to zero can prevent the hardware from update asynchronous. So reconstruct it and remove the first pmdp_invalidate. And the second tlb flush can make sure the new tlb entry valid. This patch series add a pmdp_modify_prot transaction abstraction firstly. Then add pmdp_modify_prot_start() in arm64, which uses pmdp_huge_get_and_clear() to atomically fetch the pmd and zero the entry. After rework, the mprotect can get 3~13 times performace gain in range 64M to 512M on KunPeng920: 4K granule/THP on memory size(M) 64 128 256 320 448 512 pre-patch 0.77 1.40 2.64 3.23 4.49 5.10 post-patch 0.20 0.23 0.28 0.31 0.37 0.39 Xuefeng Wang (2): mm: add helpers pmdp_modify_prot_start/commit arm64: mm: rework the pmd protect changing flow arch/arm64/include/asm/pgtable.h | 14 +++++++++++++ include/asm-generic/pgtable.h | 35 ++++++++++++++++++++++++++++++++ mm/huge_memory.c | 19 ++++++++--------- 3 files changed, 57 insertions(+), 11 deletions(-) -- 2.17.1