• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Set CPU Affinity for SYSTEMD Process in CentOS/RHEL 7

by admin

CPUAffinity is one of the directives to control the CPU affinity of the systemd executed processes.

from the man page of systemd.exec:

# man systemd.exec

CPUAffinity=

Controls the CPU affinity of the executed processes. Takes a list of CPU indices or ranges separated by either
 whitespace or commas. CPU ranges are specified by the lower and upper CPU indices separated by a dash. This 
option may be specified more than once in which case the specified CPU affinity masks are merged. If the empty 
string is assigned, the mask is reset, all assignments prior to this will have no effect. See sched_setaffinity(2)
 for details.

Configuring CPU affinity

1. Edit the file “/etc/systemd/system.conf“:

# vi /etc/systemd/system.conf

2. Uncomment “CPUAffinity” line and append the CPU numbers.

CPUAffinity=2,3

3. Restart the server and verify the status of CPU affinity.

Verify

Following commands reveals the CPU affinity of process:

# taskset -p [process ID]
# ps --ppid 2 -p 2 -o uname,pid,ppid,cmd,cls,psr --deselect

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. sysctl setting for high load and prevent DDoS
  2. Xen Hypervisor (xm) command Cheat Sheet
  3. How to add Swap Space on Linux Servers (CentOS/RHEL) On the Fly
  4. How to Configure Network Teaming in CentOS/RHEL 7
  5. Installation Steps of jEdit on Ubuntu Linux
  6. Linux Interview Questions – Linux Printing (CUPS)
  7. UNIX / Linux : How to install and configure mutt
  8. How To Disable Or Extend System Logging Rate-limit on CentOS/RHEL 6
  9. chown Command Examples in Linux
  10. How To Disable Ksplice Service on OEL

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright