You are not logged in.

#1 2022-08-15 07:54:29

PROBUBBLE01
Member
Registered: 2021-09-07
Posts: 11

nproc indicating higher number of cpu cores than CPU has

Hello, i'm using arch linux on a laptop with 6 cores and 12 threads (AMD ryzen 5 5500U). if i run

 nproc --all 

it outputs 16. also the system file  /sys/devices/system/cpu/offline contains 12-15. how is this possible?. there is only folders for cpu0 to cpu11

output of ls -la on /sys/devices/system/cpu

total 0
drwxr-xr-x 21 root root    0 Aug 15 12:50 .
drwxr-xr-x 10 root root    0 Aug 15 12:50 ..
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu0
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu1
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu10
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu11
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu2
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu3
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu4
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu5
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu6
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu7
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu8
drwxr-xr-x  9 root root    0 Aug 15 12:50 cpu9
drwxr-xr-x 14 root root    0 Aug 15 12:50 cpufreq
drwxr-xr-x  2 root root    0 Aug 15 13:00 cpuidle
drwxr-xr-x  2 root root    0 Aug 15 13:01 hotplug
drwxr-xr-x  2 root root    0 Aug 15 12:50 microcode
drwxr-xr-x  2 root root    0 Aug 15 13:01 power
drwxr-xr-x  2 root root    0 Aug 15 13:01 smt
drwxr-xr-x  2 root root    0 Aug 15 13:01 vulnerabilities
-r--r--r--  1 root root 4.0K Aug 15 13:01 isolated
-r--r--r--  1 root root 4.0K Aug 15 13:01 kernel_max
-r--r--r--  1 root root 4.0K Aug 15 13:01 modalias
-r--r--r--  1 root root 4.0K Aug 15 13:01 nohz_full
-r--r--r--  1 root root 4.0K Aug 15 13:01 offline
-r--r--r--  1 root root 4.0K Aug 15 12:50 online
-r--r--r--  1 root root 4.0K Aug 15 12:50 possible
-r--r--r--  1 root root 4.0K Aug 15 13:01 present
-rw-r--r--  1 root root 4.0K Aug 15 12:50 uevent

Can someone please explain this behaviour. is there anything wrong with the hardware that i should be aware of?

Offline

#2 2022-08-15 09:02:44

xerxes_
Member
Registered: 2018-04-29
Posts: 753

Re: nproc indicating higher number of cpu cores than CPU has

Don't suggest what is returned by nproc. More important is what returns 'cat /proc/cpuinfo' or lscpu.
I have only two cores without hyper threading and 'nproc --all' returns 4, so according to nproc I have 50% more cores smile

Last edited by xerxes_ (2022-08-15 09:03:34)

Offline

#3 2022-08-15 09:09:51

PROBUBBLE01
Member
Registered: 2021-09-07
Posts: 11

Re: nproc indicating higher number of cpu cores than CPU has

xerxes_ wrote:

Don't suggest what is returned by nproc. More important is what returns 'cat /proc/cpuinfo' or lscpu.
I have only two cores without hyper threading and 'nproc --all' returns 4, so according to nproc I have 50% more cores smile

Thanks for the reply. this command outputs 12. Which is correct. I have 12 threads on my computer. But I cannot figure out how it counted 16 of them. 4 cores are offline according to the file like I've mentioned. That's the part I'm confused about.

Offline

#4 2022-08-15 09:40:24

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,676

Re: nproc indicating higher number of cpu cores than CPU has

$ nproc
24
$ nproc --all
128
$ 

My processor is 12 C, 24 T .

No idea what it means but this line from dmesg seems relevant

[    0.000000] smpboot: Allowing 128 CPUs, 104 hotplug CPUs

Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2022-08-15 10:11:55

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,631
Website

Re: nproc indicating higher number of cpu cores than CPU has

@Lone_Wolf - that is odd, for 16C32T CPU here:

% nproc
32
% nproc --all
32
% dmesg | grep hotplug
[  +0.000004] smpboot: Allowing 32 CPUs, 0 hotplug CPUs

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2022-08-15 10:22:57

PROBUBBLE01
Member
Registered: 2021-09-07
Posts: 11

Re: nproc indicating higher number of cpu cores than CPU has

Lone_Wolf wrote:
$ nproc
24
$ nproc --all
128
$ 

My processor is 12 C, 24 T .

No idea what it means but this line from dmesg seems relevant

[    0.000000] smpboot: Allowing 128 CPUs, 104 hotplug CPUs

This dmesg explains something. It is counting 128 CPU cores. But only 24 of them are used (128 minus 104). Which is your actual amount of hyperthreaded cores.

I also get similar dmesg log.

Allowing 16 CPUs, 4 hotplug CPUs

where 12 is used and 4 of them are "hotplugable". But it's only a 12 thread CPU in my case and 24 on yours. No idea where the the rest of them comes from

Offline

#7 2022-08-15 11:07:42

carioli
Member
Registered: 2022-01-14
Posts: 2

Re: nproc indicating higher number of cpu cores than CPU has

nproc analyzes contents of the
/sys/devices/system/cpu/online
/proc/stat
/proc/cpuinfo
in order of appearance

Offline

#8 2022-08-15 11:24:40

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,676

Re: nproc indicating higher number of cpu cores than CPU has

I've done some searching and it appears there are sytems / motherboards that allow adding / removing processors on the fly while the system keeps running .

Maybe my mobo and that of PROBUBBLE01 do support that ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB