免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5054 | 回复: 4
打印 上一主题 下一主题

alloc_skb [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-15 09:52 |只看该作者 |倒序浏览
本帖最后由 chenshko 于 2011-09-15 10:00 编辑

在netfilter中构建nskb失败

跟踪发现是alloc_skb失败,一下内核所记录的函数调用栈日志,求高人分析下alloc_skb失败的可能原因。
内核打印了meminfo信息,难到跟swap内存空间的大小有关?
  1. Sep 14 12:24:10 localhost kernel: swapper: page allocation failure. order:0, mode:0x20
  2. Sep 14 12:24:10 localhost kernel: Pid: 0, comm: swapper Not tainted 2.6.29.6NFQ #18
  3. Sep 14 12:24:10 localhost kernel: Call Trace:
  4. Sep 14 12:24:10 localhost kernel:  [<c015cec4>] __alloc_pages_internal+0x351/0x363
  5. Sep 14 12:24:10 localhost kernel:  [<c0178d53>] allocate_slab+0x55/0xa0
  6. Sep 14 12:24:10 localhost kernel:  [<c0178dd6>] new_slab+0x1f/0xff
  7. Sep 14 12:24:10 localhost kernel:  [<c0179272>] __slab_alloc+0xab/0x14d
  8. Sep 14 12:24:10 localhost kernel:  [<c0179370>] kmem_cache_alloc+0x5c/0x9f
  9. Sep 14 12:24:10 localhost kernel:  [<c02dcdb8>] __alloc_skb+0x25/0xef
  10. Sep 14 12:24:10 localhost last message repeated 2 times
  11. Sep 14 12:24:10 localhost kernel:  [<c02fa566>] nfqnl_build_packet_message+0xb7/0x499
  12. Sep 14 12:24:10 localhost kernel:  [<c02fdc84>] __nf_ct_refresh_acct+0x116/0x157
  13. Sep 14 12:24:11 localhost kernel:  [<f85b9582>] ipt_do_table+0x410/0x42f [ip_tables]
  14. Sep 14 12:24:11 localhost kernel:  [<c02fab4d>] qzt_nfqnl_enqueue_packet+0x13/0x194
  15. Sep 14 12:24:11 localhost kernel:  [<c02f9b7c>] __nf_queue+0x131/0x15e
  16. Sep 14 12:24:11 localhost kernel:  [<c0308565>] ip_rcv_finish+0x0/0x25b
  17. Sep 14 12:24:11 localhost kernel:  [<c02f96aa>] nf_hook_slow+0xa0/0xb4
  18. Sep 14 12:24:11 localhost kernel:  [<c0308565>] ip_rcv_finish+0x0/0x25b
  19. Sep 14 12:24:11 localhost kernel:  [<c030899d>] ip_rcv+0x1dd/0x214
  20. Sep 14 12:24:11 localhost kernel:  [<c0308565>] ip_rcv_finish+0x0/0x25b
  21. Sep 14 12:24:11 localhost kernel:  [<c02e424b>] netif_receive_skb+0x279/0x29d
  22. Sep 14 12:24:11 localhost kernel:  [<f8226026>] rtl8139_rx+0x197/0x260 [8139too]
  23. Sep 14 12:24:11 localhost kernel:  [<f8226271>] rtl8139_poll+0x49/0xa0 [8139too]
  24. Sep 14 12:24:11 localhost kernel:  [<c02e4a35>] net_rx_action+0x9b/0x168
  25. Sep 14 12:24:11 localhost kernel:  [<c012a9de>] __do_softirq+0x72/0xf2
  26. Sep 14 12:24:11 localhost kernel:  [<c012a96c>] __do_softirq+0x0/0xf2
  27. Sep 14 12:24:11 localhost kernel:  <IRQ>  [<c0104664>] do_IRQ+0xc4/0xd8
  28. Sep 14 12:24:11 localhost kernel:  [<c0103527>] common_interrupt+0x27/0x2c
  29. Sep 14 12:24:11 localhost kernel:  [<c0107edf>] mwait_idle+0x4d/0x55
  30. Sep 14 12:24:11 localhost kernel:  [<c01017d6>] cpu_idle+0x4c/0x60
  31. Sep 14 12:24:11 localhost kernel: Mem-Info:
  32. Sep 14 12:24:11 localhost kernel: DMA per-cpu:
  33. Sep 14 12:24:11 localhost kernel: CPU    0: hi:    0, btch:   1 usd:   0
  34. Sep 14 12:24:11 localhost kernel: CPU    1: hi:    0, btch:   1 usd:   0
  35. Sep 14 12:24:11 localhost kernel: Normal per-cpu:
  36. Sep 14 12:24:11 localhost kernel: CPU    0: hi:  186, btch:  31 usd:  67
  37. Sep 14 12:24:11 localhost kernel: CPU    1: hi:  186, btch:  31 usd:  60
  38. Sep 14 12:24:11 localhost kernel: HighMem per-cpu:
  39. Sep 14 12:24:11 localhost kernel: CPU    0: hi:   42, btch:   7 usd:   5
  40. Sep 14 12:24:11 localhost kernel: CPU    1: hi:   42, btch:   7 usd:   0
  41. Sep 14 12:24:11 localhost kernel: Active_anon:3242 active_file:1444 inactive_anon:3583
  42. Sep 14 12:24:11 localhost kernel:  inactive_file:5238 unevictable:128 dirty:0 writeback:0 unstable:0
  43. Sep 14 12:24:11 localhost kernel:  free:13114 slab:216699 mapped:2081 pagetables:312 bounce:0
  44. Sep 14 12:24:11 localhost kernel: DMA free:3476kB min:64kB low:80kB high:96kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB present:15772kB pages_scanned:0 all_unreclaimable? yes
  45. Sep 14 12:24:11 localhost kernel: lowmem_reserve[]: 0 863 965 965
  46. Sep 14 12:24:11 localhost kernel: Normal free:1392kB min:3724kB low:4652kB high:5584kB active_anon:48kB inactive_anon:64kB active_file:112kB inactive_file:0kB unevictable:0kB present:884200kB pages_scanned:270 all_unreclaimable? yes
  47. Sep 14 12:24:11 localhost kernel: lowmem_reserve[]: 0 0 815 815
  48. Sep 14 12:24:11 localhost kernel: HighMem free:47588kB min:128kB low:236kB high:344kB active_anon:12920kB inactive_anon:14268kB active_file:5664kB inactive_file:20952kB unevictable:512kB present:104384kB pages_scanned:0 all_unreclaimable? no
  49. Sep 14 12:24:11 localhost kernel: lowmem_reserve[]: 0 0 0 0
  50. Sep 14 12:24:11 localhost kernel: DMA: 7*4kB 5*8kB 5*16kB 2*32kB 5*64kB 3*128kB 2*256kB 0*512kB 0*1024kB 1*2048kB 0*4096kB = 3476kB
  51. Sep 14 12:24:11 localhost kernel: Normal: 283*4kB 0*8kB 1*16kB 1*32kB 1*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1372kB
  52. Sep 14 12:24:11 localhost kernel: HighMem: 1021*4kB 1018*8kB 567*16kB 323*32kB 183*64kB 27*128kB 1*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 47572kB
  53. Sep 14 12:24:11 localhost kernel: 7157 total pagecache pages
  54. Sep 14 12:24:11 localhost kernel: 287 pages in swap cache
  55. Sep 14 12:24:11 localhost kernel: Swap cache stats: add 15378, delete 15091, find 63/105
  56. Sep 14 12:24:11 localhost kernel: Free swap  = 2309420kB
  57. Sep 14 12:24:11 localhost kernel: Total swap = 2369576kB
  58. Sep 14 12:24:11 localhost kernel: 253664 pages RAM
  59. Sep 14 12:24:11 localhost kernel: 26354 pages HighMem
  60. Sep 14 12:24:11 localhost kernel: 5044 pages reserved
  61. Sep 14 12:24:11 localhost kernel: 7140 pages shared
  62. Sep 14 12:24:11 localhost kernel: 231054 pages non-shared
复制代码

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
2 [报告]
发表于 2011-09-15 10:00 |只看该作者
回复 1# chenshko
系统内存使用情况如何呢?

论坛徽章:
0
3 [报告]
发表于 2011-09-15 10:30 |只看该作者
回复 2# Godbach

这是出问题前后meminfo前后的对比数据,没感觉有什么很大异常。
也可能是有异常,在alloc_skb失败几次后,内核态杀掉了用户态的与netfilter相关的应用进程,这样的对比数据可能意义不大。
alloc_skb失败有没有可能是用户态进程影响的?
  1. MemTotal:         998704 kB     998704 kB
  2. MemFree:          850992 kB     915412 kB  
  3. Buffers:           11824 kB     5540 kB
  4. Cached:            80592 kB     27032 kB
  5. SwapCached:            0 kB     1104 kB
  6. Active:            50104 kB     18144 kB
  7. Inactive:          72364 kB     38192 kB
  8. Active(anon):      30228 kB     12260 kB
  9. Inactive(anon):        0 kB     12928 kB
  10. Active(file):      19876 kB     5884 kB
  11. Inactive(file):    72364 kB     25264 kB
  12. Unevictable:           0 kB     1260 kB
  13. Mlocked:               0 kB     0 kB
  14. HighTotal:        105416 kB     105416 kB
  15. HighFree:            224 kB     49792 kB
  16. LowTotal:         893288 kB     893288 kB
  17. LowFree:          850768 kB     865620 kB
  18. SwapTotal:       2369576 kB     2369576 kB
  19. SwapFree:        2369576 kB     2365092 kB
  20. Dirty:                28 kB     40 kB
  21. Writeback:             0 kB     0 kB
  22. AnonPages:         30272 kB     24056 kB
  23. Mapped:             8484 kB     5872 kB
  24. Slab:              12300 kB     5280 kB
  25. SReclaimable:       9156 kB     2076 kB
  26. SUnreclaim:         3144 kB     3204 kB
  27. PageTables:          876 kB     784 kB
  28. NFS_Unstable:          0 kB     0 kB
  29. Bounce:                0 kB     0 kB
  30. WritebackTmp:          0 kB     0 kB
  31. CommitLimit:     2868928 kB     2868928 kB
  32. Committed_AS:     110540 kB     72612 kB
  33. VmallocTotal:     122880 kB     122880 kB
  34. VmallocUsed:        3332 kB     3364 kB
  35. VmallocChunk:      98988 kB     98204 kB
  36. HugePages_Total:       0        0
  37. HugePages_Free:        0        0
  38. HugePages_Rsvd:        0        0
  39. HugePages_Surp:        0        0
  40. Hugepagesize:       2048 kB     2048 kB
  41. DirectMap4k:       10232 kB     10232 kB
  42. DirectMap2M:      899072 kB     899072 kB
复制代码

论坛徽章:
7
丑牛
日期:2013-10-18 14:43:21技术图书徽章
日期:2013-11-03 09:58:03辰龙
日期:2014-01-15 22:57:50午马
日期:2014-09-15 07:04:39丑牛
日期:2014-10-16 14:25:222015年亚洲杯之伊朗
日期:2015-03-16 10:24:352015亚冠之城南
日期:2015-05-31 09:52:32
4 [报告]
发表于 2011-09-15 10:39 |只看该作者
你应该改下标题, 把几个懂内存管理的人召唤来

论坛徽章:
0
5 [报告]
发表于 2011-09-15 10:44 |只看该作者
补充下内核杀掉用户态进程的函数调用栈
看到了out_of_memory,心都凉了。

关于out_of_memoy, 什么叫kill the "best" 什么叫Note that we don't have to be perfect here, we just have to be good.
  1. /**
  2. * out_of_memory - kill the "best" process when we run out of memory
  3. * @zonelist: zonelist pointer
  4. * @gfp_mask: memory allocation flags
  5. * @order: amount of memory being requested as a power of 2
  6. *
  7. * If we run out of memory, we have the choice between either
  8. * killing a random task (bad), letting the system crash (worse)
  9. * OR try to be smart about which process to kill. Note that we
  10. * don't have to be perfect here, we just have to be good.
  11. */
复制代码
  1. Sep 14 16:59:26 localhost kernel:  [<c015b399>] oom_kill_process+0x70/0x117
  2. Sep 14 16:59:26 localhost kernel:  [<c015b6a5>] __out_of_memory+0x67/0x72
  3. Sep 14 16:59:26 localhost kernel:  [<c015b76d>] out_of_memory+0x58/0x7f
  4. Sep 14 16:59:26 localhost kernel:  [<c015ce3b>] __alloc_pages_internal+0x2c8/0x363
  5. Sep 14 16:59:26 localhost kernel:  [<c0178d53>] allocate_slab+0x55/0xa0
  6. Sep 14 16:59:26 localhost kernel:  [<c0178dd6>] new_slab+0x1f/0xff
  7. Sep 14 16:59:26 localhost kernel:  [<c0179272>] __slab_alloc+0xab/0x14d
  8. Sep 14 16:59:26 localhost kernel:  [<c017a634>] __kmalloc_track_caller+0x87/0xce
  9. Sep 14 16:59:26 localhost kernel:  [<c02f7b77>] netlink_ack+0x31/0x12b
  10. Sep 14 16:59:26 localhost kernel:  [<c02f7b77>] netlink_ack+0x31/0x12b
  11. Sep 14 16:59:26 localhost kernel:  [<c02dcdd9>] __alloc_skb+0x46/0xef
  12. Sep 14 16:59:26 localhost kernel:  [<c02fa0db>] nfnetlink_rcv_msg+0x0/0x12a
  13. Sep 14 16:59:26 localhost kernel:  [<c02f7b77>] netlink_ack+0x31/0x12b
  14. Sep 14 16:59:26 localhost kernel:  [<c02fa0db>] nfnetlink_rcv_msg+0x0/0x12a
  15. Sep 14 16:59:26 localhost kernel:  [<c02f7cc4>] netlink_rcv_skb+0x53/0x72
  16. Sep 14 16:59:26 localhost kernel:  [<c02fa219>] nfnetlink_rcv+0x14/0x1b
  17. Sep 14 16:59:26 localhost kernel:  [<c02f6b95>] netlink_unicast+0x121/0x17e
  18. Sep 14 16:59:26 localhost kernel:  [<c02f741c>] netlink_sendmsg+0x256/0x265
  19. Sep 14 16:59:26 localhost kernel:  [<c011c6fb>] enqueue_task_fair+0x2a/0x2c
  20. Sep 14 16:59:26 localhost kernel:  [<c02d8c2e>] sock_sendmsg+0xc0/0xdc
  21. Sep 14 16:59:26 localhost kernel:  [<c01cd025>] sys_semtimedop+0x37f/0x3a1
  22. Sep 14 16:59:26 localhost kernel:  [<c0136a8b>] autoremove_wake_function+0x0/0x2d
  23. Sep 14 16:59:26 localhost kernel:  [<c0120fa8>] load_balance_newidle+0x5b/0x205
  24. Sep 14 16:59:26 localhost kernel:  [<c0201c27>] copy_from_user+0x3d/0x62
  25. Sep 14 16:59:26 localhost kernel:  [<c02e00c6>] verify_iovec+0x3e/0x71
  26. Sep 14 16:59:26 localhost kernel:  [<c02da227>] sys_sendmsg+0x147/0x19c
  27. Sep 14 16:59:26 localhost kernel:  [<c011a905>] gup_pmd_range+0x8e/0xac
  28. Sep 14 16:59:26 localhost kernel:  [<c011aaa5>] get_user_pages_fast+0x9b/0x126
  29. Sep 14 16:59:26 localhost kernel:  [<c013f1f1>] get_futex_key+0x10e/0x118
  30. Sep 14 16:59:26 localhost kernel:  [<c013f95f>] futex_wake+0xe2/0xec
  31. Sep 14 16:59:26 localhost kernel:  [<c0356672>] _spin_unlock_irq+0x5/0x7
  32. Sep 14 16:59:26 localhost kernel:  [<c02da5a1>] sys_socketcall+0x16f/0x19e
  33. Sep 14 16:59:26 localhost kernel:  [<c012a226>] sys_gettimeofday+0x43/0x55
  34. Sep 14 16:59:26 localhost kernel:  [<c0102f41>] sysenter_do_call+0x12/0x21
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP