kernel BUG at mm/slab.c

来源:互联网 发布:监控安装设计软件 编辑:程序博客网 时间:2024/06/11 08:13
[csharp] view plaincopy
  1. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  2. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  3. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  4. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  5. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  6. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  7. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  8. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  9. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  10. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  11. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  12. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  13. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  14. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  15. <2>GMAC: swgmac_linux_xmit_frames No More Free Tx Descriptors  
  16. kernel BUG at mm/slab.c:602!  
  17. <0>Kernel panic - not syncing: BUG!  

解决方法:

(1) 定位出错代码

[csharp] view plaincopy
  1. <mm/slab.c>  
  2. static inline struct slab *page_get_slab(struct page *page)  
  3. {  
  4.         BUG_ON(!PageSlab(page));  
  5.         return (struct slab *)page->lru.prev;  
  6. }  

(2) 跟踪PageSlab()函数,PageSlab()函数的宏定义位于

[csharp] view plaincopy
  1. <linux-2.6.28/include/linux/page-flags.h>  
  2. __PAGEFLAG(Slab, slab)  
  3.  
  4. #define TESTPAGEFLAG(uname, lname)                                      \  
  5. static inline int Page##uname(struct page *page)                        \  
  6.                         { return test_bit(PG_##lname, &page->flags); }  
  7.  
  8. #define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)             \  
  9.         __SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)  

由此可知PageSlab函数原型为:

[csharp] view plaincopy
  1. static inline int PageSlab(struct page *page)                         
  2. {  
  3.    return test_bit(PG_slab, &page->flags);  
  4. }  
        因为slab分配器中使用的页面都会加上PG_slab标志,以跟一般页面的区别。在释放内存的时候,经常需要用到从页面到slab的对应转换关系。而page_get_slab()函数在释放内存的时候经常会被引用到,这样可以定位应该是skb内存块释放出了问题。仔细阅读网卡驱动程序,终于发现了问题。
[csharp] view plaincopy
  1. status = gmac_set_tx_qptr(gmacdev, dma_addr, skb->len, (u64)skb,0,0,0,offload_needed);  
  2. if(status < 0){  
  3.          TR0("%s No More Free Tx Descriptors\n",__FUNCTION__);  
  4.          dev_kfree_skb (skb); //出错的根源。  
  5.      //  dev_kfree_skb (skb); // 修改后的代码  
  6.          netif_stop_queue(netdev);  
  7.          local_irq_restore(flags);  
  8.          return -EBUSY;  

原创粉丝点击