Link processes and CPUs with the loom

This commit is contained in:
Rodrigo Arias 2023-02-17 10:08:40 +01:00 committed by Rodrigo Arias Mallo
parent 54cf4d3409
commit 2d8b68bff2
5 changed files with 26 additions and 0 deletions

View File

@ -52,6 +52,12 @@ cpu_set_gindex(struct cpu *cpu, int64_t gindex)
cpu->gindex = gindex; cpu->gindex = gindex;
} }
void
cpu_set_loom(struct cpu *cpu, struct loom *loom)
{
cpu->loom = loom;
}
void void
cpu_set_name(struct cpu *cpu, const char *name) cpu_set_name(struct cpu *cpu, const char *name)
{ {

View File

@ -37,6 +37,9 @@ struct cpu {
/* Physical id: as reported by lscpu(1) */ /* Physical id: as reported by lscpu(1) */
int phyid; int phyid;
/* Required to find threads that can run in this CPU */
struct loom *loom;
size_t nthreads; size_t nthreads;
size_t nth_running; size_t nth_running;
size_t nth_active; size_t nth_active;
@ -66,6 +69,7 @@ void cpu_init_begin(struct cpu *cpu, int phyid, int is_virtual);
int cpu_get_phyid(struct cpu *cpu); int cpu_get_phyid(struct cpu *cpu);
//int cpu_get_index(struct cpu *cpu); //int cpu_get_index(struct cpu *cpu);
void cpu_set_gindex(struct cpu *cpu, int64_t gindex); void cpu_set_gindex(struct cpu *cpu, int64_t gindex);
void cpu_set_loom(struct cpu *cpu, struct loom *loom);
void cpu_set_name(struct cpu *cpu, const char *name); void cpu_set_name(struct cpu *cpu, const char *name);
int cpu_init_end(struct cpu *cpu); int cpu_init_end(struct cpu *cpu);
int cpu_connect(struct cpu *cpu, struct bay *bay, struct recorder *rec); int cpu_connect(struct cpu *cpu, struct bay *bay, struct recorder *rec);

View File

@ -68,6 +68,7 @@ loom_init_begin(struct loom *loom, const char *name)
loom->id = loom->name; loom->id = loom->name;
cpu_init_begin(&loom->vcpu, -1, 1); cpu_init_begin(&loom->vcpu, -1, 1);
cpu_set_loom(&loom->vcpu, loom);
dbg("creating new loom %s", loom->id); dbg("creating new loom %s", loom->id);
@ -121,6 +122,8 @@ loom_add_cpu(struct loom *loom, struct cpu *cpu)
//DL_SORT2(loom->cpus, cmp_cpus, lprev, lnext); // Maybe? //DL_SORT2(loom->cpus, cmp_cpus, lprev, lnext); // Maybe?
loom->ncpus++; loom->ncpus++;
cpu_set_loom(cpu, loom);
return 0; return 0;
} }
@ -223,6 +226,8 @@ loom_add_proc(struct loom *loom, struct proc *proc)
HASH_ADD_INT(loom->procs, pid, proc); HASH_ADD_INT(loom->procs, pid, proc);
loom->nprocs++; loom->nprocs++;
proc_set_loom(proc, loom);
return 0; return 0;
} }

View File

@ -95,6 +95,12 @@ proc_set_gindex(struct proc *proc, int64_t gindex)
proc->gindex = gindex; proc->gindex = gindex;
} }
void
proc_set_loom(struct proc *proc, struct loom *loom)
{
proc->loom = loom;
}
int int
proc_load_metadata(struct proc *proc, JSON_Object *meta) proc_load_metadata(struct proc *proc, JSON_Object *meta)
{ {

View File

@ -27,6 +27,10 @@ struct proc {
int nthreads; int nthreads;
struct thread *threads; struct thread *threads;
/* Required to find if a thread belongs to the same loom as a
* CPU */
struct loom *loom;
/* Loom list */ /* Loom list */
struct proc *lnext; struct proc *lnext;
struct proc *lprev; struct proc *lprev;
@ -45,6 +49,7 @@ int proc_init_begin(struct proc *proc, const char *id);
int proc_init_end(struct proc *proc); int proc_init_end(struct proc *proc);
int proc_get_pid(struct proc *proc); int proc_get_pid(struct proc *proc);
void proc_set_gindex(struct proc *proc, int64_t gindex); void proc_set_gindex(struct proc *proc, int64_t gindex);
void proc_set_loom(struct proc *proc, struct loom *loom);
void proc_sort(struct proc *proc); void proc_sort(struct proc *proc);
int proc_load_metadata(struct proc *proc, JSON_Object *meta); int proc_load_metadata(struct proc *proc, JSON_Object *meta);
struct thread *proc_find_thread(struct proc *proc, int tid); struct thread *proc_find_thread(struct proc *proc, int tid);