how does linux avoid cache alias on mips platform

2006/5/6 11:54:11
1. initialize cache sets and cache line size in probe_pcache()
2.initialize 
        shm_align_mask = max_t( unsigned long,
                                c->dcache.sets * c->dcache.linesz - 1,
                                PAGE_SIZE - 1); in r4k_cache_init()
        caculate the size of pcache , and minus 1, got cache mask
 
3.let's look at how does linux avoid cache alias.
do_mmap_pgoff --->get_unmapped_area-->get_unmapped_area(arch_get_unmapped_area)

the first place:
        if (flags & MAP_FIXED) {
                /*
                 * We do not accept a shared mapping if it would violate
                 * cache aliasing constraints.
                 */
                if ((flags & MAP_SHARED) && (addr & shm_align_mask))
                        return -EINVAL;
                return addr;
        }
the second place:
                        ........
                        if (do_color_align)
                        addr = COLOUR_ALIGN(addr, pgoff);
                        .......
 
 
got it ? :)
posted @ 2011-04-05 13:41  konggang  阅读(309)  评论(0)    收藏  举报