From 657e11dcb9ec8e8ed7ffcbd490d845072bcb4be4 Mon Sep 17 00:00:00 2001
From: Christopher Kenna <cjk@cs.unc.edu>
Date: Tue, 11 Oct 2011 14:37:06 -0400
Subject: Add level-A release and remove some bad time-trace macros.

---
 include/litmus/trace.h |  3 +++
 litmus/event_group.c   | 11 -----------
 litmus/rt_domain.c     |  3 ---
 litmus/sched_mc.c      | 21 ++++++++++-----------
 4 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/include/litmus/trace.h b/include/litmus/trace.h
index d6829c416912..4fe4aadea8eb 100644
--- a/include/litmus/trace.h
+++ b/include/litmus/trace.h
@@ -108,6 +108,9 @@ feather_callback void save_timestamp_time(unsigned long event, unsigned long tim
 #define TS_TICK_START(t)		TTIMESTAMP(110, t)
 #define TS_TICK_END(t) 			TTIMESTAMP(111, t)
 
+#define TS_LVLA_RELEASE_START		DTIMESTAMP(112, TSK_RT)
+#define TS_LVLA_RELEASE_END		DTIMESTAMP(113, TSK_RT)
+
 
 #define TS_PLUGIN_SCHED_START		/* TIMESTAMP(120) */  /* currently unused */
 #define TS_PLUGIN_SCHED_END		/* TIMESTAMP(121) */
diff --git a/litmus/event_group.c b/litmus/event_group.c
index 06520299fb1d..478698a6d17a 100644
--- a/litmus/event_group.c
+++ b/litmus/event_group.c
@@ -36,8 +36,6 @@ static enum hrtimer_restart on_timer(struct hrtimer *timer)
 	struct list_head *pos, events[NUM_EVENT_PRIORITIES];
 	raw_spinlock_t *queue_lock;
 
-	QT_START;
-
 	el = container_of(timer, struct event_list, timer);
 	queue_lock = &el->group->queue_lock;
 
@@ -81,8 +79,6 @@ static enum hrtimer_restart on_timer(struct hrtimer *timer)
 
 	VTRACE("Exhausted %d events from list 0x%x\n", num, el);
 
-	QT_END;
-
 	return HRTIMER_NORESTART;
 }
 
@@ -171,8 +167,6 @@ void add_event(struct event_group *group, struct rt_event *e, lt_t fire)
 	struct event_list *el;
 	int in_use;
 
-	QT_START;
-
 	VTRACE("Adding event 0x%x with priority %d for time %llu\n",
 	       e, e->prio, fire);
 
@@ -207,8 +201,6 @@ void add_event(struct event_group *group, struct rt_event *e, lt_t fire)
 	} else {
 		VTRACE("Not my timer @%llu\n", fire);
 	}
