linux2.6.28.1编译时__mutex_unlock_slowpath未定义的错误

http://blog.chinaunix.net/uid-9688646-id-3413844.html
下午在编译2.6.28.1内核的时候,采用的是默认的x86_config的配置,make bzImage的时候报错,提示:

    undefined reference to __mutex_unlock_slowpath,

  上网搜索半天也得不到有用的结果,只好自己想办法了。首先索引内核源代码,看下__mutex_unlock_slowpath到底是何方神圣。在http://lxr.linux.no/linux/中得到的结果如下:

  

  1. 268/* 
  2. 269 * Release the lock, slowpath: 
  3. 270 */  
  4. 271static noinline void  
  5. 272__mutex_unlock_slowpath(atomic_t *lock_count)  
  6. 273{  
  7. 274        __mutex_unlock_common_slowpath(lock_count, 1);  
  8. 275}  
  9. 276  
  1.   
  没发现任何问题,很明显代码中是存在了定义的。那为什么还是说找不到呢?只可能相关的宏定义没有打开的原因。继续搜索:
  1. 5#ifndef CONFIG_DEBUG_LOCK_ALLOC  
  2.   56/* 
  3.   57 * We split the mutex lock/unlock logic into separate fastpath and 
  4.   58 * slowpath functions, to reduce the register pressure on the fastpath. 
  5.   59 * We also put the fastpath first in the kernel image, to make sure the 
  6.   60 * branch is predicted by the CPU as default-untaken. 
  7.   61 */  
  8.   62static void noinline __sched  
  9.   63__mutex_lock_slowpath(atomic_t *lock_count);  
  10.   64  
  11.   65/*** 
  12.   66 * mutex_lock - acquire the mutex 
  13.   67 * @lock: the mutex to be acquired 
  14.   68 * 
  15.   69 * Lock the mutex exclusively for this task. If the mutex is not 
  16.   70 * available right now, it will sleep until it can get it. 
  17.   71 * 
  18.   72 * The mutex must later on be released by the same task that 
  19.   73 * acquired it. Recursive locking is not allowed. The task 
  20.   74 * may not exit without first unlocking the mutex. Also, kernel 
  21.   75 * memory where the mutex resides mutex must not be freed with 
  22.   76 * the mutex still locked. The mutex must first be initialized 
  23.   77 * (or statically defined) before it can be locked. memset()-ing 
  24.   78 * the mutex to 0 is not allowed. 
  25.   79 * 
  26.   80 * ( The CONFIG_DEBUG_MUTEXES .config option turns on debugging 
  27.   81 *   checks that will enforce the restrictions and will also do 
  28.   82 *   deadlock debugging. ) 
  29.   83 * 
  30.   84 * This function is similar to (but not equivalent to) down(). 
  31.   85 */  
  32.   86void inline __sched mutex_lock(struct mutex *lock)  
  33.   87{  
  34.   88        might_sleep();  
  35.   89        /* 
  36.   90         * The locking fastpath is the 1->0 transition from 
  37.   91         * 'unlocked' into 'locked' state. 
  38.   92         */  
  39.   93        __mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath);  
  40.   94}  
  41.   95  
  42.   96EXPORT_SYMBOL(mutex_lock);  
  43.   97#endif  
  44.   98  
  45.   99static noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);  
  46.  100  
  47.  101/*** 
  48.  102 * mutex_unlock - release the mutex 
  49.  103 * @lock: the mutex to be released 
  50.  104 * 
  51.  105 * Unlock a mutex that has been locked by this task previously. 
  52.  106 * 
  53.  107 * This function must not be used in interrupt context. Unlocking 
  54.  108 * of a not locked mutex is not allowed. 
  55.  109 * 
  56.  110 * This function is similar to (but not equivalent to) up(). 
  57.  111 */  
  58.  112void __sched mutex_unlock(struct mutex *lock)  
  59.  113{  
  60.  114        /* 
  61.  115         * The unlocking fastpath is the 0->1 transition from 'locked' 
  62.  116         * into 'unlocked' state: 
  63.  117         */  
  64.  118        __mutex_fastpath_unlock(&lock->count, __mutex_unlock_slowpath);  
  65.  119}  
  66.  120  



   发现CONFIG_DEBUG_LOCK_ALLOC控制了__mutex_unlock_slowpath的定义。打开.config搜索,看是否CONFIG_DEBUG_LOCK_ALLOC宏是否设置,发现设置了。那肯定还有另外的宏在起控制作用。继续搜索,发现如下结果:

    

  1. 22/* 
  2. 23 * In the DEBUG case we are using the "NULL fastpath" for mutexes, 
  3. 24 * which forces all calls into the slowpath: 
  4. 25 */  
  5. 26#ifdef CONFIG_DEBUG_MUTEXES  
  6. 27# include "mutex-debug.h"  
  7. 28# include <asm-generic/mutex-null.h>  
  8. 29#else  
  9. 30# include "mutex.h"  
  10. 31# include <asm/mutex.h>  
  11. 32#endif  
  12. 33  

   可以看到CONFIG_DEBUG_MUTEXES控制了头文件的包含关系,再次在.config中搜索,发现CONFIG_DEBUG_MUTEXES宏果然没有定义。将其改成y,重新编译,通过。


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值