您好,请教一个奇怪的问题。
最近在调一个PCI转SATA的卡,装上驱动后,在SATA硬盘的两个分区内进行文拷贝,发现小文件复制时很正常,但对大文操作时,第一次正常,第二次就出现问题,导致死机。实在不明白是为什么,希望得到高手指点,不胜感激!
siimage3512 pci-sata转接卡,内存:128M。
# free
total used free shared buffers
Mem: 127324 28052 99272 0 20536
Swap: 104 0 104
Total: 127428 28052 99376
# cp /mnt/usb1/fc9.iso /mnt/usb2/fc9.iso.bak //第一次可正常复制
# free
total used free shared buffers
Mem: 127324 124580 2744 0 20544
Swap: 104 0 104
Total: 127428 124580 2848
# rm /mnt/usb2/fc9.iso.bak
# cp /mnt/usb1/fc9.iso /mnt/usb2/fc9.iso.bak
kblockd/0: page allocation failure. order:1, mode:0x21
[<c0023a34>] (dump_stack+0x0/0x14) from [<c0050f34>] (__alloc_pages+0x294/0x2a8)
[<c0050ca0>] (__alloc_pages+0x0/0x2a8) from [<c0025580>] (__dma_alloc+0x1b4/0x40c)
[<c00253cc>] (__dma_alloc+0x0/0x40c) from [<c00257fc>] (dma_alloc_coherent+0x24/0x2c)
[<c00257d8>] (dma_alloc_coherent+0x0/0x2c) from [<c00297ac>] (dma_map_sg+0x214/0x340)
[<c0029598>] (dma_map_sg+0x0/0x340) from [<c01214e0>] (ata_qc_issue+0x1e0/0x364)
[<c0121300>] (ata_qc_issue+0x0/0x364) from [<c0125098>] (ata_scsi_translate+0xac/0xec)
[<c0124fec>] (ata_scsi_translate+0x0/0xec) from [<c012620c>] (ata_scsi_queuecmd+0x15c/0x17c)
[<c01260b0>] (ata_scsi_queuecmd+0x0/0x17c) from [<c0113f28>] (scsi_dispatch_cmd+0x1e8/0x268)
r6 = C6D85000 r5 = C6F881C0 r4 = 80000013
[<c0113d40>] (scsi_dispatch_cmd+0x0/0x268) from [<c0119728>] (scsi_request_fn+0x264/0x30c)
r8 = C6FA9318 r7 = C6F881C0 r6 = C6D85000 r5 = C6FAAB38
r4 = C6ED2000
[<c01194c4>] (scsi_request_fn+0x0/0x30c) from [<c00ce0bc>] (__generic_unplug_device+0x30/0x34)
[<c00ce08c>] (__generic_unplug_device+0x0/0x34) from [<c00ce0dc>] (generic_unplug_device+0x1c/0x2c)
r4 = C4142A20
[<c00ce0c0>] (generic_unplug_device+0x0/0x2c) from [<c00ce128>] (blk_unplug_work+0x14/0x18)
[<c00ce114>] (blk_unplug_work+0x0/0x18) from [<c003f2e0>] (run_workqueue+0xb4/0x108)
[<c003f22c>] (run_workqueue+0x0/0x108) from [<c003f448>] (worker_thread+0x114/0x16c)
r7 = C4142A20 r6 = C6E3DF90 r5 = C4142A28 r4 = C4142A30
[<c003f334>] (worker_thread+0x0/0x16c) from [<c0042c28>] (kthread+0xec/0x11c)
r7 = C003F334 r6 = C4153F0C r5 = C6E3C000 r4 = C4142A20
[<c0042b3c>] (kthread+0x0/0x11c) from [<c0031750>] (do_exit+0x0/0x7b8)
Mem-info:
DMA per-cpu:
cpu 0 hot: high 18, batch 3 used:0
cpu 0 cold: high 6, batch 1 used:0
DMA32 per-cpu:
cpu 0 hot: high 18, batch 3 used:0
cpu 0 cold: high 6, batch 1 used:0
Normal per-cpu: empty
HighMem per-cpu: empty
Free pages: 1760kB (0kB HighMem)
Active:3485 inactive:25347 dirty:2996 writeback:0 unstable:0 free:440 slab:1840 mapped:341 pagetables:28
DMA free:1036kB min:724kB low:904kB high:1084kB active:0kB inactive:58056kB present:65536kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 64 64 64
DMA32 free:724kB min:724kB low:904kB high:1084kB active:13940kB inactive:43332kB present:65536kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
HighMem free:0kB min:128kB low:128kB high:128kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
DMA: 225*4kB 1*8kB 0*16kB 0*32kB 0*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1036kB
DMA32: 1*4kB 2*8kB 0*16kB 0*32kB 1*64kB 1*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 724kB
Normal: empty
HighMem: empty
Swap cache: add 0, delete 0, find 0/0, race 0+0
Free swap = 104kB
Total swap = 104kB
Free swap: 104kB
32768 pages of RAM
636 free pages
1104 reserved pages
1840 slab pages
12658 pages shared
0 pages swap cached
sata_sil 0000:00:04.0: alloc_safe_buffer: could not alloc dma memory (size=8192)
sata_sil 0000:00:04.0: map_single: unable to map unsafe buffer c742e000!
kblockd/0: page allocation failure. order:1, mode:0x21
[<c0023a34>] (dump_stack+0x0/0x14) from [<c0050f34>] (__alloc_pages+0x294/0x2a8)
[<c0050ca0>] (__alloc_pages+0x0/0x2a8) from [<c0025580>] (__dma_alloc+0x1b4/0x40c)
[<c00253cc>] (__dma_alloc+0x0/0x40c) from [<c00257fc>] (dma_alloc_coherent+0x24/0x2c)
[<c00257d8>] (dma_alloc_coherent+0x0/0x2c) from [<c00297ac>] (dma_map_sg+0x214/0x340)
[<c0029598>] (dma_map_sg+0x0/0x340) from [<c01214e0>] (ata_qc_issue+0x1e0/0x364)
[<c0121300>] (ata_qc_issue+0x0/0x364) from [<c0125098>] (ata_scsi_translate+0xac/0xec)
[<c0124fec>] (ata_scsi_translate+0x0/0xec) from [<c012620c>] (ata_scsi_queuecmd+0x15c/0x17c)
[<c01260b0>] (ata_scsi_queuecmd+0x0/0x17c) from [<c0113f28>] (scsi_dispatch_cmd+0x1e8/0x268)
r6 = C6D85000 r5 = C6F881C0 r4 = 80000013
[<c0113d40>] (scsi_dispatch_cmd+0x0/0x268) from [<c0119728>] (scsi_request_fn+0x264/0x30c)
r8 = C6FA9318 r7 = C6F881C0 r6 = C6D85000 r5 = C6FAAB38
r4 = C6ED2000
[<c01194c4>] (scsi_request_fn+0x0/0x30c) from [<c00ce0bc>] (__generic_unplug_device+0x30/0x34)
[<c00ce08c>] (__generic_unplug_device+0x0/0x34) from [<c00ce0dc>] (generic_unplug_device+0x1c/0x2c)
r4 = C4142A20
[<c00ce0c0>] (generic_unplug_device+0x0/0x2c) from [<c00ce128>] (blk_unplug_work+0x14/0x18)
[<c00ce114>] (blk_unplug_work+0x0/0x18) from [<c003f2e0>] (run_workqueue+0xb4/0x108)
[<c003f22c>] (run_workqueue+0x0/0x108) from [<c003f448>] (worker_thread+0x114/0x16c)
r7 = C4142A20 r6 = C6E3DF90 r5 = C4142A28 r4 = C4142A30
[<c003f334>] (worker_thread+0x0/0x16c) from [<c0042c28>] (kthread+0xec/0x11c)
r7 = C003F334 r6 = C4153F0C r5 = C6E3C000 r4 = C4142A20
[<c0042b3c>] (kthread+0x0/0x11c) from [<c0031750>] (do_exit+0x0/0x7b8)
Mem-info:
DMA per-cpu:
cpu 0 hot: high 18, batch 3 used:0
cpu 0 cold: high 6, batch 1 used:0
DMA32 per-cpu:
cpu 0 hot: high 18, batch 3 used:0
cpu 0 cold: high 6, batch 1 used:0
Normal per-cpu: empty
HighMem per-cpu: empty
Free pages: 1760kB (0kB HighMem)
Active:3485 inactive:25347 dirty:2996 writeback:0 unstable:0 free:440 slab:1840 mapped:341 pagetables:28
DMA free:1036kB min:724kB low:904kB high:1084kB active:0kB inactive:58056kB present:65536kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 64 64 64
DMA32 free:724kB min:724kB low:904kB high:1084kB active:13940kB inactive:43332kB present:65536kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
HighMem free:0kB min:128kB low:128kB high:128kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
DMA: 225*4kB 1*8kB 0*16kB 0*32kB 0*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1036kB
DMA32: 1*4kB 2*8kB 0*16kB 0*32kB 1*64kB 1*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 724kB
Normal: empty
HighMem: empty
Swap cache: add 0, delete 0, find 0/0, race 0+0
Free swap = 104kB
Total swap = 104kB
Free swap: 104kB
32768 pages of RAM
636 free pages
1104 reserved pages
1840 slab pages
12658 pages shared
0 pages swap cached
sata_sil 0000:00:04.0: alloc_safe_buffer: could not alloc dma memory (size=8192)
sata_sil 0000:00:04.0: map_single: unable to map unsafe buffer c44ca000!
----------------------------------------
然后死机。。。
说是swap的问题,可第一次正常复制后,swap区好像根本没有用到。第二次却因为分不到交换区,真是奇怪。。。。
[ 本帖最后由 dreamice 于 2008-11-3 20:14 编辑 ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
在rm后,你用free看看情况是怎样的,不要急着复制。这样有助于分析问题提供一些信息。
在rm后,free的结果为:
# rm FC9.iso
# free
total used free shared buffers
Mem: 127324 74868 52456 0 21568
Swap: 104 0 104
Total: 127428 74868 52560
也没有太显著的变化呀。
这是由什么原因引起的问题了,太奇怪了...
你看看你free的已经不多了啊,不足以完成你下次拷贝。如果驱动没有做这种边界性的检查,那你多复制这么多,必然会导致失败。至于为什么是alloc_page failure,这个可能和复制实际执行写硬盘的操作有关。
通常,swap是一个交换区,你复制的动作发生了,但真正写硬盘却并不是立即执行——尤其是大数据量的移动。所以,可能你上次复制的还在swap区,后面继续复制,但硬盘的大小已经无法容纳你的复制需求了,才会报出这样的错误。
终于搞明白了,在复制后,手动进行一下同步,再清缓存,之后再复制就OK了。
# free
total used free shared buffers
Mem: 127324 29212 98112 0 21544
Swap: 104 0 104
Total: 127428 29212 98216
# cp /mnt/usb1/fc9.iso /mnt/usb2/fc9.iso.bak
# free
total used free shared buffers
Mem: 127324 124520 2804 0 20564
Swap: 104 0 104
Total: 127428 124520 2908
# sync
# echo 3 > /proc/sys/vm/drop_caches
# free
total used free shared buffers
Mem: 127324 26996 100328 0 20480
Swap: 104 0 104
Total: 127428 26996 100432
# cp /mnt/usb1/Fedora-9-i386-DVD.iso /mnt/usb2/fc9.iso
# ---------------------------------------------------------------------------
OK了
可问题是内核怎么不能自动清除缓存了,在FC9上就不会出现这种问题呀。
恭喜兄弟
估计是老版本的内核的一个bug吧,或者是定期清缓冲的时间比较长。这个没有研究过,兄弟可以研究研究,写个心得大家分享,呵呵。
刚看了下linux的MM,原来是在打开一个文件后,内存中的缓存并不会自动清空,以提高下一操作对同一文件的访问时的命中率;但如果下一操作不是打开同一文件,且内存不足的话,则会立即清空原来的缓存。
应该是这样的,如果马上清空,也是不合理的,所以,有的时候就得主动清一下,来确保你操作的正确性。
可如果真的需要连续复制一个大文件时,该怎么办了?总不至于还得先手动清除内存中的缓存,否则就死机吧。。。
在理解内核运行机制的基础上,去完成特定的操作,只要你知道什么时候该清,什么时候不该清,这样操作就铁定没有问题了。
毕竟Linux不只是针对一个特定应用而开发的,如果你需要自己特定的功能,比如说让他马上就清缓存,估计这只能通过改内核源码来实现了。