linux-lts-quantal-3.5.0/kernel/replay.c
// Preallocate any reserved regions that do not conflict with the existing mappings
Preallocate any reserved regions that do not conflict with the existing mappings
Preallocate any reserved regions that do not conflict with the existing mappings
static void 
preallocate_memory (struct record_group* prg)
{
	struct vm_area_struct* vma;
	ds_list_iter_t* iter;
	struct reserved_mapping* pmapping;
	u_long begin_at;
	iter = ds_list_iter_create (prg->rg_reserved_mem_list);
	while ((pmapping = ds_list_iter_next (iter)) != NULL) {
		MPRINT ("Considering pre-allocation from %lx to %lx\n", pmapping->m_begin, pmapping->m_end);
		down_read (&current->mm->mmap_sem);
		begin_at = pmapping->m_begin;
		for (vma = current->mm->mmap; vma; vma = vma->vm_next) {
			MPRINT ("\tConsider vma from %lx to %lx\n", vma->vm_start, vma->vm_end);
			if (vma->vm_start > pmapping->m_end) {
				up_read (&current->mm->mmap_sem);
				do_preallocate (begin_at, pmapping->m_end);  
				down_read (&current->mm->mmap_sem);
				break;
			}
			if (vma->vm_end > begin_at && vma->vm_start < pmapping->m_end) {
				MPRINT ("\tConflict\n");
				if (vma->vm_start > begin_at) {
					up_read (&current->mm->mmap_sem);
					do_preallocate (begin_at, vma->vm_start); 
					down_read (&current->mm->mmap_sem);
				}
				if (vma->vm_end < pmapping->m_end) { 
					begin_at = vma->vm_end; 
					MPRINT ("\tConsidering only from %lx now\n", begin_at);
				} else {
					break;
				}
			}
		}	
		up_read (&current->mm->mmap_sem);
	}
	ds_list_iter_destroy (iter);
}
static void preallocate_memory ( struct record_group * prg ) { struct vm_area_struct * vma ; ds_list_iter_t * iter ; struct reserved_mapping * pmapping ; u_long begin_at ; iter = ds_list_iter_create ( prg -> rg_reserved_mem_list ) ; while ( ( pmapping = ds_list_iter_next ( iter ) ) != NULL ) { MPRINT ( " \n " , pmapping -> m_begin , pmapping -> m_end ) ; down_read ( & current -> mm -> mmap_sem ) ; begin_at = pmapping -> m_begin ; for ( vma = current -> mm -> mmap ; vma ; vma = vma -> vm_next ) { MPRINT ( " \t \n " , vma -> vm_start , vma -> vm_end ) ; if ( vma -> vm_start > pmapping -> m_end ) { up_read ( & current -> mm -> mmap_sem ) ; do_preallocate ( begin_at , pmapping -> m_end ) ; down_read ( & current -> mm -> mmap_sem ) ; break ; } if ( vma -> vm_end > begin_at && vma -> vm_start < pmapping -> m_end ) { MPRINT ( " \t \n " ) ; if ( vma -> vm_start > begin_at ) { up_read ( & current -> mm -> mmap_sem ) ; do_preallocate ( begin_at , vma -> vm_start ) ; down_read ( & current -> mm -> mmap_sem ) ; } if ( vma -> vm_end < pmapping -> m_end ) { begin_at = vma -> vm_end ; MPRINT ( " \t \n " , begin_at ) ; } else { break ; } } } up_read ( & current -> mm -> mmap_sem ) ; } ds_list_iter_destroy ( iter ) ; }
Preallocate any reserved regions that do not conflict with the existing mappings
Preallocate any reserved regions that do not conflict with the existing mappings
// Any conflicting VMAs? // No more mappings that will conflict // Allocate region before VM region // Consider area after VM region only