__get_contiguous_pages () 이 함수 아시는분? 정말 없나용???
글쓴이: iimec2 / 작성시간: 금, 2006/01/27 - 11:01오전
메모리 allocate하는 함수인데 어떤 알고리즘으로 돌아가는건지
정확히 모르겠습니다 .
look through the map for a run of consecutive pages that will + * hold a # of pages + */ + unsigned long __get_contiguous_pages( unsigned int gfp_mask, unsigned long num_adjpages, unsigned int align_order) { unsigned long flags; mem_map_t *p; int repeats = 0; pg_data_t *pgdat; zone_t *zone; DBG_ALLOC("%s,%d: %s(0x%x, %d, %d) - mem_map=0x%x\n", __FILE__, __LINE__, __FUNCTION__, gfp_mask, num_adjpages, align_order, mem_map); save_flags(flags); if (waitqueue_active(&kswapd_wait)) wake_up_interruptible(&kswapd_wait); repeat: cli(); /* * Don't bother trying to find pages unless there are enough * for the given context */ if (num_adjpages <= _nr_free_pages) { int n = 0, little_alloc = 0, ff; p = NULL; if (num_adjpages <= 2) little_alloc = bit_map_size; ff = find_next_zero_bit(bit_map, bit_map_size, num_adjpages <= 2 ? (little_alloc -= 16) : first_usable_page); while (ff + num_adjpages <= bit_map_size || little_alloc > 0) { if (ff + num_adjpages <= bit_map_size) { p = mem_map + ff; if (((unsigned long) page_address(p)) & ((PAGE_SIZE << align_order) - 1)) n = 0; else for (n = 0; n < num_adjpages; n++, p++) { if (test_bit(p-mem_map, bit_map)) break; #if 0 if (dma && !PageDMA(p)) break; #endif } if (n >= num_adjpages) break; } ff = find_next_zero_bit(bit_map, bit_map_size, num_adjpages <= 2 ? (little_alloc -= 16) : (ff + n + 1)); } if (p && n >= num_adjpages) { _nr_free_pages -= num_adjpages; while (n-- > 0) { p--; #ifdef SADISTIC_PAGE_ALLOC if (atomic_read(&p->count)) printk("allocated a non-free page\n"); #endif set_page_count(p, 1); set_bit(p-mem_map, bit_map); p->index = 0xa1c20000 | num_adjpages; if (num_adjpages > 0xffff) BUG(); } #ifdef SADISTIC_PAGE_ALLOC mem_test((char *) page_address(p), num_adjpages * PAGE_SIZE); mem_set((char *) page_address(p), num_adjpages * PAGE_SIZE); #endif DBG_ALLOC(" return(0x%x[p=0x%x])\n", page_address(p), p); pgdat = pgdat_list; do { /* try and keep memory freed */ int i; for (i = pgdat->nr_zones-1; i >= 0; i--) { zone = pgdat->node_zones + i; zone->need_balance = 1; } } while ((pgdat = pgdat->node_next)); restore_flags(flags); return((unsigned long) page_address(p)); } } restore_flags(flags); if ((current->flags & PF_MEMALLOC) == 0) { find_some_memory(3); if (repeats++ < 3) goto repeat; printk("%s: allocation of %d pages failed!\n", current->comm, (int) num_adjpages); #ifdef CONFIG_MEM_MAP mem_map_read_proc(NULL, NULL, 0, 0, 0, 0); #endif out_of_memory(); /* call this too often and we panic */ } return(0); }
이소스 해석줌..
Forums:
댓글 달기