how to tell if i am restricted to a limited number of cpu-cores to work in parallel

Issue

I am working on a server with super configurations, it has 128 cpu-cores. When I run a parallelized code that utilizes full capacity of the cpu-cores only 8 cpu-cores are running in parallel. I can see that in htop
and number of threads working is, as shown below in the image, is 9

Is there any way to tell if I am restricted to usage of specific number of cpu-cores? How to do this in bash

image:

enter image description here

Solution

The application may run in a subset of the CPU set. Look at the cgroups to which the process is attached:

$ cat /proc/<pid>/cgroup
12:hugetlb:/
11:cpu,cpuacct:/user.slice
10:freezer:/
9:pids:/user.slice/user-500298949.slice/session-c16.scope
8:memory:/user.slice
7:cpuset:/
6:rdma:/
5:blkio:/user.slice
4:net_cls,net_prio:/
3:perf_event:/
2:devices:/user.slice
1:name=systemd:/user.slice/user-500298949.slice/session-c16.scope
0::/user.slice/user-500298949.slice/session-c16.scope

Look at the CPU list in the cpuset subsystem. In the above list, the cpuset subsystem of the process is at the root (typically /sys/fs/cgroup) of the cgroup hierarchy (i.e. 7:cpuset:/):

$ cat /sys/fs/cgroup/cpuset/cpuset.cpus 
0-39

Answered By – Rachid K.

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published