影响界面刷新的一个问题

    技术2022-05-20  59

    这个问题的发现也是在实际工作中才发现的,可以说是隐藏的比较深吧。问题描述:2440的BSP包从5.0升级到6.0后,发现界面的刷新效率会有一个明显的下降(经大概测试全屏刷图会有2到3倍的下降)。刚开始以为是显示驱动的问题,但是借鉴了6410的驱动架构进行修改后问题依旧,最后在网上(见引用一)找到了最接近的答案。************************************************Question:Hi guys, I have a project using CE6.0, HW platform is samsung S3C2440, 64MB SDR. The problem is: When I call CreateDibSection in my app, it always set PAGE_NOCACHE to the memory it allocated. That I believe caused my bitblt and other access to the memory really slow, about 3~4 times slower than a memory alloctaed by new. I tried CE5.0 on the same HW, CreateDibSection works fine on that, no PAGE_NOCACHE flag set to the memory it allocated, and the app runs fast. But it's jus a test, I can't really use CE5 for the project. So please help~~, what is the possible cause to the PAGE_NOCACHE problem?? Answer:It is possible due to your CPU is virtual tag cache; in CE6, kernel adds PAGE_NOCACHE attribute when VirtualAllocCopy an existing memory (2 VA map to on PA) to avoid cache coherency issue. In case you are interested, trace the code in PROCVMAllocCopy (private/winceos/COREOS/nk/kernel/process.c) and then to VMAlias in (private/winceos/COREOS/nk/kernel/vm.c) It seems you don't have much choice, either upgrade the hardware to ARMV6 based system or back to CE5.这段话大概的意思是ARMV5架构的CPU是用的virtual tag cache,CE6的内核在进行内存分配的时候根据这个情况会将内存打上PAGE_NOCACHE标志,而CE5则没有做这个处理。所以CE6下贴图要比CE5下慢,在CE6的PROCVMAllocCopy 和VMAlias函数中都有一个进行判断的函数IsVirtualTaggedCache,其代码如下#ifdef ARM #define ARMArchitectureV6 0x7 #define ARCHID_OFFSET 0x02a0 #define IsVirtualTaggedCache() (__GetUserKData (ARCHID_OFFSET) < ARMArchitectureV6) #endif 而在CE5中没有找到相关的代码,可能是未开源。************************************************关于virtual tag cache的作用,找到了下面一些信息:Question:ARM926的L1 Cache是Virtual Tag, Virtual Index的。ARM1176的L1 Cache是Physical Tag,Virtual index的。与此相关的问题,是在支持OS、Task context switching方面的效率高低。请大家说说,怎样理解ARM9->ARM11的这点变化,另外,ARM9中设计的process id、FCSE等机制,与L1 Cache是采用实地址、虚拟地址,有什么具体联系呢?Answer:对ARM不是很熟,但这种机制还是比较清楚,简单的说,主要是与性能和面积相关,因为采用Virtual Tag方式,在多进程环境下,不同的进程可能有同样的虚地址,为了解决这个问题,可以有如下办法:1:Virtual Tag中不仅要存储Virtual-Addr,还要存储Processor-ID号,从而增加了存储器的面积,也增加了比较逻辑(通常虚地址比物理地址大,再加ID号);2:采用所谓的别名机制,但增加了逻辑的复杂性;3:Virtual Tag存储阵列中不保存ID号,但进程切换的时候,将cache中上一个进程的内容全部从Cache写回到主存,并直置无效Cache,这自然增加了软件开销;这是Virtual Tag的缺点,其优点在哪呢?优点是:访问Cache的时候,不必进行TLB转换,直接拿虚地址,就知道数据是不是在Cache中,如果不在Cache中,再将虚地址TLB转换成物理地址,从外部存储器取数据进来。而采用Physical Tag恰恰与Virtual-Tag机制相反。而Virtual index的条件是,每个Bank的Cache容量<=页面大小;如果想要Cache容量大些,但页面比较小(页面的大小主要与软件的兼容性相关,因为早期的OS支持的页面不大,所以页面大小不会轻易变化),通常采用多个Bank进行关联;************************************************引用链接:引用一:http://msgroups.net/microsoft.public.windowsce.platbuilder/CE6.0-DIBSection-is-PAGE_NOCACHE-Why引用二:http://xilinx.eetop.cn/viewthread-133005


    最新回复(0)