嵌入式CPU缓存的地址空间区域 [英] Flush cpu cache for a region of address space
问题描述
我感兴趣的冲洗缓存(L1,L2和L3)只为地址空间的区域,例如地址的解决B.所有缓存条目是否有一个机制,在linux这样做呢?
查看此网页在Linux内核中可用的冲水方式的列表:的 https://www.kernel.org/doc/Documentation/cachetlb.txt
Cache和Linux下TLB冲洗。大卫·米勒S.
块引用>有设定的范围内冲洗功能
2)flush_cache_range(VMA,开始,结束);
change_range_of_page_tables(毫米,开始,结束);
flush_tlb_range(VMA,开始,结束);
3)无效flush_cache_range(结构的vm_area_struct * VMA,
无符号长启动,无符号长端)
块引用>在这里,我们潮红(用户)的虚拟的特定范围
从高速缓存地址。运行后,将不会有
在虚拟地址;'vm_mm的vma-&GT在缓存条目
范围内'开始'到'端-1。您也可以检查执行的功能 - 的http:// LXR 。免费-electrons.com / IDENT A = SH; I = flush_cache_range
例如,在胳膊 - 的 http://lxr.free-electrons.com/source/arch/arm/mm/flush.c?a=sh&v=3.13#L67
67虚空flush_cache_range(结构的vm_area_struct * VMA,无符号长启动,无符号长端)
68 {
69如果(cache_is_vivt()){
70 vivt_flush_cache_range(VMA,开始,结束);
71返回;
72}
73
74如果(cache_is_vipt_aliasing()){
75 ASM(MCR P15,0,0%,C7,C14,0 \\ n
76MCR P15,0,%0,C7,C10,4 -
77:
78:R(0)
79:CC);
80}
81
82,如果(的vma-> vm_flags&安培; VM_EXEC)
83 __flush_icache_all();
84}I am interested in flushing cache (L1, L2, and L3) only for a region of address space, for example all cache entries from address A to address B. Is there a mechanism to do so in linux?
解决方案Check this page for list of available flushing methods in linux kernel: https://www.kernel.org/doc/Documentation/cachetlb.txt
Cache and TLB Flushing Under Linux. David S. Miller
There are set of range flushing functions
2) flush_cache_range(vma, start, end); change_range_of_page_tables(mm, start, end); flush_tlb_range(vma, start, end);
3) void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
Here we are flushing a specific range of (user) virtual addresses from the cache. After running, there will be no entries in the cache for 'vma->vm_mm' for virtual addresses in the range 'start' to 'end-1'.
You can also check implementation of the function - http://lxr.free-electrons.com/ident?a=sh;i=flush_cache_range
For example, in arm - http://lxr.free-electrons.com/source/arch/arm/mm/flush.c?a=sh&v=3.13#L67
67 void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) 68 { 69 if (cache_is_vivt()) { 70 vivt_flush_cache_range(vma, start, end); 71 return; 72 } 73 74 if (cache_is_vipt_aliasing()) { 75 asm( "mcr p15, 0, %0, c7, c14, 0\n" 76 " mcr p15, 0, %0, c7, c10, 4" 77 : 78 : "r" (0) 79 : "cc"); 80 } 81 82 if (vma->vm_flags & VM_EXEC) 83 __flush_icache_all(); 84 }
这篇关于嵌入式CPU缓存的地址空间区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!