History

mm: update callers to use HASH_ZERO flag

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

Pavel Tatashin committed 9 years ago

Commit 3d375d71 parent 3749a8f5 files · +12 −40Browse files

Unified · Split

5 files
  1. fs/dcache.c +4 −14
  2. fs/inode.c +2 −12
  3. fs/namespace.c +2 −8
  4. kernel/locking/qspinlock_paravirt.h +2 −1
  5. kernel/pid.c +2 −5
fs/dcache.c+4−14
@@ -3546,8 +3546,6 @@ __setup("dhash_entries=", set_dhash_entries); · 3545 unmodified lines
3546 3546
3547static void __init dcache_init_early(void)3547static void __init dcache_init_early(void)
3548{3548{
3549 unsigned int loop;
3550
3551 /* If hashes are distributed across NUMA nodes, defer3549 /* If hashes are distributed across NUMA nodes, defer
3552 * hash allocation until vmalloc space is available.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 sizeof(struct hlist_bl_head),3557 sizeof(struct hlist_bl_head),
3560 dhash_entries,3558 dhash_entries,
3561 13,3559 13,
3562 HASH_EARLY,3560 HASH_EARLY | HASH_ZERO,
3563 &d_hash_shift,3561 &d_hash_shift,
3564 &d_hash_mask,3562 &d_hash_mask,
3565 0,3563 0,
3566 0);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
3572static void __init dcache_init(void)3567static void __init dcache_init(void)
3573{3568{
3574 unsigned int loop;3569 /*
3575
3576 /*
3577 * A constructor could be added for stable state like the lists,3570 * A constructor could be added for stable state like the lists,
3578 * but it is probably not worth it because of the cache nature3571 * but it is probably not worth it because of the cache nature
3579 * of the dcache. 3572 * of the dcache.
3580 */3573 */
3581 dentry_cache = KMEM_CACHE(dentry,3574 dentry_cache = KMEM_CACHE(dentry,
3582 SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD|SLAB_ACCOUNT);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 sizeof(struct hlist_bl_head),3583 sizeof(struct hlist_bl_head),
3591 dhash_entries,3584 dhash_entries,
3592 13,3585 13,
3593 0,3586 HASH_ZERO,
3594 &d_hash_shift,3587 &d_hash_shift,
3595 &d_hash_mask,3588 &d_hash_mask,
3596 0,3589 0,
3597 0);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/* SLAB cache for __getname() consumers */3593/* SLAB cache for __getname() consumers */
fs/inode.c+2−12
@@ -1915,8 +1915,6 @@ __setup("ihash_entries=", set_ihash_entries); · 1914 unmodified lines
1915 */1915 */
1916void __init inode_init_early(void)1916void __init inode_init_early(void)
1917{1917{
1918 unsigned int loop;
1919
1920 /* If hashes are distributed across NUMA nodes, defer1918 /* If hashes are distributed across NUMA nodes, defer
1921 * hash allocation until vmalloc space is available.1919 * hash allocation until vmalloc space is available.
1922 */1920 */
@@ -1928,20 +1926,15 @@ void __init inode_init_early(void) · 5 unmodified lines
1928 sizeof(struct hlist_head),1926 sizeof(struct hlist_head),
1929 ihash_entries,1927 ihash_entries,
1930 14,1928 14,
1931 HASH_EARLY,1929 HASH_EARLY | HASH_ZERO,
1932 &i_hash_shift,1930 &i_hash_shift,
1933 &i_hash_mask,1931 &i_hash_mask,
1934 0,1932 0,
1935 0);1933 0);
1936
1937 for (loop = 0; loop < (1U << i_hash_shift); loop++)
1938 INIT_HLIST_HEAD(&inode_hashtable[loop]);
1939}1934}
1940 1935
1941void __init inode_init(void)1936void __init inode_init(void)
1942{1937{
1943 unsigned int loop;
1944
1945 /* inode slab cache */1938 /* inode slab cache */
1946 inode_cachep = kmem_cache_create("inode_cache",1939 inode_cachep = kmem_cache_create("inode_cache",
1947 sizeof(struct inode),1940 sizeof(struct inode),
@@ -1959,14 +1952,11 @@ void __init inode_init(void) · 11 unmodified lines
1959 sizeof(struct hlist_head),1952 sizeof(struct hlist_head),
1960 ihash_entries,1953 ihash_entries,
1961 14,1954 14,
1962 0,1955 HASH_ZERO,
1963 &i_hash_shift,1956 &i_hash_shift,
1964 &i_hash_mask,1957 &i_hash_mask,
1965 0,1958 0,
1966 0);1959 0);
1967
1968 for (loop = 0; loop < (1U << i_hash_shift); loop++)
1969 INIT_HLIST_HEAD(&inode_hashtable[loop]);
1970}1960}
1971 1961
1972void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)1962void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
fs/namespace.c+2−8
@@ -3239,7 +3239,6 @@ static void __init init_mount_tree(void) · 3238 unmodified lines
3239 3239
3240void __init mnt_init(void)3240void __init mnt_init(void)
3241{3241{
3242 unsigned u;
3243 int err;3242 int err;
3244 3243
3245 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),3244 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
@@ -3248,22 +3247,17 @@ void __init mnt_init(void) · 2 unmodified lines
3248 mount_hashtable = alloc_large_system_hash("Mount-cache",3247 mount_hashtable = alloc_large_system_hash("Mount-cache",
3249 sizeof(struct hlist_head),3248 sizeof(struct hlist_head),
3250 mhash_entries, 19,3249 mhash_entries, 19,
3251 0,3250 HASH_ZERO,
3252 &m_hash_shift, &m_hash_mask, 0, 0);3251 &m_hash_shift, &m_hash_mask, 0, 0);
3253 mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",3252 mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
3254 sizeof(struct hlist_head),3253 sizeof(struct hlist_head),
3255 mphash_entries, 19,3254 mphash_entries, 19,
3256 0,3255 HASH_ZERO,
3257 &mp_hash_shift, &mp_hash_mask, 0, 0);3256 &mp_hash_shift, &mp_hash_mask, 0, 0);
3258 3257
3259 if (!mount_hashtable || !mountpoint_hashtable)3258 if (!mount_hashtable || !mountpoint_hashtable)
3260 panic("Failed to allocate mount hash table\n");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 kernfs_init();3261 kernfs_init();
3268 3262
3269 err = sysfs_init();3263 err = sysfs_init();
kernel/locking/qspinlock_paravirt.h+2−1
@@ -193,7 +193,8 @@ void __init __pv_init_lock_hash(void) · 192 unmodified lines
193 */193 */
194 pv_lock_hash = alloc_large_system_hash("PV qspinlock",194 pv_lock_hash = alloc_large_system_hash("PV qspinlock",
195 sizeof(struct pv_hash_entry),195 sizeof(struct pv_hash_entry),
196 pv_hash_size, 0, HASH_EARLY,196 pv_hash_size, 0,
197 HASH_EARLY | HASH_ZERO,
197 &pv_lock_hash_bits, NULL,198 &pv_lock_hash_bits, NULL,
198 pv_hash_size, pv_hash_size);199 pv_hash_size, pv_hash_size);
199}200}
kernel/pid.c+2−5
@@ -575,16 +575,13 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) · 574 unmodified lines
575 */575 */
576void __init pidhash_init(void)576void __init pidhash_init(void)
577{577{
578 unsigned int i, pidhash_size;578 unsigned int pidhash_size;
579 579
580 pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,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 &pidhash_shift, NULL,582 &pidhash_shift, NULL,
583 0, 4096);583 0, 4096);
584 pidhash_size = 1U << pidhash_shift;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
590void __init pidmap_init(void)587void __init pidmap_init(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t