> >> +/**
> >> + * kfree_rcu - free previously allocated memory after a grace period.
> >> + * @ptr: pointer returned by kmalloc.
> >> + * @head: structure to be used for queueing the RCU updates. This structure
> >> + * is a part of previously allocated memory @ptr.
> >> + */
> >> +extern void kfree_rcu(const void *ptr, struct rcu_head *head);
> >> +
> >> #endif /* __LINUX_RCUPDATE_H */
> >> diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
> >> index aad93cd..5a14190 100644
> >> --- a/kernel/rcuclassic.c
> >> +++ b/kernel/rcuclassic.c
> >> @@ -232,7 +232,7 @@ static void rcu_do_batch(struct rcu_data *rdp)
> >> while (list) {
> >> next = list->next;
> >> prefetch(next);
> >> - list->func(list);
> >> + __rcu_reclaim(list);
> >
> > OK, consistent with above.
> >
> >> list = next;
> >> if (++count >= rdp->blimit)
> >> break;
> >> diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
> >> index 467d594..aa9b56a 100644
> >> --- a/kernel/rcupdate.c
> >> +++ b/kernel/rcupdate.c
> >> @@ -162,6 +162,18 @@ void rcu_barrier_sched(void)
> >> }
> >> EXPORT_SYMBOL_GPL(rcu_barrier_sched);
> >>
> >> +void kfree_rcu(const void *ptr, struct rcu_head *head)
> >> +{
> >> + unsigned long offset;
> >> + typedef void (*rcu_callback)(struct rcu_head *);
> >> +
> >> + offset = (void *)head - (void *)ptr;
> >> + BUG_ON(offset > KFREE_RCU_MAX_OFFSET);
> >> +
> >> + call_rcu(head, (rcu_callback)(offset / sizeof(void *)));
> >
> > OK, so we pass in the pointer to the rcu_head structure, followed
> > by the offset in pointer-sized units, but with the latter cast to
> > a pointer to a callback function? Hmmm.... Kinky....
> >
> > Then after the grace period completes, the __rcu_reclaim() sorts
> > things out.
>
> Yes, kernel pointers have redundant information, we use the low 4k
> as offset. when ->func < 4k, it stand for offset, when ->func >= 4k,
> it stand for function pointer.
>
> >
> >> +}
> >> +EXPORT_SYMBOL_GPL(kfree_rcu);
> >> +
> >> void __init rcu_init(void)
> >> {
> >> __rcu_init();
> >> diff --git a/kernel/rcupreempt.c b/kernel/rcupreempt.c
> >> index 2782793..62a9e54 100644
> >> --- a/kernel/rcupreempt.c
> >> +++ b/kernel/rcupreempt.c
> >> @@ -1108,7 +1108,7 @@ static void rcu_process_callbacks(struct softirq_action *unused)
> >> spin_unlock_irqrestore(&rdp->lock, flags);
> >> while (list) {
> >> next = list->next;
> >> - list->func(list);
> >> + __rcu_reclaim(list);
> >
> > And we do this for preemptable RCU as well.
> >
> >> list = next;
> >> RCU_TRACE_ME(rcupreempt_trace_invoke);
> >> }
> >>
> > --
> > 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/
> >
> >
> >
>
>