public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Ctrl+C doesn't interrupt process waiting for I/O
@ 2008-06-28 10:38 Török Edwin
  2008-06-29  2:44 ` Jeremy Fitzhardinge
  2008-07-01  7:47 ` Elias Oltmanns
  0 siblings, 2 replies; 47+ messages in thread
From: Török Edwin @ 2008-06-28 10:38 UTC (permalink / raw)
  To: Linux Kernel

Hi,

I have encountered the following situation several times, but I've been
unable to come up with a way to reproduce this until now:
 - some process is keeping the disk busy (some cron job for example:
updatedb, chkrootkit, ...)
 - other processes that want to do I/O have to wait (this is normal)
 - I have a (I/O bound) process running in my terminal, and I want to
interrupt it with Ctrl+C
 - I type Ctrl+C several times, and the process is not interrupted for
several seconds (10-30 secs)
 - if I type Ctrl+Z, and use kill %1 the process dies faster than
waiting for it to react to Ctrl+C

This issue occurs both on my x86-64 machine that uses reiserfs, and on
my x86 machine that uses XFS, so it doesn't seem related to the
underlying FS.
I use 2.6.25-2 and 2.6.26-rc8 now; I don't recall seeing this behaviour
with old kernels (IIRC I see this since 2.6.21 or 2.6.23).

Is this intended behaviour, or should I report a bug?

If it should be considered a bug, I will try several kernels to see if
there is a particular kernel version that introduced this behaviour.

To reproduce this issue here is a testcase:
Step 1: Run this shell script in a terminal in X (gnome-terminal,
konsole, ...):
#!/bin/sh
# choose a size that will keep the disks busy for about half a minute or
more
dd if=/dev/zero of=xt bs=100M count=4&
dd if=/dev/zero of=yt bs=100M count=4&
rm xt
rm yt
wait %1 %2

