Skip to content

Commit 68279f9

Browse files
Alexey Dobriyanakpm00
authored andcommitted
treewide: mark stuff as __ro_after_init
__read_mostly predates __ro_after_init. Many variables which are marked __read_mostly should have been __ro_after_init from day 1. Also, mark some stuff as "const" and "__init" while I'm at it. [[email protected]: revert sysctl_nr_open_min, sysctl_nr_open_max changes due to arm warning] [[email protected]: coding-style cleanups] Link: https://lkml.kernel.org/r/4f6bb9c0-abba-4ee4-a7aa-89265e886817@p183 Signed-off-by: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1b13a70 commit 68279f9

26 files changed

+64
-63
lines changed

block/bdev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ EXPORT_SYMBOL(thaw_bdev);
292292
*/
293293

294294
static __cacheline_aligned_in_smp DEFINE_MUTEX(bdev_lock);
295-
static struct kmem_cache * bdev_cachep __read_mostly;
295+
static struct kmem_cache *bdev_cachep __ro_after_init;
296296

297297
static struct inode *bdev_alloc_inode(struct super_block *sb)
298298
{
@@ -361,13 +361,13 @@ static struct file_system_type bd_type = {
361361
.kill_sb = kill_anon_super,
362362
};
363363

364-
struct super_block *blockdev_superblock __read_mostly;
364+
struct super_block *blockdev_superblock __ro_after_init;
365365
EXPORT_SYMBOL_GPL(blockdev_superblock);
366366

367367
void __init bdev_cache_init(void)
368368
{
369369
int err;
370-
static struct vfsmount *bd_mnt;
370+
static struct vfsmount *bd_mnt __ro_after_init;
371371

372372
bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
373373
0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|

fs/anon_inodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
#include <linux/uaccess.h>
2626

27-
static struct vfsmount *anon_inode_mnt __read_mostly;
28-
static struct inode *anon_inode_inode;
27+
static struct vfsmount *anon_inode_mnt __ro_after_init;
28+
static struct inode *anon_inode_inode __ro_after_init;
2929

3030
/*
3131
* anon_inodefs_dname() is called from d_path().

fs/buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,13 +2988,13 @@ EXPORT_SYMBOL(try_to_free_buffers);
29882988
/*
29892989
* Buffer-head allocation
29902990
*/
2991-
static struct kmem_cache *bh_cachep __read_mostly;
2991+
static struct kmem_cache *bh_cachep __ro_after_init;
29922992

29932993
/*
29942994
* Once the number of bh's in the machine exceeds this level, we start
29952995
* stripping them in writeback.
29962996
*/
2997-
static unsigned long max_buffer_heads;
2997+
static unsigned long max_buffer_heads __ro_after_init;
29982998

29992999
int buffer_heads_over_limit;
30003000

fs/char_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "internal.h"
2727

28-
static struct kobj_map *cdev_map;
28+
static struct kobj_map *cdev_map __ro_after_init;
2929

3030
static DEFINE_MUTEX(chrdevs_lock);
3131

fs/dcache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
7878

7979
EXPORT_SYMBOL(rename_lock);
8080

81-
static struct kmem_cache *dentry_cache __read_mostly;
81+
static struct kmem_cache *dentry_cache __ro_after_init;
8282

8383
const struct qstr empty_name = QSTR_INIT("", 0);
8484
EXPORT_SYMBOL(empty_name);
@@ -96,9 +96,9 @@ EXPORT_SYMBOL(dotdot_name);
9696
* information, yet avoid using a prime hash-size or similar.
9797
*/
9898

99-
static unsigned int d_hash_shift __read_mostly;
99+
static unsigned int d_hash_shift __ro_after_init;
100100

101-
static struct hlist_bl_head *dentry_hashtable __read_mostly;
101+
static struct hlist_bl_head *dentry_hashtable __ro_after_init;
102102

103103
static inline struct hlist_bl_head *d_hash(unsigned int hash)
104104
{
@@ -3324,7 +3324,7 @@ static void __init dcache_init(void)
33243324
}
33253325

33263326
/* SLAB cache for __getname() consumers */
3327-
struct kmem_cache *names_cachep __read_mostly;
3327+
struct kmem_cache *names_cachep __ro_after_init;
33283328
EXPORT_SYMBOL(names_cachep);
33293329

33303330
void __init vfs_caches_init_early(void)

fs/direct-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct dio {
151151
};
152152
} ____cacheline_aligned_in_smp;
153153

154-
static struct kmem_cache *dio_cache __read_mostly;
154+
static struct kmem_cache *dio_cache __ro_after_init;
155155

156156
/*
157157
* How many pages are in the queue?

fs/eventpoll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ static u64 loop_check_gen = 0;
256256
static struct eventpoll *inserting_into;
257257

258258
/* Slab cache used to allocate "struct epitem" */
259-
static struct kmem_cache *epi_cache __read_mostly;
259+
static struct kmem_cache *epi_cache __ro_after_init;
260260

261261
/* Slab cache used to allocate "struct eppoll_entry" */
262-
static struct kmem_cache *pwq_cache __read_mostly;
262+
static struct kmem_cache *pwq_cache __ro_after_init;
263263

264264
/*
265265
* List of files with newly added links, where we may need to limit the number
@@ -271,7 +271,7 @@ struct epitems_head {
271271
};
272272
static struct epitems_head *tfile_check_list = EP_UNACTIVE_PTR;
273273

274-
static struct kmem_cache *ephead_cache __read_mostly;
274+
static struct kmem_cache *ephead_cache __ro_after_init;
275275

276276
static inline void free_ephead(struct epitems_head *head)
277277
{

fs/fcntl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ int send_sigurg(struct fown_struct *fown)
844844
}
845845

846846
static DEFINE_SPINLOCK(fasync_lock);
847-
static struct kmem_cache *fasync_cache __read_mostly;
847+
static struct kmem_cache *fasync_cache __ro_after_init;
848848

849849
static void fasync_free_rcu(struct rcu_head *head)
850850
{

fs/file_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static struct files_stat_struct files_stat = {
4040
};
4141

4242
/* SLAB cache for file structures */
43-
static struct kmem_cache *filp_cachep __read_mostly;
43+
static struct kmem_cache *filp_cachep __ro_after_init;
4444

4545
static struct percpu_counter nr_files __cacheline_aligned_in_smp;
4646

fs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
* inode_hash_lock
5555
*/
5656

57-
static unsigned int i_hash_mask __read_mostly;
58-
static unsigned int i_hash_shift __read_mostly;
59-
static struct hlist_head *inode_hashtable __read_mostly;
57+
static unsigned int i_hash_mask __ro_after_init;
58+
static unsigned int i_hash_shift __ro_after_init;
59+
static struct hlist_head *inode_hashtable __ro_after_init;
6060
static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock);
6161

6262
/*
@@ -70,7 +70,7 @@ EXPORT_SYMBOL(empty_aops);
7070
static DEFINE_PER_CPU(unsigned long, nr_inodes);
7171
static DEFINE_PER_CPU(unsigned long, nr_unused);
7272

73-
static struct kmem_cache *inode_cachep __read_mostly;
73+
static struct kmem_cache *inode_cachep __ro_after_init;
7474

7575
static long get_nr_inodes(void)
7676
{

0 commit comments

Comments
 (0)