Index: kernel/generic/src/synch/rcu.c
===================================================================
--- kernel/generic/src/synch/rcu.c	(revision b7fd2a02e4161f4edd38548e7f8456b8021549be)
+++ kernel/generic/src/synch/rcu.c	(revision 3061bc129a855122d429fbba1e623a521aaa164c)
@@ -35,7 +35,7 @@
  * @file
  * @brief Preemptible read-copy update. Usable from interrupt handlers.
- * 
+ *
  * @par Podzimek-preempt-RCU (RCU_PREEMPT_PODZIMEK)
- * 
+ *
  * Podzimek-preempt-RCU is a preemptible variant of Podzimek's non-preemptible
  * RCU algorithm [1, 2]. Grace period (GP) detection is centralized into a
@@ -43,24 +43,24 @@
  * that it passed a quiescent state (QS), ie a state when the cpu is
  * outside of an rcu reader section (CS). Cpus check for QSs during context
- * switches and when entering and exiting rcu reader sections. Once all 
- * cpus announce a QS and if there were no threads preempted in a CS, the 
+ * switches and when entering and exiting rcu reader sections. Once all
+ * cpus announce a QS and if there were no threads preempted in a CS, the
  * GP ends.
- * 
- * The detector increments the global GP counter, _rcu_cur_gp, in order 
- * to start a new GP. Readers notice the new GP by comparing the changed 
+ *
+ * The detector increments the global GP counter, _rcu_cur_gp, in order
+ * to start a new GP. Readers notice the new GP by comparing the changed
  * _rcu_cur_gp to a locally stored value last_seen_gp which denotes the
  * the last GP number for which the cpu noted an explicit QS (and issued
  * a memory barrier). Readers check for the change in the outer-most
- * (ie not nested) rcu_read_lock()/unlock() as these functions represent 
- * a QS. The reader first executes a memory barrier (MB) in order to contain 
- * memory references within a CS (and to make changes made by writers 
- * visible in the CS following rcu_read_lock()). Next, the reader notes 
+ * (ie not nested) rcu_read_lock()/unlock() as these functions represent
+ * a QS. The reader first executes a memory barrier (MB) in order to contain
+ * memory references within a CS (and to make changes made by writers
+ * visible in the CS following rcu_read_lock()). Next, the reader notes
  * that it reached a QS by updating the cpu local last_seen_gp to the
  * global GP counter, _rcu_cur_gp. Cache coherency eventually makes
  * the updated last_seen_gp visible to the detector cpu, much like it
  * delivered the changed _rcu_cur_gp to all cpus.
