Damien Zammit, le dim. 11 févr. 2024 07:10:24 +0000, a ecrit: > This has the effect of running with one cpu only with smp, > but has the ability to enable APs in userspace with the right > processor set RPCs. > --- > ddb/db_print.c | 4 +++- > kern/machine.c | 7 ++++++- > kern/processor.c | 30 +++++++++++++++++++----------- > kern/processor.h | 1 + > 4 files changed, 29 insertions(+), 13 deletions(-) > > diff --git a/ddb/db_print.c b/ddb/db_print.c > index 028cb887..b5b562fd 100644 > --- a/ddb/db_print.c > +++ b/ddb/db_print.c > @@ -347,8 +347,10 @@ db_show_all_runqs( > { > int i; > > - db_printf("Processor set runq:\t"); > + db_printf("Processor set def runq:\t"); > showrq(&default_pset.runq); > + db_printf("Processor set APs runq:\t"); > + showrq(&ap_pset->runq);
Since userland can create psets as well, better iterate over all_psets. > for (i = 0; i < smp_get_numcpus(); i++) { > db_printf("Processor #%d runq:\t", i); > showrq(&cpu_to_processor(i)->runq); > diff --git a/kern/machine.c b/kern/machine.c > index 87fbc4d1..9fbc3871 100644 > --- a/kern/machine.c > +++ b/kern/machine.c > @@ -84,6 +84,7 @@ void cpu_up(int cpu) > > processor = cpu_to_processor(cpu); > pset_lock(&default_pset); > + pset_lock(ap_pset); Only #if MACH_HOST > s = splsched(); > processor_lock(processor); > #if NCPUS > 1 > @@ -92,10 +93,14 @@ void cpu_up(int cpu) > ms = &machine_slot[cpu]; > ms->running = TRUE; > machine_info.avail_cpus++; > - pset_add_processor(&default_pset, processor); > + if (cpu == 0) > + pset_add_processor(&default_pset, processor); > + else > + pset_add_processor(ap_pset, processor); Only #if MACH_HOST > processor->state = PROCESSOR_RUNNING; > processor_unlock(processor); > splx(s); > + pset_unlock(ap_pset); > pset_unlock(&default_pset); > } > > diff --git a/kern/processor.c b/kern/processor.c > index 76735381..d151f497 100644 > --- a/kern/processor.c > +++ b/kern/processor.c > @@ -60,6 +60,7 @@ struct kmem_cache pset_cache; > int master_cpu; > > struct processor_set default_pset; > +struct processor_set *ap_pset; "AP" is an intel name that is mostly unknown otherwise. Since the BSP is called master processor, we can call the additional pset slaves_pset. Also only #if MACH_HOST > queue_head_t all_psets; > int all_psets_count; > @@ -67,16 +68,13 @@ def_simple_lock_data(, all_psets_lock); > > processor_t master_processor; > > -/* > - * Bootstrap the processor/pset system so the scheduler can run. > - */ > -void pset_sys_bootstrap(void) > +static void pset_sys_bootstrap_real(struct processor_set *pset, int start, > int count) This refactoring doesn't seem to be used? > @@ -124,6 +130,8 @@ void pset_sys_init(void) > ipc_processor_init(processor); > } > } > + > + processor_set_create(&realhost, &ap_pset, &ap_pset); > } > #endif /* MACH_HOST */ > > diff --git a/kern/processor.h b/kern/processor.h > index fc204ffa..29abc99a 100644 > --- a/kern/processor.h > +++ b/kern/processor.h > @@ -85,6 +85,7 @@ struct processor_set { > long sched_load; /* load avg for scheduler */ > }; > extern struct processor_set default_pset; > +extern struct processor_set *ap_pset; > > struct processor { > struct run_queue runq; /* local runq for this processor */ > -- > 2.43.0 > > >