List:       linux-kernel
Subject:    [PATCH] Preemptible Read-Copy Update
From:       Dipankar Sarma <dipankar () in ! ibm ! com>
Date:       2002-05-08 9:33:49

Read-Copy Update depends on tasks losing local reference to 
RCU protected data during context switches. That is not
guaranteed in a preemptible kernel environment. So, I modified
RCU to work correctly in both preemptible and non-preemptible
kernel environments.

Based on Andrea's suggestion, I have introduced a separate
interface for preemptible RCU - call_rcu_preempt(). 
Existing call_rcu() interface requires that you disable preemption
during read-side of the RCU protected data. With call_rcu_preempt(),
that is not required. It transparently takes care of detecting
the grace period despite existence of preempted tasks. Andrea's
point was that we could have kernel daemons who may do -

#ifndef CONFIG_PREEMPT
	schedule();
#else
	continue to do stuff inside the kernel
#endif

This may result in very large RCU grace periods thereby increasing
memory pressure. So for things like synchronize_kernel() which
aren't concerned about latency (when used with module unloading
or cpu hotplug), call_rcu_preempt() can be used. For anything
else that care about latency, preemption should be disabled
during the read-side and call_rcu() should be used.

Preemptible RCU uses a pair of per-CPU counters to keep
track of preempted tasks. The pair is used as a cyclical
queue. While one counts the number of tasks preempted
in that cpu before the start of the current grace period,
the other counts the same after the start of the current
grace period. At the end of every grace period, the counters
are switched. A preempted task may migrate to another CPU, so
we keep track of the original counter whose reference it held
in a per-task counter pointer. When such a task undergoes
a voluntary context switch or exits, the reference is decremented.
For a grace period to end, each cpus current preempt conter
must be zero.

Note: rcu_preempt_put() needs to be done more aggressively by
detecting transition to user level or user level itself.

The included patch is based on rcu_poll which is in
2.4.x-aa series of kernels.

Comments/suggestions are welcome.

Thanks
-- 
Dipankar Sarma  <dipankar@in.ibm.com> http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.


Patch

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/