Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cAdvisor running in docker ignore isolcpus #2792

Closed
shohamd4 opened this issue Jan 28, 2021 · 7 comments · Fixed by #2805
Closed

cAdvisor running in docker ignore isolcpus #2792

shohamd4 opened this issue Jan 28, 2021 · 7 comments · Fixed by #2805
Assignees

Comments

@shohamd4
Copy link

shohamd4 commented Jan 28, 2021

Hi,

I'm running cAdvisor in docker on machines with high CPU load.
I've configured the server kernel with isolcpus=1,2,3

I'm running cAdvisor with the following params:

docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:ro \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  --privileged \
  --device=/dev/kmsg \
  gcr.io/cadvisor/cadvisor:v0.37.0

I've noticed that cAdvisor still runs on all cpus (not only cpu 0).
If I run cAdvisor with docker --cpuset-cpus=0, then cAdvisor doesn't show info on the other cpus.
Also if I enforce cpu affinity with taskset (without the --cpuset-cpus flag) - cAdvisor will show me stats only on the allowed cpus.

What is the correct way to run cAdvisor on a specific cpu?
BTW, I can see that setting -max_procs to 1 doesn't affect the number of processes that cAdvisor uses.

Thanks,
Doron

@iwankgb
Copy link
Collaborator

iwankgb commented Feb 12, 2021

@shohamd4 there is something clearly wrong with handling isolcpus and tasksets. I will take a look into this.

@iwankgb iwankgb self-assigned this Feb 12, 2021
@iwankgb
Copy link
Collaborator

iwankgb commented Feb 12, 2021

Environment: 4-core aarch64 system. isolcpus=1-3. alexeiled/stress-ng docker container running on CPUs 2,3 (--cpuset-cpus 2,3).
With #2744:

  • Topology information is displayed correctly despite of isolcpus and taskset used simultaneously.
  • CPU usage is displayed for one CPU only. Overall CPU usage seems to be accounted for (no taskset used):
"cpu": {
  "usage": {
   "total": 567239332835,
   "per_cpu_usage": [
     0
    ],
    "user": 567560000000,
    "system": 80000000
  }
}  
  • cAdvisor seems to consume up to 80% of CPU 0.

@iwankgb
Copy link
Collaborator

iwankgb commented Feb 12, 2021

And the culprit is:

if err := unix.SchedGetaffinity(0, &availableCPUs); err != nil {

According to the manual:

sched_getaffinity() writes the affinity mask of the process whose ID is pid into the cpu_set_t structure pointed to by mask. The cpusetsize argument specifies the size (in bytes) of mask. If pid is zero, then the mask of the calling process is returned.

I believe that this function and any filtering that uses it must be removed: sched_getaffinity() does not return number of CPUs in the system. Such information can be obtained from sysfs but I don't think it is relevant in this case.

@iwankgb
Copy link
Collaborator

iwankgb commented Feb 12, 2021

@shohamd4 you can try code from #2805 - it should fix your problem.

@shohamd4
Copy link
Author

@iwankgb - Thank you very much for the quick fix, I'll try it on Monday.

@shohamd4
Copy link
Author

Hi, looks great, do you plan to push it into an official release?
Thank you very much!
Doron

@iwankgb
Copy link
Collaborator

iwankgb commented Feb 15, 2021

As soon as it gets merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants