From ps -auxwf: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2 0.0 0.0 0 0 ? S 16:51 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 16:51 0:00 \_ [migration/0] root 4 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 16:51 0:00 \_ [watchdog/0] root 6 0.0 0.0 0 0 ? S 16:51 0:00 \_ [migration/1] root 7 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ksoftirqd/1] root 8 0.0 0.0 0 0 ? S 16:51 0:00 \_ [watchdog/1] root 9 0.0 0.0 0 0 ? S 16:51 0:00 \_ [events/0] root 10 0.0 0.0 0 0 ? S 16:51 0:00 \_ [events/1] root 11 0.0 0.0 0 0 ? S 16:51 0:00 \_ [khelper] root 17 0.0 0.0 0 0 ? S 16:51 0:00 \_ [async/mgr] root 156 0.0 0.0 0 0 ? S 16:51 0:00 \_ [sync_supers] root 158 0.0 0.0 0 0 ? S 16:51 0:00 \_ [bdi-default] root 159 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kintegrityd/0] root 160 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kintegrityd/1] root 162 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kblockd/0] root 163 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kblockd/1] root 165 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kacpid] root 166 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kacpi_notify] root 167 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kacpi_hotplug] root 291 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ata/0] root 292 0.0 0.0 0 0 ? S 16:51 0:01 \_ [ata/1] root 293 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ata_aux] root 295 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ksuspend_usbd] root 299 0.0 0.0 0 0 ? S 16:51 0:00 \_ [khubd] root 302 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kseriod] root 373 0.0 0.0 0 0 ? S 16:51 0:00 \_ [khungtaskd] root 396 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kswapd0] root 450 0.0 0.0 0 0 ? S 16:51 0:00 \_ [aio/0] root 451 0.0 0.0 0 0 ? S 16:51 0:00 \_ [aio/1] root 462 0.0 0.0 0 0 ? S 16:51 0:00 \_ [crypto/0] root 463 0.0 0.0 0 0 ? S 16:51 0:00 \_ [crypto/1] root 674 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kpsmoused] root 680 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kstriped] root 683 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ksnapd] root 713 0.0 0.0 0 0 ? S 16:51 0:00 \_ [usbhid_resumer] root 925 0.0 0.0 0 0 ? S 16:51 0:03 \_ [scsi_eh_0] root 926 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_1] root 937 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_2] root 938 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_3] root 940 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_4] root 941 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_5] root 949 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 951 0.0 0.0 0 0 ? S 16:51 0:00 \_ [flush-259:0] root 1255 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kgameportd] root 1360 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_6] root 1361 0.0 0.0 0 0 ? S 16:51 0:00 \_ [scsi_eh_7] root 1795 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kauditd] root 1991 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kmpathd/0] root 1992 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kmpathd/1] root 1993 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kmpath_handlerd] root 2035 0.0 0.0 0 0 ? S 16:51 0:00 \_ [jbd2/sdd1-8] root 2036 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ext4-dio-unwrit] root 2037 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ext4-dio-unwrit] root 2038 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2039 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2040 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2041 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2042 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2043 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2044 0.0 0.0 0 0 ? S 16:51 0:00 \_ [kjournald] root 2049 0.0 0.0 0 0 ? S 16:51 0:00 \_ [jbd2/sdb6-8] root 2050 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ext4-dio-unwrit] root 2051 0.0 0.0 0 0 ? S 16:51 0:00 \_ [ext4-dio-unwrit] root 2273 0.0 0.0 0 0 ? S 16:51 0:00 \_ [rpciod/0] root 2274 0.0 0.0 0 0 ? S 16:51 0:00 \_ [rpciod/1] root 2629 0.0 0.0 0 0 ? S 16:51 0:00 \_ [bluetooth] root 3224 0.0 0.0 0 0 ? S 21:57 0:00 \_ [flush-259:45875] root 3225 0.0 0.0 0 0 ? S 21:57 0:00 \_ [flush-259:98304] root 3226 0.0 0.0 0 0 ? S 21:57 0:00 \_ [flush-259:58982] root 3227 0.0 0.0 0 0 ? S 21:57 0:00 \_ [flush-259:91750] The flushxxxx are the new kernel thread, what are these doing? Take pid=3224: /proc/3224>cat stack [<ffffffff811987b0>] bdi_writeback_task+0xcb/0x11b [<ffffffff81138f5b>] bdi_start_fn+0xb5/0x131 [<ffffffff810996b6>] kthread+0xa5/0xb4 [<ffffffff81014a5a>] child_rip+0xa/0x20 [<ffffffffffffffff>] 0xffffffffffffffff In mm/backing-dev.c: 283 284 static int bdi_start_fn(void *ptr) 285 { 286 struct bdi_writeback *wb = ptr; 287 struct backing_dev_info *bdi = wb->bdi; 288 int ret; 289 290 /* 291 * Add us to the active bdi_list 292 */ 293 spin_lock_bh(&bdi_lock); 294 list_add_rcu(&bdi->bdi_list, &bdi_list); 295 spin_unlock_bh(&bdi_lock); 296 297 bdi_task_init(bdi, wb); 298 299 /* 300 * Clear pending bit and wakeup anybody waiting to tear us down 301 */ 302 clear_bit(BDI_pending, &bdi->state); 303 smp_mb__after_clear_bit(); 304 wake_up_bit(&bdi->state, BDI_pending); 305 306 ret = bdi_writeback_task(wb); 307 308 /* 309 * Remove us from the list 310 */ 311 spin_lock(&bdi->wb_lock); 312 list_del_rcu(&wb->list); 313 spin_unlock(&bdi->wb_lock); 314 315 /* 316 * Flush any work that raced with us exiting. No new work 317 * will be added, since this bdi isn't discoverable anymore. 318 */ 319 if (!list_empty(&bdi->work_list)) 320 wb_do_writeback(wb, 1); 321 322 wb->task = NULL; 323 return ret; 324 } and bdi_writeback_task(): 929 /* 930 * Handle writeback of dirty data for the device backed by this bdi. Also 931 * wakes up periodically and does kupdated style flushing. 932 */ 933 int bdi_writeback_task(struct bdi_writeback *wb) 934 { 935 unsigned long last_active = jiffies; 936 unsigned long wait_jiffies = -1UL; 937 long pages_written; 938 939 while (!kthread_should_stop()) { 940 pages_written = wb_do_writeback(wb, 0); 941 942 if (pages_written) 943 last_active = jiffies; 944 else if (wait_jiffies != -1UL) { 945 unsigned long max_idle; 946 947 /* 948 * Longest period of inactivity that we tolerate. If we 949 * see dirty data again later, the task will get 950 * recreated automatically. 951 */ 952 max_idle = max(5UL * 60 * HZ, wait_jiffies); 953 if (time_after(jiffies, max_idle + last_active)) 954 break; 955 } 956 957 wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10); 958 schedule_timeout_interruptible(wait_jiffies); 959 try_to_freeze(); 960 } 961 962 return 0; 963 } and wb_do_writeback(): 886 /* 887 * Retrieve work items and do the writeback they describe 888 */ 889 long wb_do_writeback(struct bdi_writeback *wb, int force_wait) 890 { 891 struct backing_dev_info *bdi = wb->bdi; 892 struct bdi_work *work; 893 long wrote = 0; 894 895 while ((work = get_next_work_item(bdi, wb)) != NULL) { 896 struct wb_writeback_args args = work->args; 897 898 /* 899 * Override sync mode, in case we must wait for completion 900 */ 901 if (force_wait) 902 work->args.sync_mode = args.sync_mode = WB_SYNC_ALL; 903 904 /* 905 * If this isn't a data integrity operation, just notify 906 * that we have seen this work and we are now starting it. 907 */ 908 if (args.sync_mode == WB_SYNC_NONE) 909 wb_clear_pending(wb, work); 910 911 wrote += wb_writeback(wb, &args); 912 913 /* 914 * This is a data integrity writeback, so only do the 915 * notification when we have completed the work. 916 */ 917 if (args.sync_mode == WB_SYNC_ALL) 918 wb_clear_pending(wb, work); 919 } 920 921 /* 922 * Check for periodic writeback, kupdated() style 923 */ 924 wrote += wb_check_old_data_flush(wb); 925 926 return wrote; 927 } 928 |