Questions tagged [cpuset]

cpuset is a command used to restrict process to a defined processor and memory node

From the manual page:

   A cpuset defines a list of CPUs and memory nodes.

   The CPUs of a system include all the logical processing units on
   which a process can execute, including, if present, multiple
   processor cores within a package and Hyper-Threads within a processor
   core.  Memory nodes include all distinct banks of main memory; small
   and SMP systems typically have just one memory node that contains all
   the system's main memory, while NUMA (non-uniform memory access)
   systems have multiple memory nodes.

   Cpusets are represented as directories in a hierarchical pseudo-
   filesystem, where the top directory in the hierarchy (/dev/cpuset)
   represents the entire system (all online CPUs and memory nodes) and
   any cpuset that is the child (descendant) of another parent cpuset
   contains a subset of that parent's CPUs and memory nodes.  The
   directories and files representing cpusets have normal filesystem
   permissions.

   Every process in the system belongs to exactly one cpuset.  A process
   is confined to run only on the CPUs in the cpuset it belongs to, and
   to allocate memory only on the memory nodes in that cpuset.  When a
   process fork(2)s, the child process is placed in the same cpuset as
   its parent.  With sufficient privilege, a process may be moved from
   one cpuset to another and the allowed CPUs and memory nodes of an
   existing cpuset may be changed.

   When the system begins booting, a single cpuset is defined that
   includes all CPUs and memory nodes on the system, and all processes
   are in that cpuset.  During the boot process, or later during normal
   system operation, other cpusets may be created, as subdirectories of
   this top cpuset, under the control of the system administrator, and
   processes may be placed in these other cpusets.

   Cpusets are integrated with the sched_setaffinity(2) scheduling
   affinity mechanism and the mbind(2) and set_mempolicy(2) memory-
   placement mechanisms in the kernel.  Neither of these mechanisms let
   a process make use of a CPU or memory node that is not allowed by
   that process's cpuset.  If changes to a process's cpuset placement
   conflict with these other mechanisms, then cpuset placement is
   enforced even if it means overriding these other mechanisms.  The
   kernel accomplishes this overriding by silently restricting the CPUs
   and memory nodes requested by these other mechanisms to those allowed
   by the invoking process's cpuset.  This can result in these other
   calls returning an error, if for example, such a call ends up
   requesting an empty set of CPUs or memory nodes, after that request
   is restricted to the invoking process's cpuset.

   Typically, a cpuset is used to manage the CPU and memory-node
   confinement for a set of cooperating processes such as a batch
   scheduler job, and these other mechanisms are used to manage the
   placement of individual processes or memory regions within that set
   or job.
23 questions
22
votes
4 answers

Isolate Kernel Module to a Specific Core Using Cpuset

From user-space we can use cpuset to actually isolate a specific core in our system and execute just one specific process to that core. I'm trying to do the same thing with a kernel module. So I want the module to get executed in an isolated core.…
insumity
  • 5,311
  • 8
  • 36
  • 64
12
votes
1 answer

echo $$ > tasks gives "no space left on device" when trying to use cpuset

I tried the example from the cpuset(7) manual and created a cpuset Charlie. On both Ubuntu 14.4 LTS and SLES 12 I get the following error when trying to put the current process into the cpuset: /dev/cpuset/Charlie# echo $$ > tasks bash: echo: write…
Holger Jakobs
  • 984
  • 3
  • 11
  • 32
8
votes
1 answer

docker run --cpuset is not having any effect

I started one docker container by specifying the cpuset to 1 cores: docker run --cpuset-cpus="0"... A second one by specifying the cpuset to 4 cores: docker run --cpuset-cpus="0-3"... I launched a load process within each container and I…
staticx
  • 1,201
  • 2
  • 16
  • 31
2
votes
1 answer

How to make cpuset.cpu_exclusive function of cpuset work correctly

I'm trying to use the kernel's cpuset to isolate my process. To obtain this, I follow the instructions(2.1 Basic Usage) from kernel doc cpusets, however, it didn't work in my environment. I have tried in both my centos7 server and my ubuntu16.04…
xjas
  • 75
  • 2
  • 11
2
votes
1 answer

Get CPU number from running java program

I am running a java program and want to get the cpu that the process is currently running on. Is there any standard way in java to get this? My backup plan is to run something like ps -eF to get the cpu for my current process but that seems ugly
jamesatha
  • 7,280
  • 14
  • 37
  • 54
1
vote
0 answers

Creating a new cpuset within a Kubernetes pod

I've launched a Kubernetes pod (single container) with a static CPU management policy. It has a CPU request/limit of 10. This all seems to be working as expected: cat /sys/fs/cgroup/cpuset/cpuset.cpus 11-20 What I'd like to do now is reserve a…
Jon Chambers
  • 644
  • 7
  • 14
1
vote
1 answer

Pin Kubernetes pods/deployments/replica sets/daemon sets to run on specific cpu only

I need to restrict an app/deployment to run on specific cpus only (say 0-3 or just 1 or 2 etc.) I found out about CPU Manager and tried implement it with static policy but not able to achieve what I intend to. I tried the following so far: Enabled…
Koshur
  • 378
  • 1
  • 6
  • 20
1
vote
1 answer

How to configure dockerd not to use some specific cpus?

all. I want to reserve some cpus for realtime task. I tried to use cset utility,(https://github.com/lpechacek/cpuset/blob/master/doc/tutorial.txt) but failed since dockerd reserve all available cpu to its own cpuset. Then, I reserved cpus 0~11 using…
Chul-Woong Yang
  • 1,223
  • 10
  • 17
1
vote
1 answer

There is a way to pass --cpus-cpuset and --cpuset-mems to docker swarm

I was looking through the documentation and it seems than it is not possible to isolate processes in Docker swarm to a specific core, like when you use numactl or cpuset--cpus. In docker run you do it like this (16 cpu machine, use 8 cpus on second…
josegts
  • 107
  • 1
  • 13
1
vote
1 answer

docker-compose scale with different cpuset

How can I scale a service but apply a different cpuset on each instance with docker-compose ? For example: I have 4 cpus, I want 4 instances, each using 1 unique cpu.
0xkvn
  • 377
  • 2
  • 16
1
vote
1 answer

Could the affinity of thread created by kernel be set by "cpuset"?

The affinity of user processes could be set by cpuset(7). Could the affinity of thread created by kernel be set through the cpuset(7)? I found that the affinity of some kthreads could be set by cpuset indeed([rcu_sched],[rcu_bh]),some kthreads…
sunshilong369
  • 646
  • 1
  • 5
  • 17
1
vote
0 answers

isolcpus - binding not working

Sorry, this is a duplicate question from ServerFault. I am posting this here since I didn't get any response there. Question: I am using isolcpus to isolate cores. I would like to bind specific threads to cores, but it is not working. The threads…
Prashanth
  • 328
  • 2
  • 3
  • 11
1
vote
3 answers

printing the cpus a task is allowed to run on?

I'm trying to printk the cpus that a specific task is allowed to run on. Inside struct task_struct (which can be find here) there's the cpumask_t cpus_allowed which from what I understand contains exactly what Im looking for . Is that right ? If…
nadavgam
  • 2,014
  • 5
  • 20
  • 48
1
vote
1 answer

How can I mount two more subsystems on one directory in cgroups?

I'm studying computer engineering in university. During my study I have some problems. I want to mount two subsystems on one directory. I tried as follows mount -t cgroup -o cpu,cpuset cpu_and_cpuset /cgroup/cpu_and_cpuset This command is guided…
1
vote
1 answer

Separate cpuset for jobs

Is there a way to restrict cpus and memory for users running scripts directly, but allow more cpus and memory on job submission? I am running torque/pbs on Ubuntu 14.04 server and want to allow "normal" usage of 8 cpus and 16GB RAM, and the rest to…
morais
  • 161
  • 1
  • 1
  • 9
1
2