- * 
- * The detector waits a while after starting a GP and then reads each 
- * cpu's last_seen_gp to see if it reached a QS. If a cpu did not record 
+ *
+ * The detector waits a while after starting a GP and then reads each
+ * cpu's last_seen_gp to see if it reached a QS. If a cpu did not record
  * a QS (might be a long running thread without an RCU reader CS; or cache
  * coherency has yet to make the most current last_seen_gp visible to
@@ -68,28 +68,28 @@
  * via an IPI. If the IPI handler finds the cpu still in a CS, it instructs
  * the cpu to notify the detector that it had exited the CS via a semaphore
- * (CPU->rcu.is_delaying_gp). 
+ * (CPU->rcu.is_delaying_gp).
  * The detector then waits on the semaphore for any cpus to exit their
- * CSs. Lastly, it waits for the last reader preempted in a CS to 
+ * CSs. Lastly, it waits for the last reader preempted in a CS to
  * exit its CS if there were any and signals the end of the GP to
  * separate reclaimer threads wired to each cpu. Reclaimers then
  * execute the callbacks queued on each of the cpus.
- * 
- * 
+ *
+ *
  * @par A-RCU algorithm (RCU_PREEMPT_A)
- * 
+ *
  * A-RCU is based on the user space rcu algorithm in [3] utilizing signals
- * (urcu) and Podzimek's rcu [1]. Like in Podzimek's rcu, callbacks are 
- * executed by cpu-bound reclaimer threads. There is however no dedicated 
- * detector thread and the reclaimers take on the responsibilities of the 
- * detector when they need to start a new GP. A new GP is again announced 
+ * (urcu) and Podzimek's rcu [1]. Like in Podzimek's rcu, callbacks are
+ * executed by cpu-bound reclaimer threads. There is however no dedicated
+ * detector thread and the reclaimers take on the responsibilities of the
+ * detector when they need to start a new GP. A new GP is again announced
  * and acknowledged with _rcu_cur_gp and the cpu local last_seen_gp. Unlike
- * Podzimek's rcu, cpus check explicitly for QS only during context switches. 
+ * Podzimek's rcu, cpus check explicitly for QS only during context switches.
  * Like in urcu, rcu_read_lock()/unlock() only maintain the nesting count
  * and never issue any memory barriers. This makes rcu_read_lock()/unlock()
  * simple and fast.
- * 
+ *
  * If a new callback is queued for a reclaimer and no GP is in progress,
- * the reclaimer takes on the role of a detector. The detector increments 
- * _rcu_cur_gp in order to start a new GP. It waits a while to give cpus 
+ * the reclaimer takes on the role of a detector. The detector increments
+ * _rcu_cur_gp in order to start a new GP. It waits a while to give cpus
  * a chance to switch a context (a natural QS). Then, it examines each
  * non-idle cpu that has yet to pass a QS via an IPI. The IPI handler
@@ -98,28 +98,28 @@
  * finds the cpu in a CS it does nothing and let the detector poll/interrupt
  * the cpu again after a short sleep.
- * 
+ *
  * @par Caveats
- * 
+ *
  * last_seen_gp and _rcu_cur_gp are always 64bit variables and they
  * are read non-atomically on 32bit machines. Reading a clobbered
  * value of last_seen_gp or _rcu_cur_gp or writing a clobbered value
  * of _rcu_cur_gp to last_seen_gp will at worst force the detector
- * to unnecessarily interrupt a cpu. Interrupting a cpu makes the 
+ * to unnecessarily interrupt a cpu. Interrupting a cpu makes the
  * correct value of _rcu_cur_gp visible to the cpu and correctly
  * resets last_seen_gp in both algorithms.
- * 
- * 
- * 
+ *
+ *
+ *
  * [1] Read-copy-update for opensolaris,
  *     2010, Podzimek
  *     https://andrej.podzimek.org/thesis.pdf
- * 
+ *
  * [2] (podzimek-rcu) implementation file "rcu.patch"
  *     http://d3s.mff.cuni.cz/projects/operating_systems/rcu/rcu.patch
- * 
+ *
  * [3] User-level implementations of read-copy update,
  *     2012, appendix
  *     http://www.rdrop.com/users/paulmck/RCU/urcu-supp-accepted.2011.08.30a.pdf
- * 
+ *
  */
 
@@ -139,11 +139,11 @@
 #include <macros.h>
 
-/* 
- * Number of milliseconds to give to preexisting readers to finish 
+/*
+ * Number of milliseconds to give to preexisting readers to finish
  * when non-expedited grace period detection is in progress.
  */
 #define DETECT_SLEEP_MS    10
-/* 
- * Max number of pending callbacks in the local cpu's queue before 
+/*
+ * Max number of pending callbacks in the local cpu's queue before
  * aggressively expediting the current grace period
  */
@@ -159,6 +159,6 @@
 #define UINT32_MAX_HALF    2147483648U
 
-/** 
- * The current grace period number. Increases monotonically. 
+/**
+ * The current grace period number. Increases monotonically.
  * Lock rcu.gp_lock or rcu.preempt_lock to get a current value.
  */
@@ -171,5 +171,5 @@
 	/** Reclaimers use to notify the detector to accelerate GP detection. */
 	condvar_t expedite_now;
-	/** 
+	/**
 	 * Protects: req_gp_end_cnt, req_expedited_cnt, completed_gp, _rcu_cur_gp;
 	 * or: completed_gp, _rcu_cur_gp
@@ -177,6 +177,6 @@
 	SPINLOCK_DECLARE(gp_lock);
 	/**
-	 * The number of the most recently completed grace period. At most 
-	 * one behind _rcu_cur_gp. If equal to _rcu_cur_gp, a grace period 
+	 * The number of the most recently completed grace period. At most
+	 * one behind _rcu_cur_gp. If equal to _rcu_cur_gp, a grace period
 	 * detection is not in progress and the detector is idle.
 	 */
@@ -189,7 +189,7 @@
 	/** Reader that have been preempted and might delay the next grace period.*/
 	list_t next_preempted;
-	/** 
-	 * The detector is waiting for the last preempted reader 
-	 * in cur_preempted to announce that it exited its reader 
+	/**
+	 * The detector is waiting for the last preempted reader
+	 * in cur_preempted to announce that it exited its reader
 	 * section by up()ing remaining_readers.
 	 */
@@ -198,6 +198,6 @@
 #ifdef RCU_PREEMPT_A
 	
-	/** 
-	 * The detector waits on this semaphore for any preempted readers 
+	/**
+	 * The detector waits on this semaphore for any preempted readers
 	 * delaying the grace period once all cpus pass a quiescent state.
 	 */
@@ -212,15 +212,15 @@
 	/** Number of consecutive grace periods to detect quickly and aggressively.*/
 	size_t req_expedited_cnt;
-	/** 
+	/**
 	 * Number of cpus with readers that are delaying the current GP.
 	 * They will up() remaining_readers.
 	 */
 	atomic_t delaying_cpu_cnt;
-	/** 
+	/**
 	 * The detector waits on this semaphore for any readers delaying the GP.
-	 * 
-	 * Each of the cpus with readers that are delaying the current GP 
-	 * must up() this sema once they reach a quiescent state. If there 
-	 * are any readers in cur_preempted (ie preempted preexisting) and 
+	 *
+	 * Each of the cpus with readers that are delaying the current GP
+	 * must up() this sema once they reach a quiescent state. If there
+	 * are any readers in cur_preempted (ie preempted preexisting) and
 	 * they are already delaying GP detection, the last to unlock its
 	 * reader section must up() this sema once.
@@ -252,5 +252,5 @@
 static void start_reclaimers(void);
 static void synch_complete(rcu_item_t *rcu_item);
-static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item, 
+static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item,
 	rcu_func_t func);
 static void add_barrier_cb(void *arg);
@@ -396,6 +396,6 @@
 
 
-/** Cleans up global RCU resources and stops dispatching callbacks. 
- * 
+/** Cleans up global RCU resources and stops dispatching callbacks.
+ *
  * Call when shutting down the kernel. Outstanding callbacks will
  * not be processed. Instead they will linger forever.
@@ -444,8 +444,8 @@
 		snprintf(name, THREAD_NAME_BUFLEN - 1, "rcu-rec/%u", cpu_id);
 		
-		cpus[cpu_id].rcu.reclaimer_thr = 
+		cpus[cpu_id].rcu.reclaimer_thr =
 			thread_create(reclaimer, NULL, TASK, THREAD_FLAG_NONE, name);
 
-		if (!cpus[cpu_id].rcu.reclaimer_thr) 
+		if (!cpus[cpu_id].rcu.reclaimer_thr)
 			panic("Failed to create RCU reclaimer thread on cpu%u.", cpu_id);
 
@@ -460,8 +460,8 @@
 static void start_detector(void)
 {
-	rcu.detector_thr = 
+	rcu.detector_thr =
 		thread_create(detector, NULL, TASK, THREAD_FLAG_NONE, "rcu-det");
 	
-	if (!rcu.detector_thr) 
+	if (!rcu.detector_thr)
 		panic("Failed to create RCU detector thread.");
 	
@@ -479,9 +479,9 @@
 }
 
-/** Unlocks the local reader section using the given nesting count. 
- * 
- * Preemption or interrupts must be disabled. 
- * 
- * @param pnesting_cnt Either &CPU->rcu.tmp_nesting_cnt or 
+/** Unlocks the local reader section using the given nesting count.
+ *
+ * Preemption or interrupts must be disabled.
+ *
+ * @param pnesting_cnt Either &CPU->rcu.tmp_nesting_cnt or
  *           THREAD->rcu.nesting_cnt.
  */
@@ -493,9 +493,9 @@
 		_rcu_record_qs();
 		
-		/* 
-		 * The thread was preempted while in a critical section or 
-		 * the detector is eagerly waiting for this cpu's reader 
-		 * to finish. 
-		 * 
+		/*
+		 * The thread was preempted while in a critical section or
+		 * the detector is eagerly waiting for this cpu's reader
+		 * to finish.
+		 *
 		 * Note that THREAD may be NULL in scheduler() and not just during boot.
 		 */
@@ -518,5 +518,5 @@
 	 */
 	
-	/* 
+	/*
 	 * If the detector is eagerly waiting for this cpu's reader to unlock,
 	 * notify it that the reader did so.
@@ -566,5 +566,5 @@
 	assert(!rcu_read_locked());
 	
-	synch_item_t completion; 
+	synch_item_t completion;
 
 	waitq_initialize(&completion.wq);
@@ -584,5 +584,5 @@
 void rcu_barrier(void)
 {
-	/* 
+	/*
 	 * Serialize rcu_barrier() calls so we don't overwrite cpu.barrier_item
 	 * currently in use by rcu_barrier().
@@ -590,5 +590,5 @@
 	mutex_lock(&rcu.barrier_mtx);
 	
-	/* 
+	/*
 	 * Ensure we queue a barrier callback on all cpus before the already
 	 * enqueued barrier callbacks start signaling completion.
@@ -610,7 +610,7 @@
 }
 
-/** Issues a rcu_barrier() callback on the local cpu. 
- * 
- * Executed with interrupts disabled.  
+/** Issues a rcu_barrier() callback on the local cpu.
+ *
+ * Executed with interrupts disabled.
  */
 static void add_barrier_cb(void *arg)
@@ -631,8 +631,8 @@
 }
 
-/** Adds a callback to invoke after all preexisting readers finish. 
- * 
+/** Adds a callback to invoke after all preexisting readers finish.
+ *
  * May be called from within interrupt handlers or RCU reader sections.
- * 
+ *
  * @param rcu_item Used by RCU to track the call. Must remain
  *         until the user callback function is entered.
@@ -655,5 +655,5 @@
 
 /** rcu_call() inline-able implementation. See rcu_call() for comments. */
-static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item, 
+static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item,
 	rcu_func_t func)
 {
@@ -667,5 +667,5 @@
 	rcu_cpu_data_t *r = &CPU->rcu;
 
-	rcu_item_t **prev_tail 
+	rcu_item_t **prev_tail
 		= local_atomic_exchange(&r->parriving_cbs_tail, &rcu_item->next);
 	*prev_tail = rcu_item;
@@ -704,6 +704,6 @@
 {
 	assert(THREAD && THREAD->wired);
-	/* 
-	 * Accessing with interrupts enabled may at worst lead to 
+	/*
+	 * Accessing with interrupts enabled may at worst lead to
 	 * a false negative if we race with a local interrupt handler.
 	 */
@@ -740,5 +740,5 @@
 static bool wait_for_pending_cbs(void)
 {
-	if (!all_cbs_empty()) 
+	if (!all_cbs_empty())
 		return true;
 
@@ -772,14 +772,14 @@
 		if (exec_cnt < CRITICAL_THRESHOLD) {
 			exec_cbs(&CPU->rcu.cur_cbs);
-			exec_cbs(&CPU->rcu.next_cbs);	
+			exec_cbs(&CPU->rcu.next_cbs);
 		} else {
-			/* 
-			 * Getting overwhelmed with too many callbacks to run. 
-			 * Disable preemption in order to prolong our time slice 
+			/*
+			 * Getting overwhelmed with too many callbacks to run.
+			 * Disable preemption in order to prolong our time slice
 			 * and catch up with updaters posting new callbacks.
 			 */
 			preemption_disable();
 			exec_cbs(&CPU->rcu.cur_cbs);
-			exec_cbs(&CPU->rcu.next_cbs);	
+			exec_cbs(&CPU->rcu.next_cbs);
 			preemption_enable();
 		}
@@ -792,7 +792,7 @@
 			exec_cbs(&CPU->rcu.cur_cbs);
 		} else {
-			/* 
-			 * Getting overwhelmed with too many callbacks to run. 
-			 * Disable preemption in order to prolong our time slice 
+			/*
+			 * Getting overwhelmed with too many callbacks to run.
+			 * Disable preemption in order to prolong our time slice
 			 * and catch up with updaters posting new callbacks.
 			 */
@@ -828,5 +828,5 @@
 	CPU->rcu.stat_max_cbs = max(arriving_cnt, CPU->rcu.stat_max_cbs);
 	if (0 < arriving_cnt) {
-		CPU->rcu.stat_avg_cbs = 
+		CPU->rcu.stat_avg_cbs =
 			(99 * CPU->rcu.stat_avg_cbs + 1 * arriving_cnt) / 100;
 	}
@@ -834,5 +834,5 @@
 
 /** Prepares another batch of callbacks to dispatch at the nest grace period.
- * 
+ *
  * @return True if the next batch of callbacks must be expedited quickly.
  */
@@ -849,10 +849,10 @@
 	CPU->rcu.arriving_cbs_cnt = 0;
 	
-	/* 
+	/*
 	 * Too many callbacks queued. Better speed up the detection
 	 * or risk exhausting all system memory.
 	 */
 	bool expedite = (EXPEDITE_THRESHOLD < CPU->rcu.next_cbs_cnt)
-		|| CPU->rcu.expedite_arriving;	
+		|| CPU->rcu.expedite_arriving;
 	CPU->rcu.expedite_arriving = false;
 
@@ -860,5 +860,5 @@
 	CPU->rcu.next_cbs = CPU->rcu.arriving_cbs;
 	
-	/* 
+	/*
 	 * At least one callback arrived. The tail therefore does not point
 	 * to the head of arriving_cbs and we can safely reset it to NULL.
@@ -873,6 +873,6 @@
 		ACCESS_ONCE(CPU->rcu.parriving_cbs_tail) = &CPU->rcu.arriving_cbs;
 	} else {
-		/* 
-		 * arriving_cbs was null and parriving_cbs_tail pointed to it 
+		/*
+		 * arriving_cbs was null and parriving_cbs_tail pointed to it
 		 * so leave it that way. Note that interrupt handlers may have
 		 * added a callback in the meantime so it is not safe to reset
@@ -884,6 +884,6 @@
 	upd_stat_cb_cnts(CPU->rcu.next_cbs_cnt);
 	
-	/* 
-	 * Make changes prior to queuing next_cbs visible to readers. 
+	/*
+	 * Make changes prior to queuing next_cbs visible to readers.
 	 * See comment in wait_for_readers().
 	 */
@@ -898,8 +898,8 @@
 		CPU->rcu.next_cbs_gp = _rcu_cur_gp + 1;
 		
-		/* 
+		/*
 		 * There are no callbacks to invoke before next_cbs. Instruct
 		 * wait_for_cur_cbs_gp() to notify us of the nearest GP end.
-		 * That could be sooner than next_cbs_gp (if the current GP 
+		 * That could be sooner than next_cbs_gp (if the current GP
 		 * had not yet completed), so we'll create a shorter batch
 		 * of callbacks next time around.
@@ -907,5 +907,5 @@
 		if (cur_cbs_empty()) {
 			CPU->rcu.cur_cbs_gp = rcu.completed_gp + 1;
-		} 
+		}
 		
 		spinlock_unlock(&rcu.gp_lock);
@@ -916,5 +916,5 @@
 	assert(CPU->rcu.cur_cbs_gp <= CPU->rcu.next_cbs_gp);
 	
-	return expedite;	
+	return expedite;
 }
 
@@ -922,9 +922,9 @@
 #ifdef RCU_PREEMPT_A
 
-/** Waits for the grace period associated with callbacks cub_cbs to elapse. 
- * 
- * @param expedite Instructs the detector to aggressively speed up grace 
+/** Waits for the grace period associated with callbacks cub_cbs to elapse.
+ *
+ * @param expedite Instructs the detector to aggressively speed up grace
  *            period detection without any delay.
- * @param completed_gp Returns the most recent completed grace period 
+ * @param completed_gp Returns the most recent completed grace period
  *            number.
  * @return false if the thread was interrupted and should stop.
@@ -951,16 +951,16 @@
 			condvar_broadcast(&rcu.gp_ended);
 		} else {
-			/* GP detection is in progress.*/ 
+			/* GP detection is in progress.*/
 			
-			if (expedite) 
+			if (expedite)
 				condvar_signal(&rcu.expedite_now);
 			
 			/* Wait for the GP to complete. */
-			errno_t ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock, 
+			errno_t ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
 				SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
 			
 			if (ret == EINTR) {
 				spinlock_unlock(&rcu.gp_lock);
-				return false;			
+				return false;
 			}
 		}
@@ -984,5 +984,5 @@
 	while (!cpu_mask_is_none(reader_cpus)) {
 		/* Give cpus a chance to context switch (a QS) and batch callbacks. */
-		if(!gp_sleep(&expedite)) 
+		if(!gp_sleep(&expedite))
 			return false;
 		
@@ -996,5 +996,5 @@
 	}
 	
-	/* 
+	/*
 	 * All cpus have passed through a QS and see the most recent _rcu_cur_gp.
 	 * As a result newly preempted readers will associate with next_preempted
@@ -1038,5 +1038,5 @@
 		
 	if (locked && !passed_qs) {
-		/* 
+		/*
 		 * This cpu has not yet passed a quiescent state during this grace
 		 * period and it is currently in a reader section. We'll have to
@@ -1057,11 +1057,11 @@
 	assert(interrupts_disabled());
 
-	/* 
-	 * In order not to worry about NMI seeing rcu_nesting change work 
+	/*
+	 * In order not to worry about NMI seeing rcu_nesting change work
 	 * with a local copy.
 	 */
 	size_t nesting_cnt = local_atomic_exchange(&THE->rcu_nesting, 0);
 	
-	/* 
+	/*
 	 * Ensures NMIs see .rcu_nesting without the WAS_PREEMPTED mark and
 	 * do not accidentally call rm_preempted_reader() from unlock().
@@ -1079,20 +1079,20 @@
 
 	if (CPU->rcu.last_seen_gp != _rcu_cur_gp) {
-		/* 
-		 * Contain any memory accesses of old readers before announcing a QS. 
+		/*
+		 * Contain any memory accesses of old readers before announcing a QS.
 		 * Also make changes from the previous GP visible to this cpu.
-		 * Moreover it separates writing to last_seen_gp from 
+		 * Moreover it separates writing to last_seen_gp from
 		 * note_preempted_reader().
 		 */
 		memory_barrier();
-		/* 
+		/*
 		 * The preempted reader has been noted globally. There are therefore
 		 * no readers running on this cpu so this is a quiescent state.
-		 * 
-		 * Reading the multiword _rcu_cur_gp non-atomically is benign. 
+		 *
+		 * Reading the multiword _rcu_cur_gp non-atomically is benign.
 		 * At worst, the read value will be different from the actual value.
 		 * As a result, both the detector and this cpu will believe
 		 * this cpu has not yet passed a QS although it really did.
-		 * 
+		 *
 		 * Reloading _rcu_cur_gp is benign, because it cannot change
 		 * until this cpu acknowledges it passed a QS by writing to
@@ -1103,5 +1103,5 @@
 	}
 
-	/* 
+	/*
 	 * Forcefully associate the reclaimer with the highest priority
 	 * even if preempted due to its time slice running out.
@@ -1109,5 +1109,5 @@
 	if (THREAD == CPU->rcu.reclaimer_thr) {
 		THREAD->priority = -1;
-	} 
+	}
 	
 	upd_max_cbs_in_slice(CPU->rcu.arriving_cbs_cnt);
@@ -1123,6 +1123,6 @@
 }
 
-/** Called from scheduler() when exiting the current thread. 
- * 
+/** Called from scheduler() when exiting the current thread.
+ *
  * Preemption or interrupts are disabled and the scheduler() already
  * switched away from the current thread, calling rcu_after_thread_ran().
@@ -1132,8 +1132,8 @@
 	assert(THE->rcu_nesting == 0);
 	
-	/* 
-	 * The thread forgot to exit its reader critical section. 
+	/*
+	 * The thread forgot to exit its reader critical section.
 	 * It is a bug, but rather than letting the entire system lock up
-	 * forcefully leave the reader section. The thread is not holding 
+	 * forcefully leave the reader section. The thread is not holding
 	 * any references anyway since it is exiting so it is safe.
 	 */
@@ -1162,5 +1162,5 @@
 	size_t prev = local_atomic_exchange(&THE->rcu_nesting, 0);
 	if (prev == RCU_WAS_PREEMPTED) {
-		/* 
+		/*
 		 * NMI handlers are never preempted but may call rm_preempted_reader()
 		 * if a NMI occurred in _rcu_preempted_unlock() of a preempted thread.
@@ -1168,5 +1168,5 @@
 		 * in _rcu_preempted_unlock() is: an IPI/sample_local_cpu() and
 		 * the initial part of rcu_after_thread_ran().
-		 * 
+		 *
 		 * rm_preempted_reader() will not deadlock because none of the locks
 		 * it uses are locked in this case. Neither _rcu_preempted_unlock()
@@ -1180,9 +1180,9 @@
 #elif defined(RCU_PREEMPT_PODZIMEK)
 
-/** Waits for the grace period associated with callbacks cub_cbs to elapse. 
- * 
- * @param expedite Instructs the detector to aggressively speed up grace 
+/** Waits for the grace period associated with callbacks cub_cbs to elapse.
+ *
+ * @param expedite Instructs the detector to aggressively speed up grace
  *            period detection without any delay.
- * @param completed_gp Returns the most recent completed grace period 
+ * @param completed_gp Returns the most recent completed grace period
  *            number.
  * @return false if the thread was interrupted and should stop.
@@ -1190,22 +1190,22 @@
 static bool wait_for_cur_cbs_gp_end(bool expedite, rcu_gp_t *completed_gp)
 {
-	/* 
+	/*
 	 * Use a possibly outdated version of completed_gp to bypass checking
 	 * with the lock.
-	 * 
-	 * Note that loading and storing rcu.completed_gp is not atomic 
-	 * (it is 64bit wide). Reading a clobbered value that is less than 
-	 * rcu.completed_gp is harmless - we'll recheck with a lock. The 
-	 * only way to read a clobbered value that is greater than the actual 
-	 * value is if the detector increases the higher-order word first and 
-	 * then decreases the lower-order word (or we see stores in that order), 
-	 * eg when incrementing from 2^32 - 1 to 2^32. The loaded value 
-	 * suddenly jumps by 2^32. It would take hours for such an increase 
-	 * to occur so it is safe to discard the value. We allow increases 
+	 *
+	 * Note that loading and storing rcu.completed_gp is not atomic
+	 * (it is 64bit wide). Reading a clobbered value that is less than
+	 * rcu.completed_gp is harmless - we'll recheck with a lock. The
+	 * only way to read a clobbered value that is greater than the actual
+	 * value is if the detector increases the higher-order word first and
+	 * then decreases the lower-order word (or we see stores in that order),
+	 * eg when incrementing from 2^32 - 1 to 2^32. The loaded value
+	 * suddenly jumps by 2^32. It would take hours for such an increase
+	 * to occur so it is safe to discard the value. We allow increases
 	 * of up to half the maximum to generously accommodate for loading an
 	 * outdated lower word.
 	 */
 	rcu_gp_t compl_gp = ACCESS_ONCE(rcu.completed_gp);
-	if (CPU->rcu.cur_cbs_gp <= compl_gp 
+	if (CPU->rcu.cur_cbs_gp <= compl_gp
 		&& compl_gp <= CPU->rcu.cur_cbs_gp + UINT32_MAX_HALF) {
 		*completed_gp = compl_gp;
@@ -1224,6 +1224,6 @@
 	assert(_rcu_cur_gp <= CPU->rcu.cur_cbs_gp);
 	
-	/* 
-	 * Notify the detector of how many GP ends we intend to wait for, so 
+	/*
+	 * Notify the detector of how many GP ends we intend to wait for, so
 	 * it can avoid going to sleep unnecessarily. Optimistically assume
 	 * new callbacks will arrive while we're waiting; hence +1.
@@ -1232,14 +1232,14 @@
 	req_detection(remaining_gp_ends + (arriving_cbs_empty() ? 0 : 1));
 	
-	/* 
-	 * Ask the detector to speed up GP detection if there are too many 
+	/*
+	 * Ask the detector to speed up GP detection if there are too many
 	 * pending callbacks and other reclaimers have not already done so.
 	 */
 	if (expedite) {
-		if(0 == rcu.req_expedited_cnt) 
+		if(0 == rcu.req_expedited_cnt)
 			condvar_signal(&rcu.expedite_now);
 		
-		/* 
-		 * Expedite only cub_cbs. If there really is a surge of callbacks 
+		/*
+		 * Expedite only cub_cbs. If there really is a surge of callbacks
 		 * the arriving batch will expedite the GP for the huge number
 		 * of callbacks currently in next_cbs
@@ -1252,5 +1252,5 @@
 	
 	*completed_gp = rcu.completed_gp;
-	spinlock_unlock(&rcu.gp_lock);	
+	spinlock_unlock(&rcu.gp_lock);
 	
 	if (!interrupted)
@@ -1269,5 +1269,5 @@
 	/* Wait until wait_on_gp ends. */
 	while (rcu.completed_gp < wait_on_gp && !interrupted) {
-		int ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock, 
+		int ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
 			SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
 		interrupted = (ret == EINTR);
@@ -1298,5 +1298,5 @@
 	
 	while (wait_for_detect_req()) {
-		/* 
+		/*
 		 * Announce new GP started. Readers start lazily acknowledging that
 		 * they passed a QS.
@@ -1306,5 +1306,5 @@
 		spinlock_unlock(&rcu.gp_lock);
 		
-		if (!wait_for_readers()) 
+		if (!wait_for_readers())
 			goto unlocked_out;
 		
@@ -1329,5 +1329,5 @@
 	
 	while (0 == rcu.req_gp_end_cnt && !interrupted) {
-		int ret = _condvar_wait_timeout_spinlock(&rcu.req_gp_changed, 
+		int ret = _condvar_wait_timeout_spinlock(&rcu.req_gp_changed,
 			&rcu.gp_lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
 		
@@ -1357,6 +1357,6 @@
 	cpu_mask_active(reading_cpus);
 
-	/* 
-	 * Give readers time to pass through a QS. Also, batch arriving 
+	/*
+	 * Give readers time to pass through a QS. Also, batch arriving
 	 * callbacks in order to amortize detection overhead.
 	 */
@@ -1417,7 +1417,7 @@
 }
 
-/** Invoked on a cpu delaying grace period detection. 
- * 
- * Induces a quiescent state for the cpu or it instructs remaining 
+/** Invoked on a cpu delaying grace period detection.
+ *
+ * Induces a quiescent state for the cpu or it instructs remaining
  * readers to notify the detector once they finish.
  */
@@ -1432,7 +1432,7 @@
 		if (0 < CPU->rcu.nesting_cnt) {
 			assert(!CPU->idle);
-			/* 
-			 * Note to notify the detector from rcu_read_unlock(). 
-			 * 
+			/*
+			 * Note to notify the detector from rcu_read_unlock().
+			 *
 			 * ACCESS_ONCE ensures the compiler writes to is_delaying_gp
 			 * only after it determines that we are in a reader CS.
@@ -1443,13 +1443,13 @@
 			atomic_inc(&rcu.delaying_cpu_cnt);
 		} else {
-			/* 
-			 * The cpu did not enter any rcu reader sections since 
+			/*
+			 * The cpu did not enter any rcu reader sections since
 			 * the start of the current GP. Record a quiescent state.
-			 * 
+			 *
 			 * Or, we interrupted rcu_read_unlock_impl() right before
-			 * it recorded a QS. Record a QS for it. The memory barrier 
-			 * contains the reader section's mem accesses before 
+			 * it recorded a QS. Record a QS for it. The memory barrier
+			 * contains the reader section's mem accesses before
 			 * updating last_seen_gp.
-			 * 
+			 *
 			 * Or, we interrupted rcu_read_lock() right after it recorded
 			 * a QS for the previous GP but before it got a chance to
@@ -1461,11 +1461,11 @@
 		}
 	} else {
-		/* 
-		 * This cpu already acknowledged that it had passed through 
-		 * a quiescent state since the start of cur_gp. 
+		/*
+		 * This cpu already acknowledged that it had passed through
+		 * a quiescent state since the start of cur_gp.
 		 */
 	}
 	
-	/* 
+	/*
 	 * smp_call() makes sure any changes propagate back to the caller.
 	 * In particular, it makes the most current last_seen_gp visible
@@ -1495,12 +1495,12 @@
 	assert(interrupts_disabled());
 
-	/* 
+	/*
 	 * Prevent NMI handlers from interfering. The detector will be notified
-	 * in this function if CPU->rcu.is_delaying_gp. The current thread is 
+	 * in this function if CPU->rcu.is_delaying_gp. The current thread is
 	 * no longer running so there is nothing else to signal to the detector.
 	 */
 	CPU->rcu.signal_unlock = false;
-	/* 
-	 * Separates clearing of .signal_unlock from accesses to 
+	/*
+	 * Separates clearing of .signal_unlock from accesses to
 	 * THREAD->rcu.was_preempted and CPU->rcu.nesting_cnt.
 	 */
@@ -1516,5 +1516,5 @@
 	}
 	
-	/* 
+	/*
 	 * The preempted reader has been noted globally. There are therefore
 	 * no readers running on this cpu so this is a quiescent state.
@@ -1522,16 +1522,16 @@
 	_rcu_record_qs();
 
-	/* 
-	 * Interrupt handlers might use RCU while idle in scheduler(). 
-	 * The preempted reader has been noted globally, so the handlers 
+	/*
+	 * Interrupt handlers might use RCU while idle in scheduler().
+	 * The preempted reader has been noted globally, so the handlers
 	 * may now start announcing quiescent states.
 	 */
 	CPU->rcu.nesting_cnt = 0;
 	
-	/* 
-	 * This cpu is holding up the current GP. Let the detector know 
-	 * it has just passed a quiescent state. 
-	 * 
-	 * The detector waits separately for preempted readers, so we have 
+	/*
+	 * This cpu is holding up the current GP. Let the detector know
+	 * it has just passed a quiescent state.
+	 *
+	 * The detector waits separately for preempted readers, so we have
 	 * to notify the detector even if we have just preempted a reader.
 	 */
@@ -1541,16 +1541,16 @@
 	}
 
-	/* 
+	/*
 	 * Forcefully associate the detector with the highest priority
 	 * even if preempted due to its time slice running out.
-	 * 
+	 *
 	 * todo: Replace with strict scheduler priority classes.
 	 */
 	if (THREAD == rcu.detector_thr) {
 		THREAD->priority = -1;
-	} 
+	}
 	else if (THREAD == CPU->rcu.reclaimer_thr) {
 		THREAD->priority = -1;
-	} 
+	}
 	
 	upd_max_cbs_in_slice(CPU->rcu.arriving_cbs_cnt);
@@ -1566,5 +1566,5 @@
 	CPU->rcu.nesting_cnt = THREAD->rcu.nesting_cnt;
 	
-	/* 
+	/*
 	 * Ensures NMI see the proper nesting count before .signal_unlock.
 	 * Otherwise the NMI may incorrectly signal that a preempted reader
@@ -1573,10 +1573,10 @@
 	compiler_barrier();
 	
-	/* 
-	 * In the unlikely event that a NMI occurs between the loading of the 
-	 * variables and setting signal_unlock, the NMI handler may invoke 
+	/*
+	 * In the unlikely event that a NMI occurs between the loading of the
+	 * variables and setting signal_unlock, the NMI handler may invoke
 	 * rcu_read_unlock() and clear signal_unlock. In that case we will
 	 * incorrectly overwrite signal_unlock from false to true. This event
-	 * is benign and the next rcu_read_unlock() will at worst 
+	 * is benign and the next rcu_read_unlock() will at worst
 	 * needlessly invoke _rcu_signal_unlock().
 	 */
@@ -1584,6 +1584,6 @@
 }
 
-/** Called from scheduler() when exiting the current thread. 
- * 
+/** Called from scheduler() when exiting the current thread.
+ *
  * Preemption or interrupts are disabled and the scheduler() already
  * switched away from the current thread, calling rcu_after_thread_ran().
@@ -1595,8 +1595,8 @@
 	assert(PREEMPTION_DISABLED || interrupts_disabled());
 	
-	/* 
-	 * The thread forgot to exit its reader critical section. 
+	/*
+	 * The thread forgot to exit its reader critical section.
 	 * It is a bug, but rather than letting the entire system lock up
-	 * forcefully leave the reader section. The thread is not holding 
+	 * forcefully leave the reader section. The thread is not holding
 	 * any references anyway since it is exiting so it is safe.
 	 */
@@ -1623,11 +1623,11 @@
 	++_rcu_cur_gp;
 	
-	/* 
+	/*
 	 * Readers preempted before the start of this GP (next_preempted)
-	 * are preexisting readers now that a GP started and will hold up 
+	 * are preexisting readers now that a GP started and will hold up
 	 * the current GP until they exit their reader sections.
-	 * 
-	 * Preempted readers from the previous GP have finished so 
-	 * cur_preempted is empty, but see comment in _rcu_record_qs(). 
+	 *
+	 * Preempted readers from the previous GP have finished so
+	 * cur_preempted is empty, but see comment in _rcu_record_qs().
 	 */
 	list_concat(&rcu.cur_preempted, &rcu.next_preempted);
@@ -1642,8 +1642,8 @@
 {
 	/*
-	 * Ensure the announcement of the start of a new GP (ie up-to-date 
-	 * cur_gp) propagates to cpus that are just coming out of idle 
+	 * Ensure the announcement of the start of a new GP (ie up-to-date
+	 * cur_gp) propagates to cpus that are just coming out of idle
 	 * mode before we sample their idle state flag.
-	 * 
+	 *
 	 * Cpus guarantee that after they set CPU->idle = true they will not
 	 * execute any RCU reader sections without first setting idle to
@@ -1660,33 +1660,33 @@
 	 * on the previously idle cpu -- again thanks to issuing a memory
 	 * barrier after returning from idle mode.
-	 * 
+	 *
 	 * idle -> non-idle cpu      | detector      | reclaimer
 	 * ------------------------------------------------------
 	 * rcu reader 1              |               | rcu_call()
 	 * MB X                      |               |
-	 * idle = true               |               | rcu_call() 
-	 * (no rcu readers allowed ) |               | MB A in advance_cbs() 
+	 * idle = true               |               | rcu_call()
+	 * (no rcu readers allowed ) |               | MB A in advance_cbs()
 	 * MB Y                      | (...)         | (...)
-	 * (no rcu readers allowed)  |               | MB B in advance_cbs() 
+	 * (no rcu readers allowed)  |               | MB B in advance_cbs()
 	 * idle = false              | ++cur_gp      |
 	 * (no rcu readers allowed)  | MB C          |
 	 * MB Z                      | signal gp_end |
 	 * rcu reader 2              |               | exec_cur_cbs()
-	 * 
-	 * 
+	 *
+	 *
 	 * MB Y orders visibility of changes to idle for detector's sake.
-	 * 
-	 * MB Z pairs up with MB C. The cpu making a transition from idle 
+	 *
+	 * MB Z pairs up with MB C. The cpu making a transition from idle
 	 * will see the most current value of cur_gp and will not attempt
 	 * to notify the detector even if preempted during this GP.
-	 * 
+	 *
 	 * MB Z pairs up with MB A from the previous batch. Updaters' changes
-	 * are visible to reader 2 even when the detector thinks the cpu is idle 
+	 * are visible to reader 2 even when the detector thinks the cpu is idle
 	 * but it is not anymore.
-	 * 
+	 *
 	 * MB X pairs up with MB B. Late mem accesses of reader 1 are contained
-	 * and visible before idling and before any callbacks are executed 
+	 * and visible before idling and before any callbacks are executed
 	 * by reclaimers.
-	 * 
+	 *
 	 * In summary, the detector does not know of or wait for reader 2, but
 	 * it does not have to since it is a new reader that will not access
@@ -1696,13 +1696,13 @@
 	
 	cpu_mask_for_each(*cpu_mask, cpu_id) {
-		/* 
-		 * The cpu already checked for and passed through a quiescent 
+		/*
+		 * The cpu already checked for and passed through a quiescent
 		 * state since the beginning of this GP.
-		 * 
-		 * _rcu_cur_gp is modified by local detector thread only. 
-		 * Therefore, it is up-to-date even without a lock. 
-		 * 
+		 *
+		 * _rcu_cur_gp is modified by local detector thread only.
+		 * Therefore, it is up-to-date even without a lock.
+		 *
 		 * cpu.last_seen_gp may not be up-to-date. At worst, we will
-		 * unnecessarily sample its last_seen_gp with a smp_call. 
+		 * unnecessarily sample its last_seen_gp with a smp_call.
 		 */
 		bool cpu_acked_gp = (cpus[cpu_id].rcu.last_seen_gp == _rcu_cur_gp);
@@ -1750,5 +1750,5 @@
 		list_append(&THREAD->rcu.preempt_link, &rcu.cur_preempted);
 	} else {
-		/* 
+		/*
 		 * The reader started after the GP started and this cpu
 		 * already noted a quiescent state. We might block the next GP.
@@ -1774,7 +1774,7 @@
 	bool last_removed = now_empty && !prev_empty;
 
-	/* 
-	 * Preempted readers are blocking the detector and 
-	 * this was the last reader blocking the current GP. 
+	/*
+	 * Preempted readers are blocking the detector and
+	 * this was the last reader blocking the current GP.
 	 */
 	if (last_removed && rcu.preempt_blocking_det) {
@@ -1801,5 +1801,5 @@
 		
 		return semaphore_down_interruptable(&rcu.remaining_readers);
-	} 	
+	}
 	
 	return true;
@@ -1821,7 +1821,7 @@
 void rcu_print_stat(void)
 {
-	/* 
-	 * Don't take locks. Worst case is we get out-dated values. 
-	 * CPU local values are updated without any locks, so there 
+	/*
+	 * Don't take locks. Worst case is we get out-dated values.
+	 * CPU local values are updated without any locks, so there
 	 * are no locks to lock in order to get up-to-date values.
 	 */
@@ -1834,9 +1834,9 @@
 	
 	printf("Config: expedite_threshold=%d, critical_threshold=%d,"
-		" detect_sleep=%dms, %s\n",	
+		" detect_sleep=%dms, %s\n",
 		EXPEDITE_THRESHOLD, CRITICAL_THRESHOLD, DETECT_SLEEP_MS, algo);
 	printf("Completed GPs: %" PRIu64 "\n", rcu.completed_gp);
 	printf("Expedited GPs: %zu\n", rcu.stat_expedited_cnt);
-	printf("Delayed GPs:   %zu (cpus w/ still running readers after gp sleep)\n", 
+	printf("Delayed GPs:   %zu (cpus w/ still running readers after gp sleep)\n",
 		rcu.stat_delayed_cnt);
 	printf("Preempt blocked GPs: %zu (waited for preempted readers; "
