linux-lts-quantal-3.5.0/kernel/replay.c
/* Creates a new record group for the recording process info */
Creates a new record group for the recording process info
Creates a new record group for the recording process info
static struct record_group*
new_record_group (char* logdir)
{
	struct record_group* prg;
	MPRINT ("Pid %d new_record_group: entered\n", current->pid);
	prg = KMALLOC (sizeof(struct record_group), GFP_KERNEL);
	if (prg == NULL) {
		printk ("Cannot allocate record_group\n");
		goto err;
	}
	if (logdir == NULL) {
		prg->rg_id = get_replay_id();
		if (prg->rg_id == 0) {
			printk ("Cannot get replay id\n");
			goto err_free;
		}
	}
#ifdef REPLAY_LOCK_DEBUG
	sema_init(&prg->rg_sem, 1);
#else
	mutex_init (&prg->rg_mutex);
#endif	
	atomic_set(&prg->rg_refcnt, 0);
#ifdef TIME_TRICK
	mutex_init (&prg->rg_time_mutex);
#endif
	if (create_shared_clock (prg) < 0) goto err_free;
	if (logdir) {
		strncpy (prg->rg_logdir, logdir, MAX_LOGDIR_STRLEN+1);
	} else {
		make_logdir_for_replay_id (prg->rg_id, prg->rg_logdir);
	}
	memset (prg->rg_linker, 0, MAX_LOGDIR_STRLEN+1);
	prg->rg_mismatch_flag = 0;
	prg->rg_libpath = NULL;
	atomic_set(&prg->rg_record_threads, 0);
	prg->rg_save_mmap_flag = 0;
	prg->rg_reserved_mem_list = ds_list_create (rm_cmp, 0, 1);
	prg->rg_prev_brk = 0;
	MPRINT ("Pid %d new_record_group %lld: exited\n", current->pid, prg->rg_id);
	return prg;
err_free:
	KFREE(prg);
err:
	return NULL;
}
static struct record_group * new_record_group ( char * logdir ) { struct record_group * prg ; MPRINT ( " \n " , current -> pid ) ; prg = KMALLOC ( sizeof ( struct record_group ) , GFP_KERNEL ) ; if ( prg == NULL ) { printk ( " \n " ) ; goto err ; } if ( logdir == NULL ) { prg -> rg_id = get_replay_id ( ) ; if ( prg -> rg_id == 0 ) { printk ( " \n " ) ; goto err_free ; } } #ifdef REPLAY_LOCK_DEBUG sema_init ( & prg -> rg_sem , 1 ) ; #else mutex_init ( & prg -> rg_mutex ) ; #endif atomic_set ( & prg -> rg_refcnt , 0 ) ; #ifdef TIME_TRICK mutex_init ( & prg -> rg_time_mutex ) ; #endif if ( create_shared_clock ( prg ) < 0 ) goto err_free ; if ( logdir ) { strncpy ( prg -> rg_logdir , logdir , MAX_LOGDIR_STRLEN + 1 ) ; } else { make_logdir_for_replay_id ( prg -> rg_id , prg -> rg_logdir ) ; } memset ( prg -> rg_linker , 0 , MAX_LOGDIR_STRLEN + 1 ) ; prg -> rg_mismatch_flag = 0 ; prg -> rg_libpath = NULL ; atomic_set ( & prg -> rg_record_threads , 0 ) ; prg -> rg_save_mmap_flag = 0 ; prg -> rg_reserved_mem_list = ds_list_create ( rm_cmp , 0 , 1 ) ; prg -> rg_prev_brk = 0 ; MPRINT ( " \n " , current -> pid , prg -> rg_id ) ; return prg ; err_free : KFREE ( prg ) ; err : return NULL ; }
Creates a new record group for the recording process info
Creates a new record group for the recording process info