Skip to content

Commit 3d375d7

Browse files
Pavel Tatashintorvalds
authored andcommitted
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 Link: http://lkml.kernel.org/r/1488432825-92126-4-git-send-email-pasha.tatashin@oracle.com Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Reviewed-by: Babu Moger <babu.moger@oracle.com> Cc: David Miller <davem@davemloft.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3749a8f commit 3d375d7

File tree

5 files changed

+12
-40
lines changed

5 files changed

+12
-40
lines changed

fs/dcache.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,8 +3546,6 @@ __setup("dhash_entries=", set_dhash_entries);
35463546

35473547
static void __init dcache_init_early(void)
35483548
{
3549-
unsigned int loop;
3550-
35513549
/* If hashes are distributed across NUMA nodes, defer
35523550
* hash allocation until vmalloc space is available.
35533551
*/
@@ -3559,24 +3557,19 @@ static void __init dcache_init_early(void)
35593557
sizeof(struct hlist_bl_head),
35603558
dhash_entries,
35613559
13,
3562-
HASH_EARLY,
3560+
HASH_EARLY | HASH_ZERO,
35633561
&d_hash_shift,
35643562
&d_hash_mask,
35653563
0,
35663564
0);
3567-
3568-
for (loop = 0; loop < (1U << d_hash_shift); loop++)
3569-
INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
35703565
}
35713566

35723567
static void __init dcache_init(void)
35733568
{
3574-
unsigned int loop;
3575-
3576-
/*
3569+
/*
35773570
* A constructor could be added for stable state like the lists,
35783571
* but it is probably not worth it because of the cache nature
3579-
* of the dcache.
3572+
* of the dcache.
35803573
*/
35813574
dentry_cache = KMEM_CACHE(dentry,
35823575
SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD|SLAB_ACCOUNT);
@@ -3590,14 +3583,11 @@ static void __init dcache_init(void)
35903583
sizeof(struct hlist_bl_head),
35913584
dhash_entries,
35923585
13,
3593-
0,
3586+
HASH_ZERO,
35943587
&d_hash_shift,
35953588
&d_hash_mask,
35963589
0,
35973590
0);
3598-
3599-
for (loop = 0; loop < (1U << d_hash_shift); loop++)
3600-
INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
36013591
}
36023592

36033593
/* SLAB cache for __getname() consumers */

fs/inode.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,8 +1915,6 @@ __setup("ihash_entries=", set_ihash_entries);
19151915
*/
19161916
void __init inode_init_early(void)
19171917
{
1918-
unsigned int loop;
1919-
19201918
/* If hashes are distributed across NUMA nodes, defer
19211919
* hash allocation until vmalloc space is available.
19221920
*/
@@ -1928,20 +1926,15 @@ void __init inode_init_early(void)
19281926
sizeof(struct hlist_head),
19291927
ihash_entries,
19301928
14,
1931-
HASH_EARLY,
1929+
HASH_EARLY | HASH_ZERO,
19321930
&i_hash_shift,
19331931
&i_hash_mask,
19341932
0,
19351933
0);
1936-
1937-
for (loop = 0; loop < (1U << i_hash_shift); loop++)
1938-
INIT_HLIST_HEAD(&inode_hashtable[loop]);
19391934
}
19401935

19411936
void __init inode_init(void)
19421937
{
1943-
unsigned int loop;
1944-
19451938
/* inode slab cache */
19461939
inode_cachep = kmem_cache_create("inode_cache",
19471940
sizeof(struct inode),
@@ -1959,14 +1952,11 @@ void __init inode_init(void)
19591952
sizeof(struct hlist_head),
19601953
ihash_entries,
19611954
14,
1962-
0,
1955+
HASH_ZERO,
19631956
&i_hash_shift,
19641957
&i_hash_mask,
19651958
0,
19661959
0);
1967-
1968-
for (loop = 0; loop < (1U << i_hash_shift); loop++)
1969-
INIT_HLIST_HEAD(&inode_hashtable[loop]);
19701960
}
19711961

19721962
void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)

fs/namespace.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,6 @@ static void __init init_mount_tree(void)
32393239

32403240
void __init mnt_init(void)
32413241
{
3242-
unsigned u;
32433242
int err;
32443243

32453244
mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
@@ -3248,22 +3247,17 @@ void __init mnt_init(void)
32483247
mount_hashtable = alloc_large_system_hash("Mount-cache",
32493248
sizeof(struct hlist_head),
32503249
mhash_entries, 19,
3251-
0,
3250+
HASH_ZERO,
32523251
&m_hash_shift, &m_hash_mask, 0, 0);
32533252
mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
32543253
sizeof(struct hlist_head),
32553254
mphash_entries, 19,
3256-
0,
3255+
HASH_ZERO,
32573256
&mp_hash_shift, &mp_hash_mask, 0, 0);
32583257

32593258
if (!mount_hashtable || !mountpoint_hashtable)
32603259
panic("Failed to allocate mount hash table\n");
32613260

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-
32673261
kernfs_init();
32683262

32693263
err = sysfs_init();

kernel/locking/qspinlock_paravirt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ void __init __pv_init_lock_hash(void)
193193
*/
194194
pv_lock_hash = alloc_large_system_hash("PV qspinlock",
195195
sizeof(struct pv_hash_entry),
196-
pv_hash_size, 0, HASH_EARLY,
196+
pv_hash_size, 0,
197+
HASH_EARLY | HASH_ZERO,
197198
&pv_lock_hash_bits, NULL,
198199
pv_hash_size, pv_hash_size);
199200
}

kernel/pid.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,16 +575,13 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns)
575575
*/
576576
void __init pidhash_init(void)
577577
{
578-
unsigned int i, pidhash_size;
578+
unsigned int pidhash_size;
579579

580580
pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,
581-
HASH_EARLY | HASH_SMALL,
581+
HASH_EARLY | HASH_SMALL | HASH_ZERO,
582582
&pidhash_shift, NULL,
583583
0, 4096);
584584
pidhash_size = 1U << pidhash_shift;
585-
586-
for (i = 0; i < pidhash_size; i++)
587-
INIT_HLIST_HEAD(&pid_hash[i]);
588585
}
589586

590587
void __init pidmap_init(void)

0 commit comments

Comments
 (0)