-
-	QT_END;
 }
 
 /**
@@ -222,8 +214,6 @@ void cancel_event(struct rt_event *e)
 	struct event_group *group;
 	struct list_head *list, *pos;
 
-	QT_START;
-
 	VTRACE("Canceling event 0x%x with priority %d\n", e, e->prio);
 	group = e->_event_group;
 	if (!group) return;
@@ -270,7 +260,6 @@ void cancel_event(struct rt_event *e)
 	e->_event_group = NULL;
 
 	raw_spin_unlock(&group->queue_lock);
-	QT_END;
 }
 
 struct kmem_cache *event_list_cache;
diff --git a/litmus/rt_domain.c b/litmus/rt_domain.c
index 24b7a260e95b..09123eeadf2c 100644
--- a/litmus/rt_domain.c
+++ b/litmus/rt_domain.c
@@ -405,8 +405,6 @@ static void pd_requeue(domain_t *dom, struct task_struct *task)
 {
 	rt_domain_t *domain = (rt_domain_t*)dom->data;
 
-	QT_START;
-
 	BUG_ON(!task || !is_realtime(task));
 	TRACE_TASK(task, "Requeueing\n");
 	BUG_ON(is_queued(task));
@@ -423,7 +421,6 @@ static void pd_requeue(domain_t *dom, struct task_struct *task)
 		add_release(domain, task);
 	}
 
-	QT_END;
 }
 
 /* pd_take_ready - removes and returns the next ready task from the rt_domain
diff --git a/litmus/sched_mc.c b/litmus/sched_mc.c
index 3d311505f437..53c24ac2172c 100644
--- a/litmus/sched_mc.c
+++ b/litmus/sched_mc.c
@@ -16,6 +16,7 @@
 #include <linux/pid.h>
 
 #include <litmus/litmus.h>
+#include <litmus/trace.h>
 #include <litmus/jobs.h>
 #include <litmus/sched_plugin.h>
 #include <litmus/edf_common.h>
@@ -534,8 +535,6 @@ static void remove_from_all(struct task_struct* task)
 	struct crit_entry *ce;
 	struct domain *dom = get_task_domain(task);
 
-	QT_START;
-
 	TRACE_MC_TASK(task, "Removing from everything\n");
 	BUG_ON(!task);
 
@@ -572,7 +571,6 @@ static void remove_from_all(struct task_struct* task)
 
 	BUG_ON(is_queued(task));
 	raw_spin_unlock(dom->lock);
-	QT_END;
 }
 
 /**
@@ -670,7 +668,6 @@ static lt_t __ce_timer_function(struct ce_dom_data *ce_data)
 	struct domain *dom = ce->domain;
 	struct task_struct *old_link = NULL;
 	lt_t next_timer_abs;
-	QT_START;
 
 	TRACE("MC level-A timer callback for CPU %d\n", ce_data->cpu);
 
@@ -700,7 +697,6 @@ static lt_t __ce_timer_function(struct ce_dom_data *ce_data)
 		raw_spin_unlock(dom->lock);
 		check_for_preempt(dom);
 	}
-	QT_END;
 	return next_timer_abs;
 }
 
@@ -712,10 +708,14 @@ static void ce_timer_function(struct rt_event *e)
 	unsigned long flags;
 	lt_t next_timer_abs;
 
+	TS_LVLA_RELEASE_START;
+
 	local_irq_save(flags);
 	next_timer_abs = __ce_timer_function(ce_data);
 	add_event(per_cpu(cpus, ce_data->cpu).event_group, e, next_timer_abs);
 	local_irq_restore(flags);
+
+	TS_LVLA_RELEASE_END;
 }
 #else /* else to CONFIG_MERGE_TIMERS */
 static enum hrtimer_restart ce_timer_function(struct hrtimer *timer)
@@ -725,10 +725,15 @@ static enum hrtimer_restart ce_timer_function(struct hrtimer *timer)
 	unsigned long flags;
 	lt_t next_timer_abs;
 
+	TS_LVLA_RELEASE_START;
+
 	local_irq_save(flags);
 	next_timer_abs = __ce_timer_function(ce_data);
 	hrtimer_set_expires(timer, ns_to_ktime(next_timer_abs));
 	local_irq_restore(flags);
+
+	TS_LVLA_RELEASE_END;
+
 	return HRTIMER_RESTART;
 }
 #endif /* CONFIG_MERGE_TIMERS */
@@ -743,15 +748,11 @@ static void mc_release_jobs(rt_domain_t* rt, struct bheap* tasks)
 	struct task_struct *first = bheap_peek(rt->order, tasks)->value;
 	struct domain *dom = get_task_domain(first);
 
-	QT_START;
-
 	raw_spin_lock_irqsave(dom->lock, flags);
 	TRACE(TS "Jobs released\n", TA(first));
 	__merge_ready(rt, tasks);
 	check_for_preempt(dom);
 	raw_spin_unlock_irqrestore(dom->lock, flags);
-
-	QT_END;
 }
 
 /**
@@ -890,7 +891,6 @@ static struct task_struct* mc_schedule(struct task_struct* prev)
 	struct cpu_entry* entry = &__get_cpu_var(cpus);
 	int i, out_of_time, sleep, preempt, exists, blocks, global, lower;
 	struct task_struct *dtask = NULL, *ready_task = NULL, *next = NULL;
-	QT_START;
 
 	local_irq_save(flags);
 
@@ -1004,7 +1004,6 @@ static struct task_struct* mc_schedule(struct task_struct* prev)
 		TRACE_MC_TASK(next, "Picked this task\n");
 	} else if (exists && !next)
 		TRACE_ENTRY(entry, "Becomes idle at %llu\n", litmus_clock());
-	QT_END;
 	return next;
 }
 
-- 
cgit v1.2.2