rcu: Add const annotation to char * for RCU tracepoints and functions
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Fri, 12 Jul 2013 20:50:28 +0000 (16:50 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 29 Jul 2013 21:07:49 +0000 (17:07 -0400)
All the RCU tracepoints and functions that reference char pointers do
so with just 'char *' even though they do not modify the contents of
the string itself. This will cause warnings if a const char * is used
in one of these functions.

The RCU tracepoints store the pointer to the string to refer back to them
when the trace output is displayed. As this can be minutes, hours or
even days later, those strings had better be constant.

This change also opens the door to allow the RCU tracepoint strings and
their addresses to be exported so that userspace tracing tools can
translate the contents of the pointers of the RCU tracepoints.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/rcupdate.h
include/trace/events/rcu.h
kernel/rcu.h
kernel/rcupdate.c
kernel/rcutiny.c
kernel/rcutiny_plugin.h
kernel/rcutorture.c
kernel/rcutree.c
kernel/rcutree.h

index 4b14bdc911d7854163932672ad376ab615de7be4..0c38abbe6e35242ab2d867aad34b27adaa073785 100644 (file)
@@ -52,7 +52,7 @@ extern int rcutorture_runnable; /* for sysctl */
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
 extern void rcutorture_record_test_transition(void);
 extern void rcutorture_record_progress(unsigned long vernum);
-extern void do_trace_rcu_torture_read(char *rcutorturename,
+extern void do_trace_rcu_torture_read(const char *rcutorturename,
                                      struct rcu_head *rhp,
                                      unsigned long secs,
                                      unsigned long c_old,
@@ -65,7 +65,7 @@ static inline void rcutorture_record_progress(unsigned long vernum)
 {
 }
 #ifdef CONFIG_RCU_TRACE
-extern void do_trace_rcu_torture_read(char *rcutorturename,
+extern void do_trace_rcu_torture_read(const char *rcutorturename,
                                      struct rcu_head *rhp,
                                      unsigned long secs,
                                      unsigned long c_old,
index 59ebcc89f148ba85789581cda7f233ab2374ed92..ee2376cfaab3a668d01374844c6757d07e7e1be8 100644 (file)
  */
 TRACE_EVENT(rcu_utilization,
 
-       TP_PROTO(char *s),
+       TP_PROTO(const char *s),
 
        TP_ARGS(s),
 
        TP_STRUCT__entry(
-               __field(char *, s)
+               __field(const char *, s)
        ),
 
        TP_fast_assign(
@@ -51,14 +51,14 @@ TRACE_EVENT(rcu_utilization,
  */
 TRACE_EVENT(rcu_grace_period,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum, char *gpevent),
+       TP_PROTO(const char *rcuname, unsigned long gpnum, const char *gpevent),
 
        TP_ARGS(rcuname, gpnum, gpevent),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
-               __field(char *, gpevent)
+               __field(const char *, gpevent)
        ),
 
        TP_fast_assign(
@@ -89,21 +89,21 @@ TRACE_EVENT(rcu_grace_period,
  */
 TRACE_EVENT(rcu_future_grace_period,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum, unsigned long completed,
+       TP_PROTO(const char *rcuname, unsigned long gpnum, unsigned long completed,
                 unsigned long c, u8 level, int grplo, int grphi,
-                char *gpevent),
+                const char *gpevent),
 
        TP_ARGS(rcuname, gpnum, completed, c, level, grplo, grphi, gpevent),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(unsigned long, completed)
                __field(unsigned long, c)
                __field(u8, level)
                __field(int, grplo)
                __field(int, grphi)
-               __field(char *, gpevent)
+               __field(const char *, gpevent)
        ),
 
        TP_fast_assign(
@@ -132,13 +132,13 @@ TRACE_EVENT(rcu_future_grace_period,
  */
 TRACE_EVENT(rcu_grace_period_init,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum, u8 level,
+       TP_PROTO(const char *rcuname, unsigned long gpnum, u8 level,
                 int grplo, int grphi, unsigned long qsmask),
 
        TP_ARGS(rcuname, gpnum, level, grplo, grphi, qsmask),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(u8, level)
                __field(int, grplo)
@@ -168,12 +168,12 @@ TRACE_EVENT(rcu_grace_period_init,
  */
 TRACE_EVENT(rcu_preempt_task,
 
-       TP_PROTO(char *rcuname, int pid, unsigned long gpnum),
+       TP_PROTO(const char *rcuname, int pid, unsigned long gpnum),
 
        TP_ARGS(rcuname, pid, gpnum),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(int, pid)
        ),
@@ -195,12 +195,12 @@ TRACE_EVENT(rcu_preempt_task,
  */
 TRACE_EVENT(rcu_unlock_preempted_task,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum, int pid),
+       TP_PROTO(const char *rcuname, unsigned long gpnum, int pid),
 
        TP_ARGS(rcuname, gpnum, pid),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(int, pid)
        ),
@@ -224,14 +224,14 @@ TRACE_EVENT(rcu_unlock_preempted_task,
  */
 TRACE_EVENT(rcu_quiescent_state_report,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum,
+       TP_PROTO(const char *rcuname, unsigned long gpnum,
                 unsigned long mask, unsigned long qsmask,
                 u8 level, int grplo, int grphi, int gp_tasks),
 
        TP_ARGS(rcuname, gpnum, mask, qsmask, level, grplo, grphi, gp_tasks),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(unsigned long, mask)
                __field(unsigned long, qsmask)
@@ -268,15 +268,15 @@ TRACE_EVENT(rcu_quiescent_state_report,
  */
 TRACE_EVENT(rcu_fqs,
 
-       TP_PROTO(char *rcuname, unsigned long gpnum, int cpu, char *qsevent),
+       TP_PROTO(const char *rcuname, unsigned long gpnum, int cpu, const char *qsevent),
 
        TP_ARGS(rcuname, gpnum, cpu, qsevent),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(unsigned long, gpnum)
                __field(int, cpu)
-               __field(char *, qsevent)
+               __field(const char *, qsevent)
        ),
 
        TP_fast_assign(
@@ -308,12 +308,12 @@ TRACE_EVENT(rcu_fqs,
  */
 TRACE_EVENT(rcu_dyntick,
 
-       TP_PROTO(char *polarity, long long oldnesting, long long newnesting),
+       TP_PROTO(const char *polarity, long long oldnesting, long long newnesting),
 
        TP_ARGS(polarity, oldnesting, newnesting),
 
        TP_STRUCT__entry(
-               __field(char *, polarity)
+               __field(const char *, polarity)
                __field(long long, oldnesting)
                __field(long long, newnesting)
        ),
@@ -352,12 +352,12 @@ TRACE_EVENT(rcu_dyntick,
  */
 TRACE_EVENT(rcu_prep_idle,
 
-       TP_PROTO(char *reason),
+       TP_PROTO(const char *reason),
 
        TP_ARGS(reason),
 
        TP_STRUCT__entry(
-               __field(char *, reason)
+               __field(const char *, reason)
        ),
 
        TP_fast_assign(
@@ -376,13 +376,13 @@ TRACE_EVENT(rcu_prep_idle,
  */
 TRACE_EVENT(rcu_callback,
 
-       TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen_lazy,
+       TP_PROTO(const char *rcuname, struct rcu_head *rhp, long qlen_lazy,
                 long qlen),
 
        TP_ARGS(rcuname, rhp, qlen_lazy, qlen),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(void *, rhp)
                __field(void *, func)
                __field(long, qlen_lazy)
@@ -412,13 +412,13 @@ TRACE_EVENT(rcu_callback,
  */
 TRACE_EVENT(rcu_kfree_callback,
 
-       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
+       TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset,
                 long qlen_lazy, long qlen),
 
        TP_ARGS(rcuname, rhp, offset, qlen_lazy, qlen),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(void *, rhp)
                __field(unsigned long, offset)
                __field(long, qlen_lazy)
@@ -447,12 +447,12 @@ TRACE_EVENT(rcu_kfree_callback,
  */
 TRACE_EVENT(rcu_batch_start,
 
-       TP_PROTO(char *rcuname, long qlen_lazy, long qlen, long blimit),
+       TP_PROTO(const char *rcuname, long qlen_lazy, long qlen, long blimit),
 
        TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(long, qlen_lazy)
                __field(long, qlen)
                __field(long, blimit)
@@ -477,12 +477,12 @@ TRACE_EVENT(rcu_batch_start,
  */
 TRACE_EVENT(rcu_invoke_callback,
 
-       TP_PROTO(char *rcuname, struct rcu_head *rhp),
+       TP_PROTO(const char *rcuname, struct rcu_head *rhp),
 
        TP_ARGS(rcuname, rhp),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(void *, rhp)
                __field(void *, func)
        ),
@@ -506,12 +506,12 @@ TRACE_EVENT(rcu_invoke_callback,
  */
 TRACE_EVENT(rcu_invoke_kfree_callback,
 
-       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset),
+       TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset),
 
        TP_ARGS(rcuname, rhp, offset),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(void *, rhp)
                __field(unsigned long, offset)
        ),
@@ -539,13 +539,13 @@ TRACE_EVENT(rcu_invoke_kfree_callback,
  */
 TRACE_EVENT(rcu_batch_end,
 
-       TP_PROTO(char *rcuname, int callbacks_invoked,
+       TP_PROTO(const char *rcuname, int callbacks_invoked,
                 bool cb, bool nr, bool iit, bool risk),
 
        TP_ARGS(rcuname, callbacks_invoked, cb, nr, iit, risk),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
+               __field(const char *, rcuname)
                __field(int, callbacks_invoked)
                __field(bool, cb)
                __field(bool, nr)
@@ -577,13 +577,13 @@ TRACE_EVENT(rcu_batch_end,
  */
 TRACE_EVENT(rcu_torture_read,
 
-       TP_PROTO(char *rcutorturename, struct rcu_head *rhp,
+       TP_PROTO(const char *rcutorturename, struct rcu_head *rhp,
                 unsigned long secs, unsigned long c_old, unsigned long c),
 
        TP_ARGS(rcutorturename, rhp, secs, c_old, c),
 
        TP_STRUCT__entry(
-               __field(char *, rcutorturename)
+               __field(const char *, rcutorturename)
                __field(struct rcu_head *, rhp)
                __field(unsigned long, secs)
                __field(unsigned long, c_old)
@@ -623,13 +623,13 @@ TRACE_EVENT(rcu_torture_read,
  */
 TRACE_EVENT(rcu_barrier,
 
-       TP_PROTO(char *rcuname, char *s, int cpu, int cnt, unsigned long done),
+       TP_PROTO(const char *rcuname, const char *s, int cpu, int cnt, unsigned long done),
 
        TP_ARGS(rcuname, s, cpu, cnt, done),
 
        TP_STRUCT__entry(
-               __field(char *, rcuname)
-               __field(char *, s)
+               __field(const char *, rcuname)
+               __field(const char *, s)
                __field(int, cpu)
                __field(int, cnt)
                __field(unsigned long, done)
index 7f8e7590e3e5d414141f3f778caaf58f8b0f6717..0a90ccc65bfb5b72883abf0eef5ff014549268e3 100644 (file)
@@ -94,7 +94,7 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head)
 
 extern void kfree(const void *);
 
-static inline bool __rcu_reclaim(char *rn, struct rcu_head *head)
+static inline bool __rcu_reclaim(const char *rn, struct rcu_head *head)
 {
        unsigned long offset = (unsigned long)head->func;
 
index cce6ba8bbace7f0793d008c725c9599a5ba8c1d1..14994d4e1a54998d114c230063daea391f259719 100644 (file)
@@ -377,7 +377,7 @@ EXPORT_SYMBOL_GPL(rcuhead_debug_descr);
 #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
 
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
-void do_trace_rcu_torture_read(char *rcutorturename, struct rcu_head *rhp,
+void do_trace_rcu_torture_read(const char *rcutorturename, struct rcu_head *rhp,
                               unsigned long secs,
                               unsigned long c_old, unsigned long c)
 {
index aa344111de3efdf67777bf6be400a5d2018b22c0..9ed6075dc562443b775cdec4efb56ff58b51bcef 100644 (file)
@@ -264,7 +264,7 @@ void rcu_check_callbacks(int cpu, int user)
  */
 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
 {
-       char *rn = NULL;
+       const char *rn = NULL;
        struct rcu_head *next, *list;
        unsigned long flags;
        RCU_TRACE(int cb_count = 0);
index 0cd385acccfa19660072ee3550d89a461246aa72..280d06cae3524160833d3441b5de5af3462798c7 100644 (file)
@@ -36,7 +36,7 @@ struct rcu_ctrlblk {
        RCU_TRACE(unsigned long gp_start); /* Start time for stalls. */
        RCU_TRACE(unsigned long ticks_this_gp); /* Statistic for stalls. */
        RCU_TRACE(unsigned long jiffies_stall); /* Jiffies at next stall. */
-       RCU_TRACE(char *name);          /* Name of RCU type. */
+       RCU_TRACE(const char *name);    /* Name of RCU type. */
 };
 
 /* Definition for rcupdate control block. */
index f4871e52c54600bb16d129d009e3d0828ad111fc..3d936f0fbcd8259fe95f99f344ec1f2a9d5cd5b9 100644 (file)
@@ -267,7 +267,7 @@ rcutorture_shutdown_notify(struct notifier_block *unused1,
  * Absorb kthreads into a kernel function that won't return, so that
  * they won't ever access module text or data again.
  */
-static void rcutorture_shutdown_absorb(char *title)
+static void rcutorture_shutdown_absorb(const char *title)
 {
        if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
                pr_notice(
@@ -337,7 +337,7 @@ rcu_random(struct rcu_random_state *rrsp)
 }
 
 static void
-rcu_stutter_wait(char *title)
+rcu_stutter_wait(const char *title)
 {
        while (stutter_pause_test || !rcutorture_runnable) {
                if (rcutorture_runnable)
@@ -366,7 +366,7 @@ struct rcu_torture_ops {
        int (*stats)(char *page);
        int irq_capable;
        int can_boost;
-       char *name;
+       const char *name;
 };
 
 static struct rcu_torture_ops *cur_ops;
@@ -1364,7 +1364,7 @@ rcu_torture_stutter(void *arg)
 }
 
 static inline void
-rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag)
+rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
 {
        pr_alert("%s" TORTURE_FLAG
                 "--- %s: nreaders=%d nfakewriters=%d "
index 068de3a93606980268351ccaf6b19fc45573b4ea..30201494560b0074c394d65bbe7d08466db57fcd 100644 (file)
@@ -1032,7 +1032,7 @@ static unsigned long rcu_cbs_completed(struct rcu_state *rsp,
  * rcu_nocb_wait_gp().
  */
 static void trace_rcu_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
-                               unsigned long c, char *s)
+                               unsigned long c, const char *s)
 {
        trace_rcu_future_grace_period(rdp->rsp->name, rnp->gpnum,
                                      rnp->completed, c, rnp->level,
@@ -2720,7 +2720,7 @@ static int rcu_cpu_has_callbacks(int cpu, bool *all_lazy)
  * Helper function for _rcu_barrier() tracing.  If tracing is disabled,
  * the compiler is expected to optimize this away.
  */
-static void _rcu_barrier_trace(struct rcu_state *rsp, char *s,
+static void _rcu_barrier_trace(struct rcu_state *rsp, const char *s,
                               int cpu, unsigned long done)
 {
        trace_rcu_barrier(rsp->name, s, cpu,
index b3832581043ceeff9c294669db5d26b58ba6a559..cbdeac6cea9ee4104d642490e27ae6cf9e983ecf 100644 (file)
@@ -445,7 +445,7 @@ struct rcu_state {
                                                /*  for CPU stalls. */
        unsigned long gp_max;                   /* Maximum GP duration in */
                                                /*  jiffies. */
-       char *name;                             /* Name of structure. */
+       const char *name;                       /* Name of structure. */
        char abbr;                              /* Abbreviated name. */
        struct list_head flavors;               /* List of RCU flavors. */
        struct irq_work wakeup_work;            /* Postponed wakeups */