Limit hashtables to a reasonable size on large systems.

Signed-off-by: Daniel J Blueman <daniel@numascale.com>

diff --git a/fs/dcache.c b/fs/dcache.c
index e368d4f..d3da3b4 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3259,7 +3259,7 @@ static void __init dcache_init_early(void)
 					&d_hash_shift,
 					&d_hash_mask,
 					0,
-					0);
+					2097152);
 
 	for (loop = 0; loop < (1U << d_hash_shift); loop++)
 		INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
@@ -3290,7 +3290,7 @@ static void __init dcache_init(void)
 					&d_hash_shift,
 					&d_hash_mask,
 					0,
-					0);
+					2097152);
 
 	for (loop = 0; loop < (1U << d_hash_shift); loop++)
 		INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
diff --git a/fs/inode.c b/fs/inode.c
index aa149e7..85b9b3d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1754,7 +1754,7 @@ void __init inode_init_early(void)
 					&i_hash_shift,
 					&i_hash_mask,
 					0,
-					0);
+					1048576);
 
 	for (loop = 0; loop < (1U << i_hash_shift); loop++)
 		INIT_HLIST_HEAD(&inode_hashtable[loop]);
@@ -1785,7 +1785,7 @@ void __init inode_init(void)
 					&i_hash_shift,
 					&i_hash_mask,
 					0,
-					0);
+					1048576);
 
 	for (loop = 0; loop < (1U << i_hash_shift); loop++)
 		INIT_HLIST_HEAD(&inode_hashtable[loop]);
diff --git a/fs/namespace.c b/fs/namespace.c
index cd1e968..a160bf3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3033,12 +3033,12 @@ void __init mnt_init(void)
 				sizeof(struct hlist_head),
 				mhash_entries, 19,
 				0,
-				&m_hash_shift, &m_hash_mask, 0, 0);
+				&m_hash_shift, &m_hash_mask, 0, 32768);
 	mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
 				sizeof(struct hlist_head),
 				mphash_entries, 19,
 				0,
-				&mp_hash_shift, &mp_hash_mask, 0, 0);
+				&mp_hash_shift, &mp_hash_mask, 0, 32768);
 
 	if (!mount_hashtable || !mountpoint_hashtable)
 		panic("Failed to allocate mount hash table\n");
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3075723..292155e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3054,7 +3054,7 @@ void __init tcp_init(void)
 					NULL,
 					&tcp_hashinfo.ehash_mask,
 					0,
-					thash_entries ? 0 : 512 * 1024);
+					131072);
 	for (i = 0; i <= tcp_hashinfo.ehash_mask; i++)
 		INIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 13b4dcf..6a85226 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2510,7 +2510,7 @@ void __init udp_table_init(struct udp_table *table, const char *name)
 					      &table->log,
 					      &table->mask,
 					      UDP_HTABLE_SIZE_MIN,
-					      64 * 1024);
+					      8192);
 
 	table->hash2 = table->hash + (table->mask + 1);
 	for (i = 0; i <= table->mask; i++) {
