Update dcache, inode, pid, mountpoint, and mount hash tables to use HASH_ZERO, and remove initialization after allocations. In case of places where HASH_EARLY was used such as in __pv_init_lock_hash the zeroed hash table was already assumed, because memblock zeroes the memory. CPU: SPARC M6, Memory: 7T Before fix: Dentry cache hash table entries: 1073741824 Inode-cache hash table entries: 536870912 Mount-cache hash table entries: 16777216 Mountpoint-cache hash table entries: 16777216 ftrace: allocating 20414 entries in 40 pages Total time: 11.798s After fix: Dentry cache hash table entries: 1073741824 Inode-cache hash table entries: 536870912 Mount-cache hash table entries: 16777216 Mountpoint-cache hash table entries: 16777216 ftrace: allocating 20414 entries in 40 pages Total time: 3.198s CPU: Intel Xeon E5-2630, Memory: 2.2T: Before fix: Dentry cache hash table entries: 536870912 Inode-cache hash table entries: 268435456 Mount-cache hash table entries: 8388608 Mountpoint-cache hash table entries: 8388608 CPU: Physical Processor ID: 0 Total time: 3.245s After fix: Dentry cache hash table entries: 536870912 Inode-cache hash table entries: 268435456 Mount-cache hash table entries: 8388608 Mountpoint-cache hash table entries: 8388608 CPU: Physical Processor ID: 0 Total time: 3.244s
Unified · Split
| @@ -3546,8 +3546,6 @@ __setup("dhash_entries=", set_dhash_entries); · 3545 unmodified lines | ||
| 3546 | 3546 | |
| 3547 | 3547 | static void __init dcache_init_early(void) |
| 3548 | 3548 | { |
| 3549 | − unsigned int loop; | |
| 3550 | − | |
| 3551 | 3549 | /* If hashes are distributed across NUMA nodes, defer |
| 3552 | 3550 | * hash allocation until vmalloc space is available. |
| 3553 | 3551 | */ |
| @@ -3559,24 +3557,19 @@ static void __init dcache_init_early(void) · 5 unmodified lines | ||
| 3559 | 3557 | sizeof(struct hlist_bl_head), |
| 3560 | 3558 | dhash_entries, |
| 3561 | 3559 | 13, |
| 3562 | − HASH_EARLY, | |
| 3560 | + HASH_EARLY | HASH_ZERO, | |
| 3563 | 3561 | &d_hash_shift, |
| 3564 | 3562 | &d_hash_mask, |
| 3565 | 3563 | 0, |
| 3566 | 3564 | 0); |
| 3567 | − | |
| 3568 | − for (loop = 0; loop < (1U << d_hash_shift); loop++) | |
| 3569 | − INIT_HLIST_BL_HEAD(dentry_hashtable + loop); | |
| 3570 | 3565 | } |
| 3571 | 3566 | |
| 3572 | 3567 | static void __init dcache_init(void) |
| 3573 | 3568 | { |
| 3574 | − unsigned int loop; | |
| 3575 | − | |
| 3576 | − /* | |
| 3569 | + /* | |
| 3577 | 3570 | * A constructor could be added for stable state like the lists, |
| 3578 | 3571 | * but it is probably not worth it because of the cache nature |
| 3579 | − * of the dcache. | |
| 3572 | + * of the dcache. | |
| 3580 | 3573 | */ |
| 3581 | 3574 | dentry_cache = KMEM_CACHE(dentry, |
| 3582 | 3575 | SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD|SLAB_ACCOUNT); |
| @@ -3590,14 +3583,11 @@ static void __init dcache_init(void) · 7 unmodified lines | ||
| 3590 | 3583 | sizeof(struct hlist_bl_head), |
| 3591 | 3584 | dhash_entries, |
| 3592 | 3585 | 13, |
| 3593 | − 0, | |
| 3586 | + HASH_ZERO, | |
| 3594 | 3587 | &d_hash_shift, |
| 3595 | 3588 | &d_hash_mask, |
| 3596 | 3589 | 0, |
| 3597 | 3590 | 0); |
| 3598 | − | |
| 3599 | − for (loop = 0; loop < (1U << d_hash_shift); loop++) | |
| 3600 | − INIT_HLIST_BL_HEAD(dentry_hashtable + loop); | |
| 3601 | 3591 | } |
| 3602 | 3592 | |
| 3603 | 3593 | /* SLAB cache for __getname() consumers */ |
| @@ -1915,8 +1915,6 @@ __setup("ihash_entries=", set_ihash_entries); · 1914 unmodified lines | ||
| 1915 | 1915 | */ |
| 1916 | 1916 | void __init inode_init_early(void) |
| 1917 | 1917 | { |
| 1918 | − unsigned int loop; | |
| 1919 | − | |
| 1920 | 1918 | /* If hashes are distributed across NUMA nodes, defer |
| 1921 | 1919 | * hash allocation until vmalloc space is available. |
| 1922 | 1920 | */ |
| @@ -1928,20 +1926,15 @@ void __init inode_init_early(void) · 5 unmodified lines | ||
| 1928 | 1926 | sizeof(struct hlist_head), |
| 1929 | 1927 | ihash_entries, |
| 1930 | 1928 | 14, |
| 1931 | − HASH_EARLY, | |
| 1929 | + HASH_EARLY | HASH_ZERO, | |
| 1932 | 1930 | &i_hash_shift, |
| 1933 | 1931 | &i_hash_mask, |
| 1934 | 1932 | 0, |
| 1935 | 1933 | 0); |
| 1936 | − | |
| 1937 | − for (loop = 0; loop < (1U << i_hash_shift); loop++) | |
| 1938 | − INIT_HLIST_HEAD(&inode_hashtable[loop]); | |
| 1939 | 1934 | } |
| 1940 | 1935 | |
| 1941 | 1936 | void __init inode_init(void) |
| 1942 | 1937 | { |
| 1943 | − unsigned int loop; | |
| 1944 | − | |
| 1945 | 1938 | /* inode slab cache */ |
| 1946 | 1939 | inode_cachep = kmem_cache_create("inode_cache", |
| 1947 | 1940 | sizeof(struct inode), |
| @@ -1959,14 +1952,11 @@ void __init inode_init(void) · 11 unmodified lines | ||
| 1959 | 1952 | sizeof(struct hlist_head), |
| 1960 | 1953 | ihash_entries, |
| 1961 | 1954 | 14, |
| 1962 | − 0, | |
| 1955 | + HASH_ZERO, | |
| 1963 | 1956 | &i_hash_shift, |
| 1964 | 1957 | &i_hash_mask, |
| 1965 | 1958 | 0, |
| 1966 | 1959 | 0); |
| 1967 | − | |
| 1968 | − for (loop = 0; loop < (1U << i_hash_shift); loop++) | |
| 1969 | − INIT_HLIST_HEAD(&inode_hashtable[loop]); | |
| 1970 | 1960 | } |
| 1971 | 1961 | |
| 1972 | 1962 | void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) |
| @@ -3239,7 +3239,6 @@ static void __init init_mount_tree(void) · 3238 unmodified lines | ||
| 3239 | 3239 | |
| 3240 | 3240 | void __init mnt_init(void) |
| 3241 | 3241 | { |
| 3242 | − unsigned u; | |
| 3243 | 3242 | int err; |
| 3244 | 3243 | |
| 3245 | 3244 | mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount), |
| @@ -3248,22 +3247,17 @@ void __init mnt_init(void) · 2 unmodified lines | ||
| 3248 | 3247 | mount_hashtable = alloc_large_system_hash("Mount-cache", |
| 3249 | 3248 | sizeof(struct hlist_head), |
| 3250 | 3249 | mhash_entries, 19, |
| 3251 | − 0, | |
| 3250 | + HASH_ZERO, | |
| 3252 | 3251 | &m_hash_shift, &m_hash_mask, 0, 0); |
| 3253 | 3252 | mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache", |
| 3254 | 3253 | sizeof(struct hlist_head), |
| 3255 | 3254 | mphash_entries, 19, |
| 3256 | − 0, | |
| 3255 | + HASH_ZERO, | |
| 3257 | 3256 | &mp_hash_shift, &mp_hash_mask, 0, 0); |
| 3258 | 3257 | |
| 3259 | 3258 | if (!mount_hashtable || !mountpoint_hashtable) |
| 3260 | 3259 | panic("Failed to allocate mount hash table\n"); |
| 3261 | 3260 | |
| 3262 | − for (u = 0; u <= m_hash_mask; u++) | |
| 3263 | − INIT_HLIST_HEAD(&mount_hashtable[u]); | |
| 3264 | − for (u = 0; u <= mp_hash_mask; u++) | |
| 3265 | − INIT_HLIST_HEAD(&mountpoint_hashtable[u]); | |
| 3266 | − | |
| 3267 | 3261 | kernfs_init(); |
| 3268 | 3262 | |
| 3269 | 3263 | err = sysfs_init(); |
| @@ -193,7 +193,8 @@ void __init __pv_init_lock_hash(void) · 192 unmodified lines | ||
| 193 | 193 | */ |
| 194 | 194 | pv_lock_hash = alloc_large_system_hash("PV qspinlock", |
| 195 | 195 | sizeof(struct pv_hash_entry), |
| 196 | − pv_hash_size, 0, HASH_EARLY, | |
| 196 | + pv_hash_size, 0, | |
| 197 | + HASH_EARLY | HASH_ZERO, | |
| 197 | 198 | &pv_lock_hash_bits, NULL, |
| 198 | 199 | pv_hash_size, pv_hash_size); |
| 199 | 200 | } |
| @@ -575,16 +575,13 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) · 574 unmodified lines | ||
| 575 | 575 | */ |
| 576 | 576 | void __init pidhash_init(void) |
| 577 | 577 | { |
| 578 | − unsigned int i, pidhash_size; | |
| 578 | + unsigned int pidhash_size; | |
| 579 | 579 | |
| 580 | 580 | pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18, |
| 581 | − HASH_EARLY | HASH_SMALL, | |
| 581 | + HASH_EARLY | HASH_SMALL | HASH_ZERO, | |
| 582 | 582 | &pidhash_shift, NULL, |
| 583 | 583 | 0, 4096); |
| 584 | 584 | pidhash_size = 1U << pidhash_shift; |
| 585 | − | |
| 586 | − for (i = 0; i < pidhash_size; i++) | |
| 587 | − INIT_HLIST_HEAD(&pid_hash[i]); | |
| 588 | 585 | } |
| 589 | 586 | |
| 590 | 587 | void __init pidmap_init(void) |