Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1260979ybk; Thu, 14 May 2020 04:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOMG7WmJhJM2j4vgktp3EJ4QbQMb8yn1FPfjZi7/OlzNn2fag8abo9Oi5IfIlR98QqzlAe X-Received: by 2002:a17:906:4886:: with SMTP id v6mr1086373ejq.11.1589456607522; Thu, 14 May 2020 04:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589456607; cv=none; d=google.com; s=arc-20160816; b=w0+oanI6nJXtuumpjHKImbTGGaTDyzapwHS3iLr+LjP1yyPWiaUOV0oVuSE2RmPhmS LS6BF/rnxjpZgUJCvKmIoeWcINX1W/vtuY0Z+57jZ/ACepjCcYmEtinLPgo3XFdp7Gxb 6ZtohGYxXzvAuPCxOeDG/LmQochljr5EAmJ5vVB60lOdXkDvp7P4MXoefH8IIL5Sg/4F wrAb7ZQSud7CUbLFX0anyGHuI0HzFu810siLcoEK4slRZ6Y3G3nyWrFXl4/UewiWCEjJ 8elp7znQbh8CQQ/pI5u7hyxzhXP/nM4THilBNICRbsGQCXj4IEy2AGcsBa5O40qj+MHk JgUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=dngj1zj4DhckAgBfd2M4Sg51DnfwrtRS5KPXsETEJnU=; b=KaokbRoOinezHx+5zXb6uzqbIxsVi4eTfwc0cMSliU1oANmBsavP4dEQa2538WHl4U LRLsZersVDEL2LvYF1GtQD0f9s0mgm6mLxVdGeY1yvNgJf3kOiYWEHfEahy9QGjHYdVc gqa/hC4pm94/9vZN2tAbDY9PTvCdVxB04TNFNWXsa0g9nUi20thhJ4cLxKfFSAfRYs6z oV2zaYC6D2I5v8m8bHqAF5VBZkzMYIQQogQjnGjfSERT59p9XNJezGBadmq1XRDB5jmm abPgCsELS6KvRQ/rtW3J1JfH1yzOtzfQ2zltSsNX5ta6Ini6EvrUXhh86WDX5D2MeBJ6 eUSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si1476496edm.95.2020.05.14.04.43.03; Thu, 14 May 2020 04:43:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbgENLkj (ORCPT + 99 others); Thu, 14 May 2020 07:40:39 -0400 Received: from mail.loongson.cn ([114.242.206.163]:51860 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725925AbgENLkj (ORCPT ); Thu, 14 May 2020 07:40:39 -0400 Received: from [10.20.42.25] (unknown [10.20.42.25]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxn98kLr1eYKQ0AA--.4S3; Thu, 14 May 2020 19:40:21 +0800 (CST) Subject: Re: [PATCH] MIPS: update tlb even if pte entry has no change To: Mike Rapoport References: <1589422677-11455-1-git-send-email-maobibo@loongson.cn> <20200514093359.GB1059226@linux.ibm.com> Cc: Thomas Bogendoerfer , Andrew Morton , Paul Burton , Dmitry Korotin , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , Stafford Horne , Steven Price , Anshuman Khandual , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org From: maobibo Message-ID: <1abd8a86-6e04-b69b-6f25-c3ff8201ea5d@loongson.cn> Date: Thu, 14 May 2020 19:40:20 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20200514093359.GB1059226@linux.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9Dxn98kLr1eYKQ0AA--.4S3 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrWUCw1UAw1rXF15CrW8tFb_yoW8ZrWrpF Z7A3ZagFZ7J34Ik3ySqrn8KFy3G3y8KFs7KryxKF1Yy3ZI9F1rGrWfK3yFkrWrZa9rKa18 uFW09F4DWa12y3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvKb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7 Mxk0xIA0c2IEe2xFo4CEbIxvr21l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07beAp5UUUUU= X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/14/2020 05:33 PM, Mike Rapoport wrote: > On Thu, May 14, 2020 at 10:17:57AM +0800, Bibo Mao wrote: >> From: bibo mao >> >> If there are two threads reading the same memory and tlb miss happens, >> one thread fills pte entry, the other reads new pte value during page fault >> handling. PTE value may be updated before page faul, so the process need >> need update tlb still. >> >> Also this patch define flush_tlb_fix_spurious_fault as empty, since it not >> necessary to flush the page for all CPUs > > I'm not familiar enough with MIPS TLB workings, but it seems that adding > a MIPS version of ptep_set_access_flags() and relaxing > flush_tlb_fix_spurious_fault() are two separate patches. Well, will split it into two patches. regards bibo, mao > >> Signed-off-by: Bibo Mao >> --- >> arch/mips/include/asm/pgtable.h | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h >> index aab0ec1..d0a4940 100644 >> --- a/arch/mips/include/asm/pgtable.h >> +++ b/arch/mips/include/asm/pgtable.h >> @@ -635,6 +635,26 @@ static inline pmd_t pmd_mknotpresent(pmd_t pmd) >> return pmd; >> } >> >> +#define flush_tlb_fix_spurious_fault(vma, address) do { } while (0) >> + >> +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS >> +int ptep_set_access_flags(struct vm_area_struct *vma, >> + unsigned long address, pte_t *ptep, >> + pte_t entry, int dirty) >> +{ >> + int changed = !pte_same(*ptep, entry); >> + >> + if (changed) >> + set_pte_at(vma->vm_mm, address, ptep, entry); >> + else >> + /* update tlb with latest pte entry still, tlb entry is old >> + * since there is page fault >> + */ >> + update_mmu_cache(vma, address, ptep); >> + >> + return changed; >> +} >> + >> /* >> * The generic version pmdp_huge_get_and_clear uses a version of pmd_clear() with a >> * different prototype. >> -- >> 1.8.3.1 >> >