Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp981640ybk; Wed, 13 May 2020 19:20:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxov1lJHM/yyX1YzTedvVDz0kJxFXpp4KDge98SmkQ/ZOTpLIMQi6A+EhNgwPnGaM+zSpd5 X-Received: by 2002:a17:906:f98f:: with SMTP id li15mr1747048ejb.259.1589422810057; Wed, 13 May 2020 19:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589422810; cv=none; d=google.com; s=arc-20160816; b=E8v9Qx/1LZAZcvkF/TJXrwxmlQaK9E5uoIfMeGhJMHx+WcusdQqnFETVjT+XveSFAE JqUPX4PM29HJWCdDIX/PQw8SBWqxz2fmhG2CbRQVs8JWFWUxD6c/bSjSQGSHJEa7UF7/ cu0PcmjT5hMG7ikYxFds5G040D9KbKCm+fvQvDNrHMF7GrdBVFivnaqfTDKROf46xa9U 8JfL1ltI3pOa/oKyk0BHHMvJ2yD0fTQnGe4fWCD1rToZtfH/hyzJXz1M1aIeXkC8LSiz 1uecb9lASFlKxKIjdnYuLdkFQUvSJxBHCEDVmc1CD0P1qZdkyEb8kwbTDMhSk+o5DolU QyJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=DWFWMNgtMCwbaRvCEbg8/UFj6qnaSChOKeYg4eS1om0=; b=tSgeRXGzd5oTerodWae0XIrb8SsRHx7ApCTkLnXOajjyyFVXxeTeQFgc6ngfWcfZmZ hSYOqhu6L1okocbhexjxaiLGfLv/RrCG/b1wVBxegbN1JzM+883ih6/mPKeGavhOgTeG PkgmZ7Pp502W8KaLNxs6drOHl2hCafa+M/cyo85KPQnrUjEXB/lEZaZxGdDC+qI5dKve RjbHYcxM87biriPax4t7mkZLGNLl3abo2FoWHoxNCriZWrCNKdOHHlkFzLgCz0PoeyMZ yGGYobLAtCyDdvVxSWZFmqF7/sxjtuwYNE4gSNlwMzo7xXiMXzWM1U0BuR7DN2yVCMIi FLEw== 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 oq5si962648ejb.395.2020.05.13.19.19.47; Wed, 13 May 2020 19:20:10 -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 S1726032AbgENCSZ (ORCPT + 99 others); Wed, 13 May 2020 22:18:25 -0400 Received: from mail.loongson.cn ([114.242.206.163]:45450 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725943AbgENCSY (ORCPT ); Wed, 13 May 2020 22:18:24 -0400 Received: from kvm-dev1.localdomain (unknown [10.2.5.134]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx79xcqrxeenY0AA--.31S2; Thu, 14 May 2020 10:18:06 +0800 (CST) From: Bibo Mao To: Thomas Bogendoerfer , Andrew Morton , Paul Burton , Dmitry Korotin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stafford Horne , Steven Price , Anshuman Khandual , Mike Rapoport Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, bibo mao Subject: [PATCH] MIPS: update tlb even if pte entry has no change Date: Thu, 14 May 2020 10:17:57 +0800 Message-Id: <1589422677-11455-1-git-send-email-maobibo@loongson.cn> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: AQAAf9Dx79xcqrxeenY0AA--.31S2 X-Coremail-Antispam: 1UD129KB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el-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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