start_kernel---lockdep_init<三>

1 /*
2 * Need to run as early as possible, to initialize the
3 * lockdep hash:
4 */
5 lockdep_init();

位于kernel/lockdep.c

 1 void lockdep_init(void)
2 {
3 int i;
4
5 /*
6 * Some architectures have their own start_kernel()
7 * code which calls lockdep_init(), while we also
8 * call lockdep_init() from the start_kernel() itself,
9 * and we want to initialize the hashes only once:
10 */
11 if (lockdep_initialized)
12 return;
13
14 for (i = 0; i < CLASSHASH_SIZE; i++)
15 INIT_LIST_HEAD(classhash_table + i);
16
17 for (i = 0; i < CHAINHASH_SIZE; i++)
18 INIT_LIST_HEAD(chainhash_table + i);
19
20 lockdep_initialized = 1;
21 }

只初始化该哈希表一次,

1 /*
2 * The lockdep classes are in a hash-table as well, for fast lookup:
3 */
4 #define CLASSHASH_BITS (MAX_LOCKDEP_KEYS_BITS - 1)
5 #define CLASSHASH_SIZE (1UL << CLASSHASH_BITS)
6 #define __classhashfn(key) hash_long((unsigned long)key, CLASSHASH_BITS)
7 #define classhashentry(key) (classhash_table + __classhashfn((key)))
8
9 static struct list_head classhash_table[CLASSHASH_SIZE];

in include/linux/lockdep.h中

#define MAX_LOCKDEP_KEYS_BITS  13

 1 *
2 * We put the lock dependency chains into a hash-table as well, to cache
3 * their existence:
4 */
5 #define CHAINHASH_BITS (MAX_LOCKDEP_CHAINS_BITS-1)
6 #define CHAINHASH_SIZE (1UL << CHAINHASH_BITS)
7 #define __chainhashfn(chain) hash_long(chain, CHAINHASH_BITS)
8 #define chainhashentry(chain) (chainhash_table + __chainhashfn((chain)))
9
10 static struct list_head chainhash_table[CHAINHASH_SIZE];
11
12 #define MAX_LOCKDEP_ENTRIES 16384UL
13
14 #define MAX_LOCKDEP_CHAINS_BITS 15
15 #define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)
16
17 #define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)




转载于:https://www.cnblogs.com/gdt-a20/archive/2012/01/15/2323151.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值