Step 2: Run latencytop
Step 3: In another terminal run an I/O bound process and try to
interrupt it with Ctrl+C, see how fast it responds, for example:
edwin@thunder:~/tst$ find / >/dev/null
find: `/boot/lost+found': Permission denied
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
edwin@thunder:~/tst$

Step 4: repeat step 3 until you get a behaviour like the above (repeat
20-30 times, it doesn't always happen, when it happens you have to press
Ctrl+C several times in order for the process to react)

Here is the output of /proc/latency_stats when this situation occured,
notice that even select has a high latency:

Latency Top version : v0.1
555 202326 4994 do_sys_poll sys_poll sysenter_past_esp
430 515897 4994 do_select core_sys_select sys_select sysenter_past_esp
12 1140 1013 tty_wait_until_sent set_termios tty_mode_ioctl n_tty_ioctl
tty_ioctl vfs_ioctl do_vfs_ioctl sys_ioctl sysenter_past_esp
434 60405 4522 do_select core_sys_select sys_select sysenter_past_esp
21 244388 54486 blk_execute_rq scsi_execute scsi_execute_req
sr_test_unit_ready sr_media_change media_changed cdrom_media_changed
sr_block_media_changed check_disk_change cdrom_open sr_block_open do_open
21 44988 7252 blk_execute_rq scsi_execute scsi_execute_req
sr_test_unit_ready sr_drive_status cdrom_ioctl sr_block_ioctl
blkdev_driver_ioctl blkdev_ioctl block_ioctl vfs_ioctl do_vfs_ioctl
7 7052 1185 blk_execute_rq scsi_execute sr_do_ioctl sr_packet
cdrom_get_media_event sr_drive_status cdrom_ioctl sr_block_ioctl
blkdev_driver_ioctl blkdev_ioctl block_ioctl vfs_ioctl
7 4399 735 blk_execute_rq scsi_execute scsi_execute_req
ioctl_internal_command scsi_set_medium_removal sr_lock_door
cdrom_release sr_block_release __blkdev_put blkdev_put blkdev_close __fput
32 5646 3269 sys_epoll_wait sysenter_past_esp
14 14108 3260 futex_wait do_futex sys_futex sysenter_past_esp
4 5257 4095 futex_wait do_futex sys_futex sysenter_past_esp
7 2712 1396 pipe_wait pipe_read do_sync_read vfs_read sys_read
sysenter_past_esp
2 0 0 pipe_wait pipe_read do_sync_read vfs_read sys_read sysenter_past_esp
208 1996603 953067 xfs_ilock xfs_iomap __xfs_get_blocks xfs_get_blocks
__block_prepare_write block_write_begin xfs_vm_write_begin
generic_file_buffered_write xfs_write xfs_file_aio_write do_sync_write
vfs_write
21 10264428 915514 get_request_wait __make_request generic_make_request
submit_bio xfs_submit_ioend_bio xfs_submit_ioend xfs_page_state_convert
xfs_vm_writepage __writepage write_cache_pages generic_writepages
xfs_vm_writepages
26 3369263 2260529 down xfs_buf_iowait xfs_buf_iostart
xfs_buf_read_flags xfs_trans_read_buf xfs_imap_to_bp xfs_itobp xfs_iread
xfs_iget_core xfs_iget xfs_lookup xfs_vn_lookup
1 17888 17888 down xfs_buf_iowait xfs_buf_iostart xfs_buf_read_flags
xfs_trans_read_buf xfs_da_do_buf xfs_da_read_buf xfs_dir2_block_getdents
xfs_readdir xfs_file_readdir vfs_readdir sys_getdents64
2 8226 7641 down xfs_buf_iowait xfs_buf_iostart xfs_buf_read_flags
xfs_trans_read_buf xfs_da_do_buf xfs_da_read_buf xfs_dir2_leaf_getdents
xfs_readdir xfs_file_readdir vfs_readdir sys_getdents64
2 16090 10971 down xfs_buf_iowait xfs_buf_iostart xfs_buf_read_flags
xfs_trans_read_buf xfs_da_do_buf xfs_da_read_buf
xfs_dir2_leaf_lookup_int xfs_dir2_leaf_lookup xfs_dir_lookup xfs_lookup
xfs_vn_lookup
1 2149 2149 down xfs_buf_lock _xfs_buf_find xfs_buf_get_flags
xfs_buf_read_flags xfs_trans_read_buf xfs_da_do_buf xfs_da_read_buf
xfs_dir2_leaf_getdents xfs_readdir xfs_file_readdir vfs_readdir
2 0 0 unix_stream_recvmsg sock_recvmsg sys_recvfrom sys_recv
sys_socketcall sysenter_past_esp
43 1340361 1336178 xfs_ilock xfs_iomap xfs_map_blocks
xfs_page_state_convert xfs_vm_writepage __writepage write_cache_pages
generic_writepages xfs_vm_writepages do_writepages
__writeback_single_inode sync_sb_inodes
1 6 6 xfs_ilock xfs_iomap_write_allocate xfs_iomap xfs_map_blocks
xfs_page_state_convert xfs_vm_writepage __writepage write_cache_pages
generic_writepages xfs_vm_writepages do_writepages __writeback_single_inode
64 1052948 21773 congestion_wait __alloc_pages_internal __alloc_pages
__grab_cache_page block_write_begin xfs_vm_write_begin
generic_file_buffered_write xfs_write xfs_file_aio_write do_sync_write
vfs_write sys_write
3 5264928 3610252 sync_page wait_on_page_bit
wait_on_page_writeback_range filemap_fdatawait xfs_fsync xfs_file_fsync
do_fsync __do_fsync sys_fsync sysenter_past_esp
1 284000 284000 get_request_wait __make_request generic_make_request
submit_bio _xfs_buf_ioapply xfs_buf_iorequest xlog_bdstrat_cb xlog_sync
xlog_state_release_iclog xlog_state_sync _xfs_log_force _xfs_trans_commit
3 1724786 1319135 xlog_state_sync _xfs_log_force _xfs_trans_commit
xfs_fsync xfs_file_fsync do_fsync __do_fsync sys_fsync sysenter_past_esp
3 2851878 1642865 down xfs_buf_lock _xfs_buf_find xfs_buf_get_flags
xfs_buf_read_flags xfs_trans_read_buf xfs_alloc_read_agf
xfs_alloc_fix_freelist xfs_alloc_vextent xfs_bmap_btalloc xfs_bmap_alloc
xfs_bmapi
17 43 23 xfs_ilock xfs_iomap_write_allocate xfs_iomap xfs_map_blocks
xfs_page_state_convert xfs_vm_writepage shrink_page_list
shrink_inactive_list shrink_zone try_to_free_pages
__alloc_pages_internal __alloc_pages
1 45 45 down xfs_buf_lock _xfs_buf_find xfs_buf_get_flags
xfs_buf_read_flags xfs_trans_read_buf xfs_btree_read_bufs
xfs_alloc_lookup xfs_alloc_lookup_eq xfs_alloc_fixup_trees
xfs_alloc_ag_vextent_size xfs_alloc_ag_vextent
1 539 539 congestion_wait __alloc_pages_internal __alloc_pages
handle_mm_fault do_page_fault error_code
2 26759 21339 congestion_wait __alloc_pages_internal __alloc_pages
__get_free_pages proc_file_read proc_reg_read vfs_read sys_read
sysenter_past_esp
6 96540 19159 congestion_wait __alloc_pages_internal __alloc_pages
__get_free_pages __pollwait unix_poll sock_poll do_select
core_sys_select sys_select sysenter_past_esp
2 53244 47209 mempool_alloc bio_alloc_bioset bio_alloc
xfs_alloc_ioend_bio xfs_submit_ioend xfs_page_state_convert
xfs_vm_writepage __writepage write_cache_pages generic_writepages
xfs_vm_writepages do_writepages
1 425375 425375 sync_page __lock_page find_lock_page filemap_fault
__do_fault handle_mm_fault do_page_fault error_code

Best regards,
--Edwin

^ permalink raw reply	[flat|nested] 47+ messages in thread
* Re: Ctrl+C doesn't interrupt process waiting for I/O
@ 2008-07-03  0:59 Matthew Wilcox
  0 siblings, 0 replies; 47+ messages in thread
From: Matthew Wilcox @ 2008-07-03  0:59 UTC (permalink / raw)
  To: linux-kernel


I'd like to correct a few misapprehensions in this thread.  To be fair,
what they were saying used to be true, but it isn't any more, and I
would like people to be aware of it.

Avi Kivity wrote:
> That's filesystem dependent; if you mount an nfs filesystem with the 
> 'intr' mount option, it will be interruptible (which makes sense, as it 
> is impossible to guarantee the server's responsiveness).

As of v2.6.25, 'intr' is a no-op.  The option is still recognised, but
it does not change NFS's behaviour.

Bill Davidson wrote:
> Basic problem is that you can get a process which you can't interrupt 
> (in in most cases can't kill) which has resources tied up. Given the 
> choice between surprising a process with an EINTR or killing it during a 
> reboot to get the system usable again, I would rather surprise.

I implemented option C (none of the above).  NFS now sleeps in state
TASK_KILLABLE so tasks can be killed, but they will never see the -EINTR
return (since they're dead).  Yes, that means you can end up with a
partial write to a file on the server.  But if you tripped over the
(power/network) cable, that could happen anyway.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2008-07-12 10:54 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-28 10:38 Ctrl+C doesn't interrupt process waiting for I/O Török Edwin
2008-06-29  2:44 ` Jeremy Fitzhardinge
2008-06-29  2:45   ` Jeremy Fitzhardinge
2008-06-29  3:42   ` Avi Kivity
2008-06-29  5:13     ` Jeremy Fitzhardinge
2008-06-29  5:39       ` Avi Kivity
2008-06-29  6:25         ` Jeremy Fitzhardinge
2008-06-29  7:45           ` Török Edwin
2008-06-29 23:57           ` Bill Davidsen
2008-06-29 12:37         ` Alan Cox
2008-06-30 17:35       ` J. Bruce Fields
2008-06-29  7:09   ` Török Edwin
2008-06-29  7:23   ` David Newall
2008-06-29 12:10   ` Andi Kleen
2008-06-29 16:02     ` Jeremy Fitzhardinge
2008-06-30 10:30       ` Helge Hafting
2008-07-01  7:47 ` Elias Oltmanns
2008-07-01  8:02   ` Elias Oltmanns
2008-07-01  8:28     ` Török Edwin
2008-07-01  9:59       ` Elias Oltmanns
2008-07-01 12:07       ` Joe Peterson
2008-07-01  8:50   ` David Newall
2008-07-01  9:01     ` Török Edwin
2008-07-01  9:12       ` David Newall
2008-07-01 14:12   ` Joe Peterson
2008-07-01 14:48     ` Elias Oltmanns
2008-07-01 16:27       ` Joe Peterson
2008-07-02 21:26   ` Joe Peterson
2008-07-04 20:10   ` Joe Peterson
2008-07-04 20:23     ` Alan Cox
2008-07-04 21:17       ` Joe Peterson
2008-07-11 14:47         ` Alan Cox
2008-07-12  0:44           ` Joe Peterson
2008-07-12 10:37             ` Alan Cox
2008-07-04 21:21       ` Andi Kleen
2008-07-04 21:14         ` Alan Cox
2008-07-04 21:36           ` Andi Kleen
2008-07-04 21:44             ` Alan Cox
2008-07-04 22:09               ` Andi Kleen
2008-07-05 10:34                 ` Alan Cox
2008-07-05 11:00                   ` Andi Kleen
2008-07-05 11:34                     ` Alan Cox
2008-07-05 12:49                     ` Elias Oltmanns
2008-07-05 14:01                       ` Andi Kleen
2008-07-05 19:58                       ` Joe Peterson
2008-07-06  8:28                         ` Elias Oltmanns
  -- strict thread matches above, loose matches on Subject: below --
2008-07-03  0:59 Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox