吴文官 发表于 2003-5-9 11:21:11

about defining PIDHASH_SZ

PIDHASH_SZ is defined in include/linux/sched.h:

#define PIDHASH_SZ (4096>>2)

why not just "#define PIDHASH_SZ 1024"?

Dragonfly 发表于 2003-5-9 11:55:25

hehe, who know. i guess they want to change it to a dynamic one.

吴文官 发表于 2003-5-9 13:14:29

我想
仅仅是为了在这个数前边加上两个0,保证它一定是个正数
但是,有这必要吗?

Dragonfly 发表于 2003-5-9 21:38:01

no, if u define 1024, it will be a positive number as well.

吴文官 发表于 2003-5-11 14:45:15

查了一些资料,终于明白了:
4096为一个页面大小,一个指针需要一个双字,所以要右移2,也就是除以4,这样,一个散列表占用了1个页面
可以修改这个4096来使散列表占用两个以上的页面,这样,可以同时进行散列的进程就更多。
为了修改的方便,这里用4096>>2来代替1024

Dragonfly 发表于 2003-5-11 22:05:06

my opinion
1) since linux/sched.h is a platform netural header. it can not assume the page size is 4k. on non-x86 system, page size is different. and even x86 has huge page.
2) the number of processes can operate on hash table is decided by lock, not hash table size. even a very small hash table can have many rlock on it, while a very large hash table can still have a write lock on it.

吴文官 发表于 2003-5-15 10:58:37

this section can be found in Linux kernel v2.4.0
but can't be found in Linux kernel v2.4.18

why?

Dragonfly 发表于 2003-5-15 11:15:35

this section can be found in Linux kernel v2.4.0
but can't be found in Linux kernel v2.4.18

why?

i can find
#define PIDHASH_SZ (4096 >> 2)
in 2.4.18
which 2.4.18 u mean? rh one?

吴文官 发表于 2003-5-15 12:14:42

oh
sorry
it is 2.4.20-8
rh 9

Dragonfly 发表于 2003-5-15 22:01:52

yes, rh changes so many. so maybe checking the patch redhat made to linux kernel can know current kernel problem and learn more.
页: [1]
查看完整版本: about defining PIDHASH_SZ