Debug contention for the audit_cmd_mutex including timing, stalling
and identies of holder and requestor.
Signed-off-by: Richard Guy Briggs <rgb(a)redhat.com>
---
kernel/audit.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/kernel/audit.c b/kernel/audit.c
index 93a466b..a586bf2 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1131,7 +1131,23 @@ static void audit_receive_skb(struct sk_buff *skb)
/* Receive messages from netlink socket. */
static void audit_receive(struct sk_buff *skb)
{
- mutex_lock(&audit_cmd_mutex);
+ struct task_struct *owner;
+ unsigned long trytime = jiffies;
+
+ pid_t pid = 0;
+
+ if (!mutex_trylock(&audit_cmd_mutex)) {
+ rcu_read_lock();
+ owner = ACCESS_ONCE(audit_cmd_mutex.owner);
+ if (owner)
+ pid = owner->pid;
+ rcu_read_unlock();
+ pr_warn("( %lu %lu )audit_cmd_mutex apid=%d Qlen=%d %d(%s) trying, already held by
%d\n",
+ trytime, jiffies - trytime, audit_pid, skb_queue_len(&audit_skb_queue),
current->pid, current->comm, pid);
+ mutex_lock(&audit_cmd_mutex);
+ pr_warn("( %lu %lu )audit_cmd_mutex apid=%d Qlen=%d %d(%s) acquired, released by
%d\n",
+ trytime, jiffies - trytime, audit_pid, skb_queue_len(&audit_skb_queue),
current->pid, current->comm, pid);
+ }
audit_receive_skb(skb);
mutex_unlock(&audit_cmd_mutex);
}
--
1.7.1