Use always the logical cpu index
This commit is contained in:
		
							parent
							
								
									c42711908b
								
							
						
					
					
						commit
						9c0866cfd9
					
				
							
								
								
									
										12
									
								
								emu.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								emu.h
									
									
									
									
									
								
							| @ -142,14 +142,13 @@ enum ovni_cpu_state { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct ovni_cpu { | struct ovni_cpu { | ||||||
| 	/* Physical id */ | 	/* Logical index: 0 to ncpus - 1 */ | ||||||
| 	int cpu_id; | 	int i; | ||||||
| 
 | 
 | ||||||
| 	/* Position in emu->cpu */ | 	/* Physical id: as reported by lscpu(1) */ | ||||||
| 	int index; | 	int phyid; | ||||||
| 
 | 
 | ||||||
| 	enum ovni_cpu_state state; | 	enum ovni_cpu_state state; | ||||||
| 	//enum ovni_cpu_type type;
 |  | ||||||
| 
 | 
 | ||||||
| 	size_t last_nthreads; | 	size_t last_nthreads; | ||||||
| 
 | 
 | ||||||
| @ -161,11 +160,10 @@ struct ovni_cpu { | |||||||
| struct ovni_emu { | struct ovni_emu { | ||||||
| 	struct ovni_trace trace; | 	struct ovni_trace trace; | ||||||
| 
 | 
 | ||||||
| 	/* Physical CPUs */ |  | ||||||
| 	int max_ncpus; | 	int max_ncpus; | ||||||
|  | 	int max_phyid; | ||||||
| 	int ncpus; | 	int ncpus; | ||||||
| 	struct ovni_cpu cpu[OVNI_MAX_CPU]; | 	struct ovni_cpu cpu[OVNI_MAX_CPU]; | ||||||
| 	int cpuind[OVNI_MAX_CPU]; |  | ||||||
| 
 | 
 | ||||||
| 	/* Virtual CPU */ | 	/* Virtual CPU */ | ||||||
| 	struct ovni_cpu vcpu; | 	struct ovni_cpu vcpu; | ||||||
|  | |||||||
							
								
								
									
										43
									
								
								emu_ovni.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								emu_ovni.c
									
									
									
									
									
								
							| @ -14,7 +14,7 @@ emu_get_cpu(struct ovni_emu *emu, int cpuid) | |||||||
| 		return &emu->vcpu; | 		return &emu->vcpu; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return &emu->cpu[emu->cpuind[cpuid]]; | 	return &emu->cpu[cpuid]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int | int | ||||||
| @ -246,47 +246,46 @@ ev_affinity(struct ovni_emu *emu) | |||||||
| static void | static void | ||||||
| ev_cpu_count(struct ovni_emu *emu) | ev_cpu_count(struct ovni_emu *emu) | ||||||
| { | { | ||||||
| 	int i, ncpus, maxcpu; | 	int i, max_ncpus, max_phyid; | ||||||
| 
 | 
 | ||||||
| 	ncpus = emu->cur_ev->payload.i32[0]; | 	max_ncpus = emu->cur_ev->payload.i32[0]; | ||||||
| 	maxcpu = emu->cur_ev->payload.i32[1]; | 	max_phyid = emu->cur_ev->payload.i32[1]; | ||||||
| 
 | 
 | ||||||
| 	assert(ncpus < OVNI_MAX_CPU); | 	assert(max_ncpus < OVNI_MAX_CPU); | ||||||
| 	assert(maxcpu < OVNI_MAX_CPU); | 	assert(max_phyid < OVNI_MAX_CPU); | ||||||
| 
 | 
 | ||||||
| 	for(i=0; i<OVNI_MAX_CPU; i++) | 	for(i=0; i<OVNI_MAX_CPU; i++) | ||||||
| 	{ | 	{ | ||||||
| 		emu->cpu[i].state = CPU_ST_UNKNOWN; | 		emu->cpu[i].state = CPU_ST_UNKNOWN; | ||||||
| 		emu->cpu[i].cpu_id = -1; | 		emu->cpu[i].i = -1; | ||||||
| 		emu->cpuind[i] = -1; | 		emu->cpu[i].phyid = -1; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	emu->ncpus = 0; | 	emu->ncpus = 0; | ||||||
| 	emu->max_ncpus = ncpus; | 	emu->max_ncpus = max_ncpus; | ||||||
|  | 	emu->max_phyid = max_phyid; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
| ev_cpu_id(struct ovni_emu *emu) | ev_cpu_id(struct ovni_emu *emu) | ||||||
| { | { | ||||||
| 	int cpuid; | 	int i, phyid; | ||||||
| 
 | 
 | ||||||
| 	cpuid = emu->cur_ev->payload.i32[0]; | 	i = emu->cur_ev->payload.i32[0]; | ||||||
|  | 	phyid = emu->cur_ev->payload.i32[1]; | ||||||
| 
 | 
 | ||||||
| 	assert(cpuid < emu->max_ncpus); | 	/* The logical id must match our index */ | ||||||
| 	assert(emu->ncpus < emu->max_ncpus); | 	assert(i == emu->ncpus); | ||||||
| 	assert(emu->ncpus < OVNI_MAX_CPU); |  | ||||||
| 
 | 
 | ||||||
| 	assert(emu->cpu[emu->ncpus].state == CPU_ST_UNKNOWN); | 	assert(0 <= phyid && phyid <= emu->max_phyid); | ||||||
|  | 
 | ||||||
|  | 	assert(emu->cpu[i].state == CPU_ST_UNKNOWN); | ||||||
| 
 | 
 | ||||||
| 	emu->cpu[emu->ncpus].state = CPU_ST_READY; | 	emu->cpu[emu->ncpus].state = CPU_ST_READY; | ||||||
| 	emu->cpu[emu->ncpus].cpu_id = cpuid; | 	emu->cpu[emu->ncpus].i = i; | ||||||
| 	emu->cpu[emu->ncpus].index = emu->ncpus; | 	emu->cpu[emu->ncpus].phyid = phyid; | ||||||
| 
 | 
 | ||||||
| 	/* Fill the translation to cpu index too */ | 	dbg("new cpu %d at phyid=%d\n", i, phyid); | ||||||
| 	assert(emu->cpuind[cpuid] == -1); |  | ||||||
| 	emu->cpuind[cpuid] = emu->ncpus; |  | ||||||
| 
 |  | ||||||
| 	dbg("new cpu id=%d at %d\n", cpuid, emu->ncpus); |  | ||||||
| 
 | 
 | ||||||
| 	emu->ncpus++; | 	emu->ncpus++; | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								prv.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								prv.c
									
									
									
									
									
								
							| @ -22,11 +22,10 @@ prv_ev_autocpu(struct ovni_emu *emu, int type, int val) | |||||||
| 	cpu = emu->cur_thread->cpu; | 	cpu = emu->cur_thread->cpu; | ||||||
| 
 | 
 | ||||||
| 	assert(cpu); | 	assert(cpu); | ||||||
| 	assert(cpu->index >= 0); | 	assert(cpu->i >= 0); | ||||||
| 	assert(cpu->cpu_id >= 0); |  | ||||||
| 
 | 
 | ||||||
| 	/* Begin at 1 */ | 	/* Begin at 1 */ | ||||||
| 	row = cpu->index + 1; | 	row = cpu->i + 1; | ||||||
| 
 | 
 | ||||||
| 	prv_ev_row(emu, row, type, val); | 	prv_ev_row(emu, row, type, val); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user