30.12.2025 22:18, Mark Kettenis пишет:
>> Date: Tue, 30 Dec 2025 19:05:03 +0100
>> From: Alexander Bluhm <[email protected]>
>>
>> On Sun, Nov 23, 2025 at 04:14:31PM +0000, Miod Vallat wrote:
>>>> All cores attached, i.e. octeon's hw_cpu_hatch() should've run
>>>> and bumped `ncpus' four times.
>>>
>>> Except that this only happens after cpu_boot_secondary_processors()
>>> completes, which is way later than softnet_percpu().
>>
>> octeon sets ncpus late, but ncpusfound is set early. Other subsystems
>> also use that variable. My mistake using the wrong one.
>
> No, you used the right one.
>
> * ncpusfound: the number of CPUs the hardware provides
>
> * ncpus: the number of CPUs OpenBSD is using
>
> So when running a GENERIC kernel on a machine with 32 CPUs, ncpusfound
> will be 32 but ncpus will be 1.
>
> Even when running a GENERIC.MP kernel, ncpusfound may be larger than
> ncpus. This could happen if the hardware has more than MAXCPUS CPUs.
>
> We probably should change octeon to bump ncpus when it attaches CPUs
> instead of when it spins them up.
I gave it a quick try today:
root@ot8:.../~# ps xk |grep softnet
68767 ?? DK 0:00.00 (softnet3)
71399 ?? DK 0:00.00 (softnet4)
75753 ?? DK 0:00.00 (softnet5)
95091 ?? DK 0:00.00 (softnet6)
69574 ?? DK 0:00.00 (softnet7)
31463 ?? DK 0:00.00 (softnet0)
26770 ?? DK 0:00.00 (softnet2)
37751 ?? DK 0:00.00 (softnet1)
23114 00 S+p 0:00.01 grep softnet
root@ot8:.../~# sysctl hw | grep cpu
hw.ncpu=17
hw.cpuspeed=1800
hw.ncpufound=16
hw.ncpuonline=16
Obvious off-by-one still, but incrementing on attach works.
If that's the right direction, I'll fix up the diff next week.
Index: arch/mips64/mips64/cpu.c
===================================================================
RCS file: /mount/openbsd/cvs/src/sys/arch/mips64/mips64/cpu.c,v
diff -u -p -r1.85 cpu.c
--- arch/mips64/mips64/cpu.c 5 Jun 2025 09:29:54 -0000 1.85
+++ arch/mips64/mips64/cpu.c 15 Feb 2026 20:24:10 -0000
@@ -107,6 +107,7 @@ cpuattach(struct device *parent, struct
ci->ci_cpuid = cpuno;
ci->ci_dev = dev;
bcopy(ch, &ci->ci_hw, sizeof(struct cpu_hwinfo));
+ ncpus++;
#ifdef MULTIPROCESSOR
/*
* When attaching secondary processors, cache information is not
Index: arch/octeon/octeon/machdep.c
===================================================================
RCS file: /mount/openbsd/cvs/src/sys/arch/octeon/octeon/machdep.c,v
diff -u -p -r1.137 machdep.c
--- arch/octeon/octeon/machdep.c 24 Oct 2023 13:20:10 -0000 1.137
+++ arch/octeon/octeon/machdep.c 15 Feb 2026 20:43:00 -0000
@@ -1334,8 +1334,6 @@ hw_cpu_hatch(struct cpu_info *ci)
ci->ci_flags |= CPUF_RUNNING;
membar_sync();
- ncpus++;
-
spl0();
(void)updateimask(0);