This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[SYSTEMTAP/PATCH 3/4] rt : stp_utrace.c : replace utrace->lock with raw_lock
- From: Santosh Shukla <sshukla at mvista dot com>
- To: systemtap at sourceware dot org
- Cc: sshukla at mvista dot com
- Date: Tue, 9 Sep 2014 12:38:18 +0530
- Subject: [SYSTEMTAP/PATCH 3/4] rt : stp_utrace.c : replace utrace->lock with raw_lock
- Authentication-results: sourceware.org; auth=none
- References: <1410246499-6938-1-git-send-email-sshukla at mvista dot com>
In preempt-rt kernel, At the time of launching stap script noticed below
bug_on. Replacing spinlock with Raw fixes this problem.
[ 159.433464] Preemption disabled at:[<ffffffff810b74d6>] remove_wait_queue+0x36/0x40
[ 159.433466] CPU: 8 PID: 6723 Comm: bash Tainted: GF W O 3.14.12-rt-rt9+ #1
[ 159.433467] Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.02.01.0002.082220131453 08/22/2013
[ 159.433471] ffff88042d917d80 ffff88040f623d90 ffffffff81602b13 ffff8804121e3980
[ 159.433474] ffff88040f623da0 ffffffff815fd2fb ffff88040f623df8 ffffffff81606017
[ 159.433478] ffff88040f623fd8 0000000000017d80 0000000000017d80 ffffffff810bcbcb
[ 159.433478] Call Trace:
[ 159.433481] [<ffffffff81602b13>] dump_stack+0x4e/0x7a
[ 159.433484] [<ffffffff815fd2fb>] __schedule_bug+0x9f/0xad
[ 159.433486] [<ffffffff81606017>] __schedule+0x627/0x6a0
[ 159.433489] [<ffffffff810bcbcb>] ? task_blocks_on_rt_mutex+0x19b/0x220
[ 159.433492] [<ffffffff816060c0>] schedule+0x30/0xa0
[ 159.433495] [<ffffffff81607a9d>] rt_spin_lock_slowlock+0xbd/0x1f0
[ 159.433498] [<ffffffff81608645>] rt_spin_lock+0x25/0x30
[ 159.433503] [<ffffffffa076fbf5>] start_report+0x45/0xb0 [stap_c108d00c22143294d42db713b804dbb9_10325]
[ 159.433508] [<ffffffffa0773e38>] utrace_report_syscall_exit+0x88/0x110 [stap_c108d00c22143294d42db713b804dbb9_10325]
[ 159.433511] [<ffffffff81023d30>] syscall_trace_leave+0x100/0x130
[ 159.433514] [<ffffffff8161114b>] int_check_syscall_exit_work+0x34/0x3d
Signed-off-by: Santosh Shukla <sshukla@mvista.com>
---
runtime/stp_utrace.c | 82 +++++++++++++++++++++++++-------------------------
1 file changed, 41 insertions(+), 41 deletions(-)
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 0c9d0eb..b145baa 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -56,7 +56,7 @@
* in time to have their callbacks seen.
*/
struct utrace {
- spinlock_t lock;
+ raw_spinlock_t lock;
struct list_head attached, attaching;
struct utrace_engine *reporting;
@@ -332,7 +332,7 @@ static void utrace_cleanup(struct utrace *utrace)
/* Free engines associated with the struct utrace, starting
* with the 'attached' list then doing the 'attaching' list. */
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
list_for_each_entry_safe(engine, next, &utrace->attached, entry) {
#ifdef STP_TF_DEBUG
printk(KERN_ERR "%s:%d - removing engine\n",
@@ -365,7 +365,7 @@ static void utrace_cleanup(struct utrace *utrace)
: "UNKNOWN"));
utrace->report_work_added = 0;
}
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
/* Free the struct utrace itself. */
kmem_cache_free(utrace_cachep, utrace);
@@ -460,7 +460,7 @@ static bool utrace_task_alloc(struct task_struct *task)
if (unlikely(!utrace))
return false;
- spin_lock_init(&utrace->lock);
+ raw_spin_lock_init(&utrace->lock);
INIT_LIST_HEAD(&utrace->attached);
INIT_LIST_HEAD(&utrace->attaching);
utrace->resume = UTRACE_RESUME;
@@ -501,7 +501,7 @@ static void utrace_free(struct utrace *utrace)
spin_unlock(&task_utrace_lock);
/* Free the utrace struct. */
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
#ifdef STP_TF_DEBUG
if (unlikely(utrace->reporting)
|| unlikely(!list_empty(&utrace->attached))
@@ -530,7 +530,7 @@ static void utrace_free(struct utrace *utrace)
: "UNKNOWN"));
utrace->report_work_added = 0;
}
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
kmem_cache_free(utrace_cachep, utrace);
}
@@ -606,7 +606,7 @@ static int utrace_add_engine(struct task_struct *target,
{
int ret;
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
ret = -EEXIST;
if ((flags & UTRACE_ATTACH_EXCLUSIVE) &&
@@ -654,7 +654,7 @@ static int utrace_add_engine(struct task_struct *target,
utrace_engine_get(engine);
ret = 0;
unlock:
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return ret;
}
@@ -703,11 +703,11 @@ static struct utrace_engine *utrace_attach_task(
if (!(flags & UTRACE_ATTACH_CREATE)) {
if (unlikely(!utrace))
return ERR_PTR(-ENOENT);
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
engine = find_matching_engine(utrace, flags, ops, data);
if (engine)
utrace_engine_get(engine);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return engine ?: ERR_PTR(-ENOENT);
}
@@ -823,14 +823,14 @@ static struct utrace *get_utrace_lock(struct task_struct *target,
}
utrace = task_utrace_struct(target);
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
if (unlikely(utrace->reap) || unlikely(!engine->ops) ||
unlikely(engine->ops == &utrace_detached_ops)) {
/*
* By the time we got the utrace lock,
* it had been reaped or detached already.
*/
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
utrace = ERR_PTR(-ESRCH);
if (!attached && engine->ops == &utrace_detached_ops)
utrace = ERR_PTR(-ERESTARTSYS);
@@ -992,7 +992,7 @@ static int utrace_set_events(struct task_struct *target,
ret = -EINPROGRESS;
}
unlock:
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return ret;
}
@@ -1138,7 +1138,7 @@ static bool utrace_reset(struct task_struct *task, struct utrace *utrace)
*/
rcu_read_lock();
utrace->utrace_flags = flags;
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
rcu_read_unlock();
put_detached_list(&detached);
@@ -1154,7 +1154,7 @@ static void utrace_finish_stop(void)
*/
if (unlikely(__fatal_signal_pending(current))) {
struct utrace *utrace = task_utrace_struct(current);
- spin_unlock_wait(&utrace->lock);
+ raw_spin_unlock_wait(&utrace->lock);
}
}
@@ -1168,7 +1168,7 @@ static void utrace_stop(struct task_struct *task, struct utrace *utrace,
enum utrace_resume_action action)
{
relock:
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
if (action < utrace->resume) {
/*
@@ -1215,7 +1215,7 @@ relock:
if (unlikely(__fatal_signal_pending(task))) {
spin_unlock_irq(&task->sighand->siglock);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return;
}
@@ -1230,7 +1230,7 @@ relock:
task->signal->flags = SIGNAL_STOP_STOPPED;
spin_unlock_irq(&task->sighand->siglock);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
schedule();
@@ -1266,7 +1266,7 @@ static void utrace_maybe_reap(struct task_struct *target, struct utrace *utrace,
struct utrace_engine *engine, *next;
struct list_head attached;
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
if (reap) {
/*
@@ -1280,7 +1280,7 @@ static void utrace_maybe_reap(struct task_struct *target, struct utrace *utrace,
utrace->reap = 1;
if (utrace->utrace_flags & _UTRACE_DEATH_EVENTS) {
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return;
}
} else {
@@ -1318,7 +1318,7 @@ static void utrace_maybe_reap(struct task_struct *target, struct utrace *utrace,
list_replace_init(&utrace->attached, &attached);
list_splice_tail_init(&utrace->attaching, &attached);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
list_for_each_entry_safe(engine, next, &attached, entry) {
if (engine->flags & UTRACE_EVENT(REAP))
@@ -1493,7 +1493,7 @@ static int utrace_control(struct task_struct *target,
if (unlikely(target->exit_state)) {
ret = utrace_control_dead(target, utrace, action);
if (ret) {
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return ret;
}
reset = true;
@@ -1627,7 +1627,7 @@ static int utrace_control(struct task_struct *target,
if (reset)
utrace_reset(target, utrace);
else
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
return ret;
}
@@ -1686,7 +1686,7 @@ static int utrace_barrier(struct task_struct *target,
*/
if (utrace->reporting != engine)
ret = 0;
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
if (!ret)
break;
}
@@ -1724,12 +1724,12 @@ static enum utrace_resume_action start_report(struct utrace *utrace)
enum utrace_resume_action resume = utrace->resume;
if (utrace->pending_attach ||
(resume > UTRACE_STOP && resume < UTRACE_RESUME)) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
splice_attaching(utrace);
resume = utrace->resume;
if (resume > UTRACE_STOP)
utrace->resume = UTRACE_RESUME;
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
}
return resume;
}
@@ -1739,7 +1739,7 @@ static inline void finish_report_reset(struct task_struct *task,
struct utrace_report *report)
{
if (unlikely(report->spurious || report->detaches)) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
if (utrace_reset(task, utrace))
report->action = UTRACE_RESUME;
}
@@ -1762,7 +1762,7 @@ static void finish_report(struct task_struct *task, struct utrace *utrace,
resume = will_not_stop ? UTRACE_REPORT : UTRACE_RESUME;
if (resume < utrace->resume) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
utrace->resume = resume;
if (! utrace->task_work_added) {
int rc = stp_task_work_add(task, &utrace->work);
@@ -1778,7 +1778,7 @@ static void finish_report(struct task_struct *task, struct utrace *utrace,
__FUNCTION__, __LINE__, rc);
}
}
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
}
finish_report_reset(task, utrace, report);
@@ -1799,9 +1799,9 @@ static void finish_callback_report(struct task_struct *task,
* This way, a 0 return is an unambiguous indicator that any
* callback returning UTRACE_DETACH has indeed caused detach.
*/
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
engine->ops = &utrace_detached_ops;
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
}
/*
@@ -1820,16 +1820,16 @@ static void finish_callback_report(struct task_struct *task,
report->resume_action = action;
if (engine_wants_stop(engine)) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
clear_engine_wants_stop(engine);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
}
return;
}
if (!engine_wants_stop(engine)) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
/*
* If utrace_control() came in and detached us
* before we got the lock, we must not stop now.
@@ -1838,7 +1838,7 @@ static void finish_callback_report(struct task_struct *task,
report->detaches = true;
else
mark_engine_wants_stop(utrace, engine);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
}
}
@@ -2216,9 +2216,9 @@ static void utrace_finish_vfork(struct task_struct *task)
struct utrace *utrace = task_utrace_struct(task);
if (utrace->vfork_stop) {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
utrace->vfork_stop = 0;
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
utrace_stop(task, utrace, UTRACE_RESUME); /* XXX */
}
}
@@ -2293,12 +2293,12 @@ static void utrace_report_death(void *cb_data __attribute__ ((unused)),
}
}
else {
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
BUG_ON(utrace->death);
utrace->death = 1;
utrace->resume = UTRACE_RESUME;
splice_attaching(utrace);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
REPORT_CALLBACKS(, task, utrace, &report, UTRACE_EVENT(DEATH),
report_death, engine, -1/*group_dead*/,
@@ -2439,12 +2439,12 @@ static void utrace_report_work(struct task_work *work)
might_sleep();
utrace->report_work_added = 0;
- spin_lock(&utrace->lock);
+ raw_spin_lock(&utrace->lock);
BUG_ON(utrace->death);
utrace->death = 1;
utrace->resume = UTRACE_RESUME;
splice_attaching(utrace);
- spin_unlock(&utrace->lock);
+ raw_spin_unlock(&utrace->lock);
REPORT_CALLBACKS(, task, utrace, &report, UTRACE_EVENT(DEATH),
report_death, engine, -1/*group_dead*/,
--
1.7.9.5