Commit 8f35fefa authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Neeraj Upadhyay

refscale: Constify struct ref_scale_ops

'struct ref_scale_ops' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  34231	   4167	    736	  39134	   98de	kernel/rcu/refscale.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  35175	   3239	    736	  39150	   98ee	kernel/rcu/refscale.o
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tested-by: default avatar"Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: default avatarNeeraj Upadhyay <neeraj.upadhyay@kernel.org>
parent f1fd0e0b
...@@ -135,7 +135,7 @@ struct ref_scale_ops { ...@@ -135,7 +135,7 @@ struct ref_scale_ops {
const char *name; const char *name;
}; };
static struct ref_scale_ops *cur_ops; static const struct ref_scale_ops *cur_ops;
static void un_delay(const int udl, const int ndl) static void un_delay(const int udl, const int ndl)
{ {
...@@ -171,7 +171,7 @@ static bool rcu_sync_scale_init(void) ...@@ -171,7 +171,7 @@ static bool rcu_sync_scale_init(void)
return true; return true;
} }
static struct ref_scale_ops rcu_ops = { static const struct ref_scale_ops rcu_ops = {
.init = rcu_sync_scale_init, .init = rcu_sync_scale_init,
.readsection = ref_rcu_read_section, .readsection = ref_rcu_read_section,
.delaysection = ref_rcu_delay_section, .delaysection = ref_rcu_delay_section,
...@@ -205,7 +205,7 @@ static void srcu_ref_scale_delay_section(const int nloops, const int udl, const ...@@ -205,7 +205,7 @@ static void srcu_ref_scale_delay_section(const int nloops, const int udl, const
} }
} }
static struct ref_scale_ops srcu_ops = { static const struct ref_scale_ops srcu_ops = {
.init = rcu_sync_scale_init, .init = rcu_sync_scale_init,
.readsection = srcu_ref_scale_read_section, .readsection = srcu_ref_scale_read_section,
.delaysection = srcu_ref_scale_delay_section, .delaysection = srcu_ref_scale_delay_section,
...@@ -232,7 +232,7 @@ static void rcu_tasks_ref_scale_delay_section(const int nloops, const int udl, c ...@@ -232,7 +232,7 @@ static void rcu_tasks_ref_scale_delay_section(const int nloops, const int udl, c
un_delay(udl, ndl); un_delay(udl, ndl);
} }
static struct ref_scale_ops rcu_tasks_ops = { static const struct ref_scale_ops rcu_tasks_ops = {
.init = rcu_sync_scale_init, .init = rcu_sync_scale_init,
.readsection = rcu_tasks_ref_scale_read_section, .readsection = rcu_tasks_ref_scale_read_section,
.delaysection = rcu_tasks_ref_scale_delay_section, .delaysection = rcu_tasks_ref_scale_delay_section,
...@@ -271,7 +271,7 @@ static void rcu_trace_ref_scale_delay_section(const int nloops, const int udl, c ...@@ -271,7 +271,7 @@ static void rcu_trace_ref_scale_delay_section(const int nloops, const int udl, c
} }
} }
static struct ref_scale_ops rcu_trace_ops = { static const struct ref_scale_ops rcu_trace_ops = {
.init = rcu_sync_scale_init, .init = rcu_sync_scale_init,
.readsection = rcu_trace_ref_scale_read_section, .readsection = rcu_trace_ref_scale_read_section,
.delaysection = rcu_trace_ref_scale_delay_section, .delaysection = rcu_trace_ref_scale_delay_section,
...@@ -310,7 +310,7 @@ static void ref_refcnt_delay_section(const int nloops, const int udl, const int ...@@ -310,7 +310,7 @@ static void ref_refcnt_delay_section(const int nloops, const int udl, const int
} }
} }
static struct ref_scale_ops refcnt_ops = { static const struct ref_scale_ops refcnt_ops = {
.init = rcu_sync_scale_init, .init = rcu_sync_scale_init,
.readsection = ref_refcnt_section, .readsection = ref_refcnt_section,
.delaysection = ref_refcnt_delay_section, .delaysection = ref_refcnt_delay_section,
...@@ -347,7 +347,7 @@ static void ref_rwlock_delay_section(const int nloops, const int udl, const int ...@@ -347,7 +347,7 @@ static void ref_rwlock_delay_section(const int nloops, const int udl, const int
} }
} }
static struct ref_scale_ops rwlock_ops = { static const struct ref_scale_ops rwlock_ops = {
.init = ref_rwlock_init, .init = ref_rwlock_init,
.readsection = ref_rwlock_section, .readsection = ref_rwlock_section,
.delaysection = ref_rwlock_delay_section, .delaysection = ref_rwlock_delay_section,
...@@ -384,7 +384,7 @@ static void ref_rwsem_delay_section(const int nloops, const int udl, const int n ...@@ -384,7 +384,7 @@ static void ref_rwsem_delay_section(const int nloops, const int udl, const int n
} }
} }
static struct ref_scale_ops rwsem_ops = { static const struct ref_scale_ops rwsem_ops = {
.init = ref_rwsem_init, .init = ref_rwsem_init,
.readsection = ref_rwsem_section, .readsection = ref_rwsem_section,
.delaysection = ref_rwsem_delay_section, .delaysection = ref_rwsem_delay_section,
...@@ -419,7 +419,7 @@ static void ref_lock_delay_section(const int nloops, const int udl, const int nd ...@@ -419,7 +419,7 @@ static void ref_lock_delay_section(const int nloops, const int udl, const int nd
preempt_enable(); preempt_enable();
} }
static struct ref_scale_ops lock_ops = { static const struct ref_scale_ops lock_ops = {
.readsection = ref_lock_section, .readsection = ref_lock_section,
.delaysection = ref_lock_delay_section, .delaysection = ref_lock_delay_section,
.name = "lock" .name = "lock"
...@@ -454,7 +454,7 @@ static void ref_lock_irq_delay_section(const int nloops, const int udl, const in ...@@ -454,7 +454,7 @@ static void ref_lock_irq_delay_section(const int nloops, const int udl, const in
preempt_enable(); preempt_enable();
} }
static struct ref_scale_ops lock_irq_ops = { static const struct ref_scale_ops lock_irq_ops = {
.readsection = ref_lock_irq_section, .readsection = ref_lock_irq_section,
.delaysection = ref_lock_irq_delay_section, .delaysection = ref_lock_irq_delay_section,
.name = "lock-irq" .name = "lock-irq"
...@@ -490,7 +490,7 @@ static void ref_acqrel_delay_section(const int nloops, const int udl, const int ...@@ -490,7 +490,7 @@ static void ref_acqrel_delay_section(const int nloops, const int udl, const int
preempt_enable(); preempt_enable();
} }
static struct ref_scale_ops acqrel_ops = { static const struct ref_scale_ops acqrel_ops = {
.readsection = ref_acqrel_section, .readsection = ref_acqrel_section,
.delaysection = ref_acqrel_delay_section, .delaysection = ref_acqrel_delay_section,
.name = "acqrel" .name = "acqrel"
...@@ -524,7 +524,7 @@ static void ref_clock_delay_section(const int nloops, const int udl, const int n ...@@ -524,7 +524,7 @@ static void ref_clock_delay_section(const int nloops, const int udl, const int n
stopopts = x; stopopts = x;
} }
static struct ref_scale_ops clock_ops = { static const struct ref_scale_ops clock_ops = {
.readsection = ref_clock_section, .readsection = ref_clock_section,
.delaysection = ref_clock_delay_section, .delaysection = ref_clock_delay_section,
.name = "clock" .name = "clock"
...@@ -556,7 +556,7 @@ static void ref_jiffies_delay_section(const int nloops, const int udl, const int ...@@ -556,7 +556,7 @@ static void ref_jiffies_delay_section(const int nloops, const int udl, const int
stopopts = x; stopopts = x;
} }
static struct ref_scale_ops jiffies_ops = { static const struct ref_scale_ops jiffies_ops = {
.readsection = ref_jiffies_section, .readsection = ref_jiffies_section,
.delaysection = ref_jiffies_delay_section, .delaysection = ref_jiffies_delay_section,
.name = "jiffies" .name = "jiffies"
...@@ -706,9 +706,9 @@ static void refscale_typesafe_ctor(void *rtsp_in) ...@@ -706,9 +706,9 @@ static void refscale_typesafe_ctor(void *rtsp_in)
preempt_enable(); preempt_enable();
} }
static struct ref_scale_ops typesafe_ref_ops; static const struct ref_scale_ops typesafe_ref_ops;
static struct ref_scale_ops typesafe_lock_ops; static const struct ref_scale_ops typesafe_lock_ops;
static struct ref_scale_ops typesafe_seqlock_ops; static const struct ref_scale_ops typesafe_seqlock_ops;
// Initialize for a typesafe test. // Initialize for a typesafe test.
static bool typesafe_init(void) static bool typesafe_init(void)
...@@ -769,7 +769,7 @@ static void typesafe_cleanup(void) ...@@ -769,7 +769,7 @@ static void typesafe_cleanup(void)
} }
// The typesafe_init() function distinguishes these structures by address. // The typesafe_init() function distinguishes these structures by address.
static struct ref_scale_ops typesafe_ref_ops = { static const struct ref_scale_ops typesafe_ref_ops = {
.init = typesafe_init, .init = typesafe_init,
.cleanup = typesafe_cleanup, .cleanup = typesafe_cleanup,
.readsection = typesafe_read_section, .readsection = typesafe_read_section,
...@@ -777,7 +777,7 @@ static struct ref_scale_ops typesafe_ref_ops = { ...@@ -777,7 +777,7 @@ static struct ref_scale_ops typesafe_ref_ops = {
.name = "typesafe_ref" .name = "typesafe_ref"
}; };
static struct ref_scale_ops typesafe_lock_ops = { static const struct ref_scale_ops typesafe_lock_ops = {
.init = typesafe_init, .init = typesafe_init,
.cleanup = typesafe_cleanup, .cleanup = typesafe_cleanup,
.readsection = typesafe_read_section, .readsection = typesafe_read_section,
...@@ -785,7 +785,7 @@ static struct ref_scale_ops typesafe_lock_ops = { ...@@ -785,7 +785,7 @@ static struct ref_scale_ops typesafe_lock_ops = {
.name = "typesafe_lock" .name = "typesafe_lock"
}; };
static struct ref_scale_ops typesafe_seqlock_ops = { static const struct ref_scale_ops typesafe_seqlock_ops = {
.init = typesafe_init, .init = typesafe_init,
.cleanup = typesafe_cleanup, .cleanup = typesafe_cleanup,
.readsection = typesafe_read_section, .readsection = typesafe_read_section,
...@@ -1026,7 +1026,7 @@ static int main_func(void *arg) ...@@ -1026,7 +1026,7 @@ static int main_func(void *arg)
} }
static void static void
ref_scale_print_module_parms(struct ref_scale_ops *cur_ops, const char *tag) ref_scale_print_module_parms(const struct ref_scale_ops *cur_ops, const char *tag)
{ {
pr_alert("%s" SCALE_FLAG pr_alert("%s" SCALE_FLAG
"--- %s: verbose=%d verbose_batched=%d shutdown=%d holdoff=%d lookup_instances=%ld loops=%ld nreaders=%d nruns=%d readdelay=%d\n", scale_type, tag, "--- %s: verbose=%d verbose_batched=%d shutdown=%d holdoff=%d lookup_instances=%ld loops=%ld nreaders=%d nruns=%d readdelay=%d\n", scale_type, tag,
...@@ -1081,7 +1081,7 @@ ref_scale_init(void) ...@@ -1081,7 +1081,7 @@ ref_scale_init(void)
{ {
long i; long i;
int firsterr = 0; int firsterr = 0;
static struct ref_scale_ops *scale_ops[] = { static const struct ref_scale_ops *scale_ops[] = {
&rcu_ops, &srcu_ops, RCU_TRACE_OPS RCU_TASKS_OPS &refcnt_ops, &rwlock_ops, &rcu_ops, &srcu_ops, RCU_TRACE_OPS RCU_TASKS_OPS &refcnt_ops, &rwlock_ops,
&rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops, &jiffies_ops, &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops, &jiffies_ops,
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops, &typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment