Re: [tip:core/rcu] rcu: Remove inline from forward-referencedfunctions

From: Paul E. McKenney
Date: Wed Nov 11 2009 - 00:41:42 EST


On Tue, Nov 10, 2009 at 08:50:13PM -0800, Paul E. McKenney wrote:
> On Tue, Nov 10, 2009 at 07:28:28PM -0800, Joe Perches wrote:
> > On Tue, 2009-11-10 at 17:42 -0800, Paul E. McKenney wrote:
> > > On Tue, Nov 10, 2009 at 05:03:41PM -0800, Joe Perches wrote:
> > > > So maybe rename rcutree_plugin.h to rcutree_plugin.c and
> > > > #include "rcutree_plugin.c" in rcutree.c instead.
> > > Hmmm...
> >
> > Perhaps something like this:
>
> While I do very much appreciate your time and attention to this...
>
> My problem with this sort of thing is that when I tried it, it proved
> fragile. Small changes required lots of rework of forward declarations.
> Putting it at the end makes it work very nicely -- the list of forward
> declarations doubles as documentation for the plugins, and the contents
> of kernel/rcutree_plugin.h (or .c or whatever, either way I end up
> violation about the same number of coding guidelines) is independent of
> rearrangements of kernel/rcutree.c.
>
> The reason that I would really like to keep rcu_bootup_announce() as
> a function is that it makes it trivial to collect RCU-flavor-dependent
> boot-time information, if needed for some debugging effort. If I pull
> the string out, this sort of thing becomes much more painful.

And, as noted in our offline conversation, you are absolutely right
that I need to add __init to both definitions of rcu_bootup_announce(),
which I will do, with your Suggested-by.

Fair enough?

Thanx, Paul

> > cheers, Joe
> >
> > rcu: rename rcutree_plugin.h to .c and use
> >
> > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > index d802419..737dc72 100644
> > --- a/kernel/rcutree.c
> > +++ b/kernel/rcutree.c
> > @@ -1783,6 +1783,8 @@ do { \
> > } \
> > } while (0)
> >
> > +#include "rcutree_plugin.c"
> > +
> > void __init __rcu_init(void)
> > {
> > rcu_bootup_announce();
> > @@ -1795,4 +1797,3 @@ void __init __rcu_init(void)
> > open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
> > }
> >
> > -#include "rcutree_plugin.h"
> > diff --git a/kernel/rcutree.h b/kernel/rcutree.h
> > index 17a28a0..ed11d16 100644
> > --- a/kernel/rcutree.h
> > +++ b/kernel/rcutree.h
> > @@ -300,8 +300,7 @@ DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
> >
> > #else /* #ifdef RCU_TREE_NONCORE */
> >
> > -/* Forward declarations for rcutree_plugin.h */
> > -static void rcu_bootup_announce(void);
> > +/* Forward declarations for rcutree_plugin.c */
> > long rcu_batches_completed(void);
> > static void rcu_preempt_note_context_switch(int cpu);
> > static int rcu_preempted_readers(struct rcu_node *rnp);
> > diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.c
> > similarity index 99%
> > rename from kernel/rcutree_plugin.h
> > rename to kernel/rcutree_plugin.c
> > index 52075da..5ca2d26 100644
> > --- a/kernel/rcutree_plugin.h
> > +++ b/kernel/rcutree_plugin.c
> > @@ -33,7 +33,7 @@ DEFINE_PER_CPU(struct rcu_data, rcu_preempt_data);
> > /*
> > * Tell them what RCU they are running.
> > */
> > -static void rcu_bootup_announce(void)
> > +static void __init rcu_bootup_announce(void)
> > {
> > printk(KERN_INFO
> > "Experimental preemptable hierarchical RCU implementation.\n");
> > @@ -481,7 +481,7 @@ void exit_rcu(void)
> > /*
> > * Tell them what RCU they are running.
> > */
> > -static void rcu_bootup_announce(void)
> > +static void __init rcu_bootup_announce(void)
> > {
> > printk(KERN_INFO "Hierarchical RCU implementation.\n");
> > }
> >
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/