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=-13.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 33AB8C43461 for ; Mon, 7 Sep 2020 13:11:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AFBEA20768 for ; Mon, 7 Sep 2020 13:11:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFBEA20768 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DC0B56B0003; Mon, 7 Sep 2020 09:10:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D71146B0037; Mon, 7 Sep 2020 09:10:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C620D6B0055; Mon, 7 Sep 2020 09:10:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id B19BF6B0003 for ; Mon, 7 Sep 2020 09:10:58 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6DD1F181AC9C6 for ; Mon, 7 Sep 2020 13:10:58 +0000 (UTC) X-FDA: 77236300596.13.toes77_530e4a2270cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 4223518140B67 for ; Mon, 7 Sep 2020 13:10:58 +0000 (UTC) X-HE-Tag: toes77_530e4a2270cc X-Filterd-Recvd-Size: 11525 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Sep 2020 13:10:56 +0000 (UTC) Received: from [10.20.42.25] (unknown [10.20.42.25]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxL95RMVZfSm0SAA--.2159S3; Mon, 07 Sep 2020 21:10:42 +0800 (CST) Subject: Re: [PATCH] MIPS: make userspace mapping young by default To: Huang Pei Cc: Thomas Bogendoerfer , ambrosehua@gmail.com, Andrew Morton , linux-mips@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, Jiaxun Yang , Paul Burton , Li Xuefeng , Yang Tiezhu , Gao Juxin , Fuxin Zhang , Huacai Chen References: <20200904084926.20924-1-huangpei@loongson.cn> <27a393fa-f00b-fbcc-0d3b-529113bc0e61@loongson.cn> <20200907103551.2pkntwm66t3yma6u@ambrosehua-HP-xw6600-Workstation> From: maobibo Message-ID: <3802163b-0182-9b5e-4230-1b337ccba361@loongson.cn> Date: Mon, 7 Sep 2020 21:10:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200907103551.2pkntwm66t3yma6u@ambrosehua-HP-xw6600-Workstation> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID:AQAAf9DxL95RMVZfSm0SAA--.2159S3 X-Coremail-Antispam: 1UD129KBjvJXoW3JFW8Zw1UGF1rCF1DZryUtrb_yoWfGF1xpa s7CFy0yay3Xry3AryxZwnrAw1rAwsFqFy8XwnrG3W5X343Z34ktrs8KrZ3ZrykuFZ2kw48 ZF1UXr4rWa9I9rUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9l14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IY64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY 04v7Mxk0xIA0c2IEe2xFo4CEbIxvr21lc2xSY4AK6svPMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r 4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Rspamd-Queue-Id: 4223518140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 09/07/2020 06:35 PM, Huang Pei wrote: > On Mon, Sep 07, 2020 at 04:50:45PM +0800, maobibo wrote: >> Sorry for the late reply. >> >> Would you like to remove definition of macro pte_sw_mkyoung in header >> file include/linux/pgtable.h, since it is not used any more. >> >> The others look good to me. >> >> regards >> bibo,mao >> >> On 09/04/2020 04:49 PM, Huang Pei wrote: >>> This version removes pte_sw_mkyoung without polluting MM code and covers >>> both no-RIXI and RIXI MIPS CPUs and makes page fault delay of MIPS on par >>> with other architecture >>> >>> MIPS page fault path take 3 exceptions (1 TLB Miss + 2 TLB Invalid), but >>> the second TLB Invalid exception is just triggered by __update_tlb from >>> do_page_fault writing tlb without _PAGE_VALID set. By making userspace >>> mapping young by default, aka _PAGE_VALID and _PAGE_ACCESSED both set in >>> prot, it only take 1 TLB Miss + 1 TLB Invalid exceptions >>> >>> [1]: https://lkml.kernel.org/lkml/1591416169-26666-1-git-send-email >>> -maobibo@loongson.cn/ >>> >>> Co-developed-by: Bibo Mao >>> Co-developed-by: Huang Pei >>> Signed-off-by: Huang Pei >>> --- >>> arch/mips/include/asm/pgtable.h | 32 +++++++++++++++----------------- >>> arch/mips/mm/cache.c | 25 +++++++++++++------------ >>> mm/memory.c | 3 --- >>> 3 files changed, 28 insertions(+), 32 deletions(-) >>> >>> diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h >>> index dd7a0f552cac..aaafe3d6a0a1 100644 >>> --- a/arch/mips/include/asm/pgtable.h >>> +++ b/arch/mips/include/asm/pgtable.h >>> @@ -25,22 +25,22 @@ >>> struct mm_struct; >>> struct vm_area_struct; >>> >>> -#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_NO_READ | \ >>> - _page_cachable_default) >>> -#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \ >>> - _page_cachable_default) >>> -#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_NO_EXEC | \ >>> - _page_cachable_default) >>> -#define PAGE_READONLY __pgprot(_PAGE_PRESENT | \ >>> - _page_cachable_default) >>> -#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ >>> - _PAGE_GLOBAL | _page_cachable_default) >>> -#define PAGE_KERNEL_NC __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ >>> - _PAGE_GLOBAL | _CACHE_CACHABLE_NONCOHERENT) >>> -#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \ >>> - _page_cachable_default) >>> +#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_NO_READ | \ >>> + _page_cachable_default) >>> +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \ >>> + __READABLE | _page_cachable_default) >>> +#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_NO_EXEC | \ >>> + __READABLE | _page_cachable_default) >>> +#define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE | \ >>> + _page_cachable_default) >>> +#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ >>> + _PAGE_GLOBAL | _page_cachable_default) >>> +#define PAGE_KERNEL_NC __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ >>> + _PAGE_GLOBAL | _CACHE_CACHABLE_NONCOHERENT) >>> +#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \ >>> + _page_cachable_default) >>> #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \ >>> - __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED) >>> + __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED) >>> >>> /* >>> * If _PAGE_NO_EXEC is not defined, we can't do page protection for >>> @@ -414,8 +414,6 @@ static inline pte_t pte_mkyoung(pte_t pte) >>> return pte; >>> } >>> >>> -#define pte_sw_mkyoung pte_mkyoung >>> - >>> #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT >>> static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_HUGE; } >>> >>> diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c >>> index 3e81ba000096..ed75f2871aad 100644 >>> --- a/arch/mips/mm/cache.c >>> +++ b/arch/mips/mm/cache.c >>> @@ -159,22 +159,23 @@ static inline void setup_protection_map(void) >>> { >>> if (cpu_has_rixi) { >>> protection_map[0] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); >>> - protection_map[1] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); >>> + protection_map[1] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | __READABLE); >>> protection_map[2] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); >>> - protection_map[3] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); >>> - protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> - protection_map[5] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> - protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> - protection_map[7] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> + protection_map[3] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | __READABLE); >>> + protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> + protection_map[5] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> + protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> + protection_map[7] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> >>> protection_map[8] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); >>> - protection_map[9] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); >>> + protection_map[9] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | __READABLE); >>> protection_map[10] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ); >>> - protection_map[11] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); >>> - protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> - protection_map[13] = __pgprot(_page_cachable_default | _PAGE_PRESENT); >>> - protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE); >>> - protection_map[15] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE); >>> + protection_map[11] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | __READABLE); >>> + protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> + protection_map[13] = __pgprot(_page_cachable_default | _PAGE_PRESENT | __READABLE); >>> + protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | __READABLE); >>> + protection_map[15] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | __READABLE); >>> + >>> >>> } else { >>> protection_map[0] = PAGE_NONE; >>> diff --git a/mm/memory.c b/mm/memory.c >>> index 602f4283122f..5100ab5bcf77 100644 >>> --- a/mm/memory.c >>> +++ b/mm/memory.c >>> @@ -2705,7 +2705,6 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) >>> } >>> flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); >>> entry = mk_pte(new_page, vma->vm_page_prot); >>> - entry = pte_sw_mkyoung(entry); >>> entry = maybe_mkwrite(pte_mkdirty(entry), vma); >>> /* >>> * Clear the pte entry and flush it first, before updating the >>> @@ -3386,7 +3385,6 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) >>> __SetPageUptodate(page); >>> >>> entry = mk_pte(page, vma->vm_page_prot); >>> - entry = pte_sw_mkyoung(entry); >>> if (vma->vm_flags & VM_WRITE) >>> entry = pte_mkwrite(pte_mkdirty(entry)); >>> >>> @@ -3661,7 +3659,6 @@ vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct page *page) >>> >>> flush_icache_page(vma, page); >>> entry = mk_pte(page, vma->vm_page_prot); >>> - entry = pte_sw_mkyoung(entry); >>> if (write) >>> entry = maybe_mkwrite(pte_mkdirty(entry), vma); >>> /* copy-on-write page */ >>> > > I search for pte_sw_mkyoung/pte_{clear,mk,}_savewrite, none of which is > used, do I really need to remove pte_sw_mkyoung in this patch just for > *not used* ? > macro pte_sw_mkyoung is added by me previously, and it is defined as empty excepts mips system. If it is not used any more on mips sytem, I suggest that it should be removed here. regards bibo,mao