Skip to content

Commit 1f62ed0

Browse files
committed
csky: mmu: Prevent spurious page faults
C-SKY MMU would pre-fetch invalid pte entries, and it could work with flush_tlb_fix_spurious_fault, but the additional page fault exceptions would reduce performance. So flushing the entry of the TLB would prevent the following spurious page faults. Here is the test code: define DATA_LEN 4096 define COPY_NUM (504*100) unsigned char src[DATA_LEN*COPY_NUM] = {0}; unsigned char dst[DATA_LEN*COPY_NUM] = {0}; unsigned char func_src[DATA_LEN*COPY_NUM] = {0}; unsigned char func_dst[DATA_LEN*COPY_NUM] = {0}; void main(void) { int j; for (j = 0; j < COPY_NUM; j++) memcpy(&dst[j*DATA_LEN], &src[j*DATA_LEN], 4); } perf stat -e page-faults ./main.elf The amount of page fault traps would be reduced in half with the patch. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org>
1 parent 74c53b5 commit 1f62ed0

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

arch/csky/abiv1/cacheflush.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/cache.h>
1212
#include <asm/cacheflush.h>
1313
#include <asm/cachectl.h>
14+
#include <asm/tlbflush.h>
1415

1516
#define PG_dcache_clean PG_arch_1
1617

@@ -40,6 +41,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
4041
unsigned long pfn = pte_pfn(*ptep);
4142
struct page *page;
4243

44+
flush_tlb_page(vma, addr);
45+
4346
if (!pfn_valid(pfn))
4447
return;
4548

arch/csky/abiv2/cacheflush.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
#include <linux/highmem.h>
66
#include <linux/mm.h>
77
#include <asm/cache.h>
8+
#include <asm/tlbflush.h>
89

910
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
1011
pte_t *pte)
1112
{
1213
unsigned long addr;
1314
struct page *page;
1415

16+
flush_tlb_page(vma, address);
17+
1518
if (!pfn_valid(pte_pfn(*pte)))
1619
return;
1720

0 commit comments

Comments
 (0)