Home  >  Article  >  System Tutorial  >  System process: 10 knowledge points that operation and maintenance personnel must be familiar with

System process: 10 knowledge points that operation and maintenance personnel must be familiar with

WBOY
WBOYforward
2024-01-05 17:24:201206browse
Introduction In daily operation and maintenance work, when we habitually execute the ps command, we will see many "weird" processes, and most of these processes are the kernel processes of the system. Many students know very little about it, so today I will compile an entry-level system process introduction post for you, hoping to help everyone understand the operating system process.

In daily operation and maintenance work, when we habitually execute the ps command, we will see many "weird" processes, and most of these processes are the kernel processes of the system. Many students know very little about it, so today I will compile an entry-level system process introduction post for you, hoping to help everyone understand the operating system process.
System process: 10 knowledge points that operation and maintenance personnel must be familiar with

Preface

In daily operation and maintenance work, we often see some strange system processes that occupy relatively high resources. And I always hear students from the business line asking, "What process is xxx? Why have so many of them been opened?"

These system-level kernel processes are enclosed in square brackets, and they perform some system auxiliary functions (such as writing cache to disk); processes without brackets are processes executed by users (such as php, nginx, etc.).

As shown below:
System process: 10 knowledge points that operation and maintenance personnel must be familiar with
Here are 10 common system processes for everyone:
kswapd0
kjournald
pdflush
kthreadd
migration
watchdog
events
kblockd
aio
rpciod

kswapd0

The system will wake up kswapd every certain period of time to see if the memory is tight. If not, it will go to sleep. In kswapd, there are two thresholds, pages_hige and pages_low. When the number of free memory pages is lower than pages_low time, the kswapd process will scan the memory and release 32 free pages each time until the number of free pages reaches pages_high.

Linux uses kswapd for virtual memory management such that pages that have been recently accessed are kept in memory and less active pages are paged out to disk.(what is a page?)…Linux uses manages memory in units called pages.So ,the kswapd process regularly decreases the ages of unreferenced pages…and at the end they are paged out(moved out) to disk

kjournald

journal: Record metadata changes on all file systems, the slowest mode.

logs all filesystem data and metadata changes. The slowest of the three ext3 journaling modes, this journaling mode minimizes the chance of losing the changes you have made to any file in an ext3 filesystem.

ordered: The default mode, only records the metadata of file system changes, and records the log before the change.

only logs changes to filesystem metadata, but flushes file data updates to disk before making changes to associated filesystem metadata. This is the default ext3 journaling mode.

writeback: The fastest mode, which also only records modified metadata and relies on the standard file system writing process to write data to the hard disk

only logs changes to filesystem metadata but relies on the standard filesystem write process to write file data changes to disk. This is the fastest ext3 journaling mode.

pdflush

pdflush is used to synchronize the content in memory with the file system.

For example: when a file is modified in memory, pdflush is responsible for writing it back to the hard disk. Whenever the number of dirty pages in memory exceeds 10%, pdflush will back up these pages back to the hard disk. This ratio is adjustable, and the default value is 10 through the vm.dirty_background_ratio item in /etc/sysctl.conf.

kthreadd

There is only one such kernel thread, and its role is to manage and schedule other kernel threads.

It is created when the kernel is initialized and will run a function called kthreadd in a loop. The function of this function is to run the kthread maintained in the kthread_create_list global linked list. You can call kthread_create to create a kthread, which will be added to the kthread_create_list linked list. At the same time, kthread_create will weak up kthreadd_task. When kthreadd executes kthread, it will call the old interface - kernel_thread runs a kernel thread named "kthread" to run the created kthread. The executed kthread will be deleted from the kthread_create_list list, and kthreadd will continuously call scheduler to give up the CPU. This thread cannot be closed.

migration

There are 32 kernel threads of this kind, from migration/0 to migration/31. Each processor core corresponds to a migration kernel thread. Its main function is to serve as the migration process of the corresponding CPU core and is used to perform process migration operations. The kernel The function in is migration_thread()

Belongs to the load balancing system of the 2.6 kernel. This process is automatically loaded when the system starts (one for each CPU), and sets itself as a real-time process of SCHED_FIFO, and then checks whether there are requests waiting to be processed in runqueue::migration_queue. If If not, it will sleep in TASK_INTERRUPTIBLE until it is woken up and checked again. migration_thread() is just an interface for CPU binding and CPU power management functions. This thread is an important part of the scheduling system.

watchdog

There are 32 kernel threads in total, from watchdog/0 to watchdog/31. Each processor core corresponds to a watchdog kernel thread. Watchdog is used to monitor the operation of the system and automatically restart the system when the system fails, including A kernel watchdog module and a user-space watchdog program.

Under the Linux kernel, the basic working principle of watchdog is: when watchdog is started (that is, after the /dev/watchdog device is opened), if /dev/watchdog does not exist within a certain set time interval (1 minute) When a write operation is performed, the hardware watchdog circuit or software timer will restart the system, and each write operation will cause the timer to be reset.

events

There are 32 such kernel threads, from events/0 to events/31, and each processor core corresponds to an events kernel thread. Used to process kernel events. Many software and hardware events (such as power outages, file changes) are converted into events and distributed to threads interested in corresponding events for response.

kblockd

There are 32 such kernel threads, from kblockd/0 to kblockd/31, and each processor core corresponds to a kblockd kernel thread. Used to manage system block devices, it periodically activates block device drivers in the system. If you own a block device, these threads cannot be removed.

aio

There are 32 such kernel threads, from aio/0 to aio/31. Each processor core corresponds to an aio kernel thread, which manages I/O instead of the user process to support user-mode AIO (asynchronous I/O). O), should not be closed.

rpciod

There are 32 kernel threads of this kind, from rpciod/0 to rpciod/31. Each processor core corresponds to one rpciod kernel thread. Its main function is to serve as a daemon for remote procedure call services and is used to start I from the client. /O service, usually used when starting the NFS service.

Summarize

Process is a very important concept in the operating system. All data running on the system will exist in the type of process. In the Linux system: when any event is triggered, the system will define it as a process. Therefore, the process is the only way to implement a Linux program.

The above is the detailed content of System process: 10 knowledge points that operation and maintenance personnel must be familiar with. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete