lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Mar 2019 09:40:07 +0800
From:   Yafang Shao <laoar.shao@...il.com>
To:     rostedt@...dmis.org, mingo@...hat.com, peterz@...radead.org,
        paulmck@...ux.vnet.ibm.com, josh@...htriplett.org,
        mathieu.desnoyers@...icios.com, jiangshanlai@...il.com,
        joel@...lfernandes.org
Cc:     shaoyafang@...iglobal.com, linux-kernel@...r.kernel.org,
        Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH 3/3] rcu: validate arguments for rcu tracepoints

When CONFIG_RCU_TRACE is not set, all these tracepoints are define as
do-nothing macro.
We'd better make those inline functions that take proper arguments.

As RCU_TRACE() is defined as do-nothing marco as well when
CONFIG_RCU_TRACE is not set, so we can clean it up.

Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
 include/trace/events/rcu.h | 84 +++++++++++++++++++++++++++++-----------------
 kernel/rcu/rcu.h           |  9 ++---
 kernel/rcu/tree.c          |  8 ++---
 3 files changed, 60 insertions(+), 41 deletions(-)

diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index f0c4d10..357e1b6 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -750,36 +750,60 @@
 
 #else /* #ifdef CONFIG_RCU_TRACE */
 
-#define trace_rcu_grace_period(rcuname, gp_seq, gpevent) do { } while (0)
-#define trace_rcu_future_grace_period(rcuname, gp_seq, gp_seq_req, \
-				      level, grplo, grphi, event) \
-				      do { } while (0)
-#define trace_rcu_grace_period_init(rcuname, gp_seq, level, grplo, grphi, \
-				    qsmask) do { } while (0)
-#define trace_rcu_exp_grace_period(rcuname, gqseq, gpevent) \
-	do { } while (0)
-#define trace_rcu_exp_funnel_lock(rcuname, level, grplo, grphi, gpevent) \
-	do { } while (0)
-#define trace_rcu_nocb_wake(rcuname, cpu, reason) do { } while (0)
-#define trace_rcu_preempt_task(rcuname, pid, gp_seq) do { } while (0)
-#define trace_rcu_unlock_preempted_task(rcuname, gp_seq, pid) do { } while (0)
-#define trace_rcu_quiescent_state_report(rcuname, gp_seq, mask, qsmask, level, \
-					 grplo, grphi, gp_tasks) do { } \
-	while (0)
-#define trace_rcu_fqs(rcuname, gp_seq, cpu, qsevent) do { } while (0)
-#define trace_rcu_dyntick(polarity, oldnesting, newnesting, dyntick) do { } while (0)
-#define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0)
-#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \
-	do { } while (0)
-#define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \
-	do { } while (0)
-#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
-#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
-#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
-	do { } while (0)
-#define trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
-	do { } while (0)
-#define trace_rcu_barrier(name, s, cpu, cnt, done) do { } while (0)
+TRACE_EVENT_NONE(rcu_grace_period,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq,
+		 const char *gpevent));
+TRACE_EVENT_NONE(rcu_future_grace_period,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq,
+		 unsigned long gp_seq_req, u8 level, int grplo,
+		 int grphi, const char *gpevent));
+TRACE_EVENT_NONE(rcu_grace_period_init,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq, u8 level,
+		 int grplo, int grphi, unsigned long qsmask));
+TRACE_EVENT_NONE(rcu_exp_grace_period,
+	TP_PROTO(const char *rcuname, unsigned long gpseq,
+		 const char *gpevent));
+TRACE_EVENT_NONE(rcu_exp_funnel_lock,
+	TP_PROTO(const char *rcuname, u8 level, int grplo, int grphi,
+		 const char *gpevent));
+TRACE_EVENT_NONE(rcu_nocb_wake,
+	TP_PROTO(const char *rcuname, int cpu, const char *reason));
+TRACE_EVENT_NONE(rcu_preempt_task,
+	TP_PROTO(const char *rcuname, int pid, unsigned long gp_seq));
+TRACE_EVENT_NONE(rcu_unlock_preempted_task,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq, int pid));
+TRACE_EVENT_NONE(rcu_quiescent_state_report,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq,
+		 unsigned long mask, unsigned long qsmask,
+		 u8 level, int grplo, int grphi, int gp_tasks));
+TRACE_EVENT_NONE(rcu_fqs,
+	TP_PROTO(const char *rcuname, unsigned long gp_seq, int cpu,
+		 const char *qsevent));
+TRACE_EVENT_NONE(rcu_dyntick,
+	TP_PROTO(const char *polarity, long oldnesting, long newnesting,
+		 atomic_t dynticks));
+TRACE_EVENT_NONE(rcu_callback,
+	TP_PROTO(const char *rcuname, struct rcu_head *rhp, long qlen_lazy,
+		 long qlen));
+TRACE_EVENT_NONE(rcu_kfree_callback,
+	TP_PROTO(const char *rcuname, struct rcu_head *rhp,
+		 unsigned long offset, long qlen_lazy, long qlen));
+TRACE_EVENT_NONE(rcu_batch_start,
+	TP_PROTO(const char *rcuname, long qlen_lazy, long qlen, long blimit));
+TRACE_EVENT_NONE(rcu_invoke_callback,
+	TP_PROTO(const char *rcuname, struct rcu_head *rhp));
+TRACE_EVENT_NONE(rcu_invoke_kfree_callback,
+	TP_PROTO(const char *rcuname, struct rcu_head *rhp,
+		 unsigned long offset));
+TRACE_EVENT_NONE(rcu_batch_end,
+	TP_PROTO(const char *rcuname, int callbacks_invoked,
+		 char cb, char nr, char iit, char risk));
+TRACE_EVENT_NONE(rcu_torture_read,
+	TP_PROTO(const char *rcutorturename, struct rcu_head *rhp,
+		 unsigned long secs, unsigned long c_old, unsigned long c));
+TRACE_EVENT_NONE(rcu_barrier,
+	TP_PROTO(const char *rcuname, const char *s, int cpu, int cnt,
+		 unsigned long done));
 
 #endif /* #else #ifdef CONFIG_RCU_TRACE */
 
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index a393e24..2778e44 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -24,11 +24,6 @@
 #define __LINUX_RCU_H
 
 #include <trace/events/rcu.h>
-#ifdef CONFIG_RCU_TRACE
-#define RCU_TRACE(stmt) stmt
-#else /* #ifdef CONFIG_RCU_TRACE */
-#define RCU_TRACE(stmt)
-#endif /* #else #ifdef CONFIG_RCU_TRACE */
 
 /* Offset to allow for unmatched rcu_irq_{enter,exit}(). */
 #define DYNTICK_IRQ_NONIDLE	((LONG_MAX / 2) + 1)
@@ -229,12 +224,12 @@ static inline bool __rcu_reclaim(const char *rn, struct rcu_head *head)
 
 	rcu_lock_acquire(&rcu_callback_map);
 	if (__is_kfree_rcu_offset(offset)) {
-		RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset);)
+		trace_rcu_invoke_kfree_callback(rn, head, offset);
 		kfree((void *)head - offset);
 		rcu_lock_release(&rcu_callback_map);
 		return true;
 	} else {
-		RCU_TRACE(trace_rcu_invoke_callback(rn, head);)
+		trace_rcu_invoke_callback(rn, head);
 		f = head->func;
 		WRITE_ONCE(head->func, (rcu_callback_t)0L);
 		f(head);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 9180158..d2ad39f 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2329,14 +2329,14 @@ static void rcu_report_qs_rnp(unsigned long mask, struct rcu_node *rnp,
  */
 int rcutree_dying_cpu(unsigned int cpu)
 {
-	RCU_TRACE(bool blkd;)
-	RCU_TRACE(struct rcu_data *rdp = this_cpu_ptr(&rcu_data);)
-	RCU_TRACE(struct rcu_node *rnp = rdp->mynode;)
+	bool blkd;
+	struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
+	struct rcu_node *rnp = rdp->mynode;
 
 	if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
 		return 0;
 
-	RCU_TRACE(blkd = !!(rnp->qsmask & rdp->grpmask);)
+	blkd = !!(rnp->qsmask & rdp->grpmask);
 	trace_rcu_grace_period(rcu_state.name, rnp->gp_seq,
 			       blkd ? TPS("cpuofl") : TPS("cpuofl-bgp"));
 	return 0;
-- 
1.8.3.1

Powered by blists - more mailing lists