Linux Performance Tuning: process binding and interruption binding

Source: Internet
Author: User

Linux Performance Tuning 17: process binding and interrupt binding talking about linux Performance Tuning 16: Nic binding OS /201307/230472.html 1. use taskset to set the CPU affinity taskset to search and set the CPU affinity for running processes (based on the process ID ). It can also be used to start a process with a given CPU affinity, so that the CPU affinity of a specified process and the specified CPU or a group of CPUs can be expressed by a bit mask. The second bit corresponds to the first logical CPU, and the highest bit corresponds to the last logical CPU. These masks are usually hexadecimal, So 0x00000001 represents the processor 00000003 x represents the processor 3. To set the CPU affinity of a running process, run the following command to replace the mask with the processor or the processor mask you want to bind, and replace the pid with the ID of the process you want to change the affinity. # Taskset-p mask pid to start a process with a given affinity, run the following command to replace the mask with the mask of the processor or the processor you want to bind, replace program with programs, options, and program parameters you want to run. # Taskset mask -- program instead of specifying the processor as a bit code, you can also use the-c option to provide a comma-separated independent processor, or a group of processor lists, similar to the following: # taskset-c, 7-9 -- For details about taskset, see man page: man taskset. 2. hardware interruptions frequently consume CPU resources. If there is a way to allocate a large number of hardware interruptions to different CPUs (cores) under multi-core CPU conditions) processing clearly balances performance well. Currently, multiple CPUs, multiple NICs, and multiple hard disks are not supported on the server. If the NIC can be interrupted, one CPU (core) is exclusive) if the disk IO interrupt exclusive one CPU, it will greatly reduce the burden on a single CPU and improve the overall processing efficiency. An interrupt request (IRQ) is a service request sent at the hardware layer. You can use a dedicated hardware line or cross-hardware bus information packet (message signal interruption, MSI) to issue an interruption. After the interrupt is enabled, after receiving IRQ, a message is displayed indicating that the interrupt context is switched. The kernel interrupt scheduling code searches for the list of registered interrupt service routes (ISR) associated with machines with IRQ numbers and calls ISR in sequence. ISR will confirm the interruption and ignore the redundant interruption from the same IRQ, then wait in the delayed handle to complete the interrupt processing, and ignore the subsequent interruption to end the ISR. The/proc/interrupts file lists the number of interrupts of each CPU in each I/O device, the number of interrupts processed by each CPU core, and the interrupt type, and a list of drivers that are registered separately with commas to receive interruptions. IRQ has an associated "similar" attribute smp_affinity. This parameter can be defined as the CPU core that allows IRQ to execute ISR. This attribute is also used to improve program performance by allocating interrupt similarity and program thread similarity to one or more CPU cores. This allows the cache line to be shared between the specified interrupt and program thread. The approximate interrupt value of an IRQ is saved in the related/proc/irq/IRQ_NUMBER/smp_affinity file. You can view and modify this value as the root user. The value saved in this file is a hexadecimal byte mask, representing all CPU cores in the system. For example, to specify an Ethernet driver for a quad-core server, first determine the number of IRQ associated with the Ethernet DRIVER: # grep eth0/proc/interrupts32: 0 140 45 850264 PCI-MSI-edge eth0 use the number of IRQ to locate the correct smp_affinity file: # cat/proc/irq/32/smp_affinity fsmp_affinity the default value is f, it can provide IRQ for any CPU in the system. Set this value to 1, as shown below, indicating that only CPU 0 can provide this interrupt: # echo 1>/proc/irq/32/smp_affinity # cat/proc/irq/32/smp_affinity1 when the network is very heavy, for applications such as file servers and high-traffic Web servers, binding IRQ balances of different NICs to different CPUs reduces the burden on a certain CPU, improves the overall capability of multiple CPUs to handle interruptions. For applications such as database servers, binding a disk controller to a CPU and a NIC to another CPU improves the database response time and performance. Balancing IRQ interruptions based on your production environment and application characteristics helps improve the overall throughput and performance of the system. Note: You need to stop the irqbalance service before manually binding IRQ to the CPU. irqbalance is a service process used to automatically bind and balance IRQ: #/etc/init. d/irqbalance stop

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.