Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
Re: Mostly-Inverted CPU-Core ordering
To:
Stefan Fritsch <sf@sfritsch.de>
Cc:
Theo Buehler <tb@theobuehler.org>, Mark Kettenis <mark.kettenis@xs4all.nl>, gsgs7878@proton.me, tech@openbsd.org, visa@openbsd.org
Date:
Sat, 7 Mar 2026 13:08:32 +0000

Download raw body.

Thread
On 2026/03/07 09:33, Stefan Fritsch wrote:
> On Fri, 6 Mar 2026, Stuart Henderson wrote:
> 
> > On 2026/03/06 09:49, Theo Buehler wrote:
> > > On Wed, Jan 14, 2026 at 03:47:15PM +0100, Stefan Fritsch wrote:
> > > 
> > > [...]
> > > 
> > > > > > Updated diff below that should fix all architectures. sparc64 already has 
> > > > > > the correct ordering. Boot tested on amd64, i386, arm64.
> > > > > 
> > > > > On arm64, the slow cores are typically (but not always) listed before
> > > > > the fast cores.  Don't think that is a good reason not to change the
> > > > > order of the list to be more sensible.
> > > > 
> > > > Does this mean that the boot cpu is then a slow core, too?
> > > > 
> > > > In the long term, one probably wants to have some field in cpu_info that
> > > > denotes the core type and then make intrmap_create() use that info to
> > > > prefer the fastest cores.
> > > > 
> > > > As noted by tb@, the previous diff broke !MULTIPROCESSOR configurations.
> > > > New diff attached.
> > > 
> > > Not my area. Should this be committed?
> > 
> > fwiw, no change in cpu order on my m2 mini.
> 
> The change is not visible in dmesg. The cpus attach in the same 
> chronological order and get the same numbers. What the patch fixes is that 
> they are now put into the cpu_info_list->ci_next linked list in the right 
> order, which is the order used by CPU_INFO_FOREACH.
> 
> The easiest way to observe the effect of the diff that I found is this 
> additional diff:

Thanks.

With just the below printer diff:

cpu 0
cpu 7
cpu 6
cpu 5
cpu 4
cpu 3
cpu 2
cpu 1

and with that and the "fix mostly-inverted CPU-Core ordering" diff,

cpu 0
cpu 1
cpu 2
cpu 3
cpu 4
cpu 5
cpu 6
cpu 7



> diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
> index a51ecb9a39f..e712681a333 100644
> --- a/sys/kern/init_main.c
> +++ b/sys/kern/init_main.c
> @@ -163,6 +163,8 @@ main(void *framep)
>  	struct proc *p;
>  	struct process *pr;
>  	struct pdevinit *pdev;
> +	struct cpu_info *ci;
> +	CPU_INFO_ITERATOR cii;
>  	extern struct pdevinit pdevinit[];
>  	extern void disk_init(void);
>  
> @@ -533,6 +535,9 @@ main(void *framep)
>  
>  	config_process_deferred_mountroot();
>  
> +	CPU_INFO_FOREACH(cii, ci) {
> +		printf("cpu %d\n", ci->ci_cpuid);
> +	}
>  	/*
>  	 * Okay, now we can let init(8) exec!  It's off to userland!
>  	 */
>