diff mbox

[1/2] rcu: export rcu_note_context_switch() function

Message ID 1303984323-3203-2-git-send-email-gleb@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gleb Natapov April 28, 2011, 9:52 a.m. UTC
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 include/linux/rcutiny.h |    6 +-----
 kernel/rcutiny.c        |    7 +++++++
 kernel/rcutree.c        |    1 +
 3 files changed, 9 insertions(+), 5 deletions(-)

Comments

Avi Kivity April 28, 2011, 10:01 a.m. UTC | #1
On 04/28/2011 12:52 PM, Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov<gleb@redhat.com>
> @@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
>
>   #endif /* #else #ifdef CONFIG_TINY_RCU */
>
> -static inline void rcu_note_context_switch(int cpu)
> -{
> -	rcu_sched_qs(cpu);
> -	rcu_preempt_note_context_switch();
> -}
> +extern void rcu_note_context_switch(int cpu);
>

Why are you uninlining this function?  Why not export the two functions 
it calls instead?
Gleb Natapov April 28, 2011, 10:11 a.m. UTC | #2
On Thu, Apr 28, 2011 at 01:01:04PM +0300, Avi Kivity wrote:
> On 04/28/2011 12:52 PM, Gleb Natapov wrote:
> >Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >@@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
> >
> >  #endif /* #else #ifdef CONFIG_TINY_RCU */
> >
> >-static inline void rcu_note_context_switch(int cpu)
> >-{
> >-	rcu_sched_qs(cpu);
> >-	rcu_preempt_note_context_switch();
> >-}
> >+extern void rcu_note_context_switch(int cpu);
> >
> 
> Why are you uninlining this function?  Why not export the two
> functions it calls instead?
> 
To keep exported interface uniformal between both rcu implementations.
I do not think that rcu_note_context_switch() is inlined for
performance reason since two functions it calls are quite big in rcutiny
implementation. Paul what do you think?
 
--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul E. McKenney April 29, 2011, 8:36 a.m. UTC | #3
On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:

Hmmm....  This is interesting.  KVM being a module, we either expand
TINY_RCU's size a bit by making rcu_note_context_switch() be a real
function in rcutiny.c and adding an export, or we expand it by adding
two exports.

I would like to solve this without making TINY_RCU larger, and preferably
by making it smaller.  Any ideas come to mind?  (Other than making
KVM depend on CONFIG_SMP, which sounds too much like throwing out the
baby with the bathwater.)

							Thanx, Paul

> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  include/linux/rcutiny.h |    6 +-----
>  kernel/rcutiny.c        |    7 +++++++
>  kernel/rcutree.c        |    1 +
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
> index 30ebd7c..8e5f7cf 100644
> --- a/include/linux/rcutiny.h
> +++ b/include/linux/rcutiny.h
> @@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
> 
>  #endif /* #else #ifdef CONFIG_TINY_RCU */
> 
> -static inline void rcu_note_context_switch(int cpu)
> -{
> -	rcu_sched_qs(cpu);
> -	rcu_preempt_note_context_switch();
> -}
> +extern void rcu_note_context_switch(int cpu);
> 
>  /*
>   * Return the number of grace periods.
> diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
> index 0c343b9..3d715a4 100644
> --- a/kernel/rcutiny.c
> +++ b/kernel/rcutiny.c
> @@ -78,6 +78,13 @@ void rcu_exit_nohz(void)
> 
>  #endif /* #ifdef CONFIG_NO_HZ */
> 
> +void rcu_note_context_switch(int cpu)
> +{
> +	rcu_sched_qs(cpu);
> +	rcu_preempt_note_context_switch();
> +}
> +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> +
>  /*
>   * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc().
>   * Also disable irqs to avoid confusion due to interrupt handlers
> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> index dd4aea8..0837d63 100644
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
> @@ -124,6 +124,7 @@ void rcu_note_context_switch(int cpu)
>  	rcu_sched_qs(cpu);
>  	rcu_preempt_note_context_switch(cpu);
>  }
> +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> 
>  #ifdef CONFIG_NO_HZ
>  DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
> -- 
> 1.7.2.3
> 
> --
> 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/
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul E. McKenney April 29, 2011, 8:39 a.m. UTC | #4
On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> 
> Hmmm....  This is interesting.  KVM being a module, we either expand
> TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> function in rcutiny.c and adding an export, or we expand it by adding
> two exports.
> 
> I would like to solve this without making TINY_RCU larger, and preferably
> by making it smaller.  Any ideas come to mind?  (Other than making
> KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> baby with the bathwater.)

Nothing quite like hitting "send" to make an idea show up...

In a UP kernel, does it actually help anything to have KVM
tell RCU about executing in a guest?  If not, could we have a
rcu_note_context_switch_kvm() that is a static inline empty function in
TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?

							Thanx, Paul

> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> >  include/linux/rcutiny.h |    6 +-----
> >  kernel/rcutiny.c        |    7 +++++++
> >  kernel/rcutree.c        |    1 +
> >  3 files changed, 9 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
> > index 30ebd7c..8e5f7cf 100644
> > --- a/include/linux/rcutiny.h
> > +++ b/include/linux/rcutiny.h
> > @@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
> > 
> >  #endif /* #else #ifdef CONFIG_TINY_RCU */
> > 
> > -static inline void rcu_note_context_switch(int cpu)
> > -{
> > -	rcu_sched_qs(cpu);
> > -	rcu_preempt_note_context_switch();
> > -}
> > +extern void rcu_note_context_switch(int cpu);
> > 
> >  /*
> >   * Return the number of grace periods.
> > diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
> > index 0c343b9..3d715a4 100644
> > --- a/kernel/rcutiny.c
> > +++ b/kernel/rcutiny.c
> > @@ -78,6 +78,13 @@ void rcu_exit_nohz(void)
> > 
> >  #endif /* #ifdef CONFIG_NO_HZ */
> > 
> > +void rcu_note_context_switch(int cpu)
> > +{
> > +	rcu_sched_qs(cpu);
> > +	rcu_preempt_note_context_switch();
> > +}
> > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > +
> >  /*
> >   * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc().
> >   * Also disable irqs to avoid confusion due to interrupt handlers
> > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > index dd4aea8..0837d63 100644
> > --- a/kernel/rcutree.c
> > +++ b/kernel/rcutree.c
> > @@ -124,6 +124,7 @@ void rcu_note_context_switch(int cpu)
> >  	rcu_sched_qs(cpu);
> >  	rcu_preempt_note_context_switch(cpu);
> >  }
> > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > 
> >  #ifdef CONFIG_NO_HZ
> >  DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
> > -- 
> > 1.7.2.3
> > 
> > --
> > 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/
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov April 29, 2011, 6:02 p.m. UTC | #5
On Fri, Apr 29, 2011 at 01:39:04AM -0700, Paul E. McKenney wrote:
> On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> > On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> > 
> > Hmmm....  This is interesting.  KVM being a module, we either expand
> > TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> > function in rcutiny.c and adding an export, or we expand it by adding
> > two exports.
> > 
> > I would like to solve this without making TINY_RCU larger, and preferably
> > by making it smaller.  Any ideas come to mind?  (Other than making
> > KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> > baby with the bathwater.)
> 
> Nothing quite like hitting "send" to make an idea show up...
> 
> In a UP kernel, does it actually help anything to have KVM
> tell RCU about executing in a guest?  If not, could we have a
> rcu_note_context_switch_kvm() that is a static inline empty function in
> TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?
> 
That will work, but does making rcu_note_context_switch() out of line
actually increase kernel size? The function is called in two places
currently, so by making it out of line we make two calling site smaller.
Will measure it next week.

> 							Thanx, Paul
> 
> > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > > ---
> > >  include/linux/rcutiny.h |    6 +-----
> > >  kernel/rcutiny.c        |    7 +++++++
> > >  kernel/rcutree.c        |    1 +
> > >  3 files changed, 9 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
> > > index 30ebd7c..8e5f7cf 100644
> > > --- a/include/linux/rcutiny.h
> > > +++ b/include/linux/rcutiny.h
> > > @@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
> > > 
> > >  #endif /* #else #ifdef CONFIG_TINY_RCU */
> > > 
> > > -static inline void rcu_note_context_switch(int cpu)
> > > -{
> > > -	rcu_sched_qs(cpu);
> > > -	rcu_preempt_note_context_switch();
> > > -}
> > > +extern void rcu_note_context_switch(int cpu);
> > > 
> > >  /*
> > >   * Return the number of grace periods.
> > > diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
> > > index 0c343b9..3d715a4 100644
> > > --- a/kernel/rcutiny.c
> > > +++ b/kernel/rcutiny.c
> > > @@ -78,6 +78,13 @@ void rcu_exit_nohz(void)
> > > 
> > >  #endif /* #ifdef CONFIG_NO_HZ */
> > > 
> > > +void rcu_note_context_switch(int cpu)
> > > +{
> > > +	rcu_sched_qs(cpu);
> > > +	rcu_preempt_note_context_switch();
> > > +}
> > > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > > +
> > >  /*
> > >   * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc().
> > >   * Also disable irqs to avoid confusion due to interrupt handlers
> > > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > > index dd4aea8..0837d63 100644
> > > --- a/kernel/rcutree.c
> > > +++ b/kernel/rcutree.c
> > > @@ -124,6 +124,7 @@ void rcu_note_context_switch(int cpu)
> > >  	rcu_sched_qs(cpu);
> > >  	rcu_preempt_note_context_switch(cpu);
> > >  }
> > > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > > 
> > >  #ifdef CONFIG_NO_HZ
> > >  DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
> > > -- 
> > > 1.7.2.3
> > > 
> > > --
> > > 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/

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov April 29, 2011, 6:23 p.m. UTC | #6
On Fri, Apr 29, 2011 at 09:02:39PM +0300, Gleb Natapov wrote:
> On Fri, Apr 29, 2011 at 01:39:04AM -0700, Paul E. McKenney wrote:
> > On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> > > On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> > > 
> > > Hmmm....  This is interesting.  KVM being a module, we either expand
> > > TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> > > function in rcutiny.c and adding an export, or we expand it by adding
> > > two exports.
> > > 
> > > I would like to solve this without making TINY_RCU larger, and preferably
> > > by making it smaller.  Any ideas come to mind?  (Other than making
> > > KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> > > baby with the bathwater.)
> > 
> > Nothing quite like hitting "send" to make an idea show up...
> > 
> > In a UP kernel, does it actually help anything to have KVM
> > tell RCU about executing in a guest?  If not, could we have a
> > rcu_note_context_switch_kvm() that is a static inline empty function in
> > TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?
> > 
> That will work, but does making rcu_note_context_switch() out of line
> actually increase kernel size? The function is called in two places
> currently, so by making it out of line we make two calling site smaller.
> Will measure it next week.
> 
Why wait for so long? Here is the result:
   text    data     bss     dec     hex filename
4544134  590596 2023424 7158154  6d398a vmlinux     inline
4544198  590532 2023424 7158154  6d398a vmlinux.ol  out of line

So in out of line version text is 64 byte bigger, but data is 64 byte
smaller. Hmm.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul E. McKenney April 30, 2011, 12:59 p.m. UTC | #7
On Fri, Apr 29, 2011 at 09:02:39PM +0300, Gleb Natapov wrote:
> On Fri, Apr 29, 2011 at 01:39:04AM -0700, Paul E. McKenney wrote:
> > On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> > > On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> > > 
> > > Hmmm....  This is interesting.  KVM being a module, we either expand
> > > TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> > > function in rcutiny.c and adding an export, or we expand it by adding
> > > two exports.
> > > 
> > > I would like to solve this without making TINY_RCU larger, and preferably
> > > by making it smaller.  Any ideas come to mind?  (Other than making
> > > KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> > > baby with the bathwater.)
> > 
> > Nothing quite like hitting "send" to make an idea show up...
> > 
> > In a UP kernel, does it actually help anything to have KVM
> > tell RCU about executing in a guest?  If not, could we have a
> > rcu_note_context_switch_kvm() that is a static inline empty function in
> > TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?
> > 
> That will work, but does making rcu_note_context_switch() out of line
> actually increase kernel size? The function is called in two places
> currently, so by making it out of line we make two calling site smaller.
> Will measure it next week.

One thing to keep in mind...  Calling an out-of-line function from
KVM requires an export, each of which significantly increases TINY_RCU's
memory footprint.

							Thanx, Paul

> > > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > > > ---
> > > >  include/linux/rcutiny.h |    6 +-----
> > > >  kernel/rcutiny.c        |    7 +++++++
> > > >  kernel/rcutree.c        |    1 +
> > > >  3 files changed, 9 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
> > > > index 30ebd7c..8e5f7cf 100644
> > > > --- a/include/linux/rcutiny.h
> > > > +++ b/include/linux/rcutiny.h
> > > > @@ -93,11 +93,7 @@ static inline int rcu_needs_cpu(int cpu)
> > > > 
> > > >  #endif /* #else #ifdef CONFIG_TINY_RCU */
> > > > 
> > > > -static inline void rcu_note_context_switch(int cpu)
> > > > -{
> > > > -	rcu_sched_qs(cpu);
> > > > -	rcu_preempt_note_context_switch();
> > > > -}
> > > > +extern void rcu_note_context_switch(int cpu);
> > > > 
> > > >  /*
> > > >   * Return the number of grace periods.
> > > > diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
> > > > index 0c343b9..3d715a4 100644
> > > > --- a/kernel/rcutiny.c
> > > > +++ b/kernel/rcutiny.c
> > > > @@ -78,6 +78,13 @@ void rcu_exit_nohz(void)
> > > > 
> > > >  #endif /* #ifdef CONFIG_NO_HZ */
> > > > 
> > > > +void rcu_note_context_switch(int cpu)
> > > > +{
> > > > +	rcu_sched_qs(cpu);
> > > > +	rcu_preempt_note_context_switch();
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > > > +
> > > >  /*
> > > >   * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc().
> > > >   * Also disable irqs to avoid confusion due to interrupt handlers
> > > > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > > > index dd4aea8..0837d63 100644
> > > > --- a/kernel/rcutree.c
> > > > +++ b/kernel/rcutree.c
> > > > @@ -124,6 +124,7 @@ void rcu_note_context_switch(int cpu)
> > > >  	rcu_sched_qs(cpu);
> > > >  	rcu_preempt_note_context_switch(cpu);
> > > >  }
> > > > +EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > > > 
> > > >  #ifdef CONFIG_NO_HZ
> > > >  DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
> > > > -- 
> > > > 1.7.2.3
> > > > 
> > > > --
> > > > 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/
> 
> --
> 			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity April 30, 2011, 7:43 p.m. UTC | #8
On 04/30/2011 03:59 PM, Paul E. McKenney wrote:
> >  That will work, but does making rcu_note_context_switch() out of line
> >  actually increase kernel size? The function is called in two places
> >  currently, so by making it out of line we make two calling site smaller.
> >  Will measure it next week.
>
> One thing to keep in mind...  Calling an out-of-line function from
> KVM requires an export, each of which significantly increases TINY_RCU's
> memory footprint.

I would expect that most kvm configs will actually be smp (perhaps with 
an exception for embedded ppc).

A completely random idea - how about trimming exports that aren't 
actually used?  so if you have a minimal setup you only get the hit if 
you actually use kvm.

(The trimming would need to be optional so external modules can continue 
to work for those who want them)
Gleb Natapov May 2, 2011, 10:56 a.m. UTC | #9
On Sat, Apr 30, 2011 at 05:59:28AM -0700, Paul E. McKenney wrote:
> On Fri, Apr 29, 2011 at 09:02:39PM +0300, Gleb Natapov wrote:
> > On Fri, Apr 29, 2011 at 01:39:04AM -0700, Paul E. McKenney wrote:
> > > On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> > > > On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> > > > 
> > > > Hmmm....  This is interesting.  KVM being a module, we either expand
> > > > TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> > > > function in rcutiny.c and adding an export, or we expand it by adding
> > > > two exports.
> > > > 
> > > > I would like to solve this without making TINY_RCU larger, and preferably
> > > > by making it smaller.  Any ideas come to mind?  (Other than making
> > > > KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> > > > baby with the bathwater.)
> > > 
> > > Nothing quite like hitting "send" to make an idea show up...
> > > 
> > > In a UP kernel, does it actually help anything to have KVM
> > > tell RCU about executing in a guest?  If not, could we have a
> > > rcu_note_context_switch_kvm() that is a static inline empty function in
> > > TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?
> > > 
> > That will work, but does making rcu_note_context_switch() out of line
> > actually increase kernel size? The function is called in two places
> > currently, so by making it out of line we make two calling site smaller.
> > Will measure it next week.
> 
> One thing to keep in mind...  Calling an out-of-line function from
> KVM requires an export, each of which significantly increases TINY_RCU's
> memory footprint.
> 
> 							Thanx, Paul
> 
How significantly? As I wrote in other mail I compiled two TINY_RCU
kernel with and without the patch and I didn't see memory footprint
increase at all. May be I measure it incorrectly, but what I see is that
with out of line function + export text section becomes 64 byte bigger, but
data section becomes 64 byte smaller:

   text    data     bss     dec     hex filename
4544134  590596 2023424 7158154  6d398a vmlinux     inline
4544198  590532 2023424 7158154  6d398a vmlinux.ol  out of line

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov May 2, 2011, 2:10 p.m. UTC | #10
On Mon, May 02, 2011 at 06:36:08AM -0700, Paul E. McKenney wrote:
> On Mon, May 02, 2011 at 01:56:12PM +0300, Gleb Natapov wrote:
> > On Sat, Apr 30, 2011 at 05:59:28AM -0700, Paul E. McKenney wrote:
> > > On Fri, Apr 29, 2011 at 09:02:39PM +0300, Gleb Natapov wrote:
> > > > On Fri, Apr 29, 2011 at 01:39:04AM -0700, Paul E. McKenney wrote:
> > > > > On Fri, Apr 29, 2011 at 01:36:18AM -0700, Paul E. McKenney wrote:
> > > > > > On Thu, Apr 28, 2011 at 12:52:02PM +0300, Gleb Natapov wrote:
> > > > > > 
> > > > > > Hmmm....  This is interesting.  KVM being a module, we either expand
> > > > > > TINY_RCU's size a bit by making rcu_note_context_switch() be a real
> > > > > > function in rcutiny.c and adding an export, or we expand it by adding
> > > > > > two exports.
> > > > > > 
> > > > > > I would like to solve this without making TINY_RCU larger, and preferably
> > > > > > by making it smaller.  Any ideas come to mind?  (Other than making
> > > > > > KVM depend on CONFIG_SMP, which sounds too much like throwing out the
> > > > > > baby with the bathwater.)
> > > > > 
> > > > > Nothing quite like hitting "send" to make an idea show up...
> > > > > 
> > > > > In a UP kernel, does it actually help anything to have KVM
> > > > > tell RCU about executing in a guest?  If not, could we have a
> > > > > rcu_note_context_switch_kvm() that is a static inline empty function in
> > > > > TINY_RCU and maps to rcu_note_context_switch() for TREE_RCU?
> > > > > 
> > > > That will work, but does making rcu_note_context_switch() out of line
> > > > actually increase kernel size? The function is called in two places
> > > > currently, so by making it out of line we make two calling site smaller.
> > > > Will measure it next week.
> > > 
> > > One thing to keep in mind...  Calling an out-of-line function from
> > > KVM requires an export, each of which significantly increases TINY_RCU's
> > > memory footprint.
> > > 
> > > 							Thanx, Paul
> > > 
> > How significantly? As I wrote in other mail I compiled two TINY_RCU
> > kernel with and without the patch and I didn't see memory footprint
> > increase at all. May be I measure it incorrectly, but what I see is that
> > with out of line function + export text section becomes 64 byte bigger, but
> > data section becomes 64 byte smaller:
> > 
> >    text    data     bss     dec     hex filename
> > 4544134  590596 2023424 7158154  6d398a vmlinux     inline
> > 4544198  590532 2023424 7158154  6d398a vmlinux.ol  out of line
> 
> Did you add the exports that would be needed to allow KVM to call
> the functions in the inline case?
> 
Yes, this is with and without patch applied. When patch is applied the
function is out of line and exported.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index 30ebd7c..8e5f7cf 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -93,11 +93,7 @@  static inline int rcu_needs_cpu(int cpu)
 
 #endif /* #else #ifdef CONFIG_TINY_RCU */
 
-static inline void rcu_note_context_switch(int cpu)
-{
-	rcu_sched_qs(cpu);
-	rcu_preempt_note_context_switch();
-}
+extern void rcu_note_context_switch(int cpu);
 
 /*
  * Return the number of grace periods.
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index 0c343b9..3d715a4 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -78,6 +78,13 @@  void rcu_exit_nohz(void)
 
 #endif /* #ifdef CONFIG_NO_HZ */
 
+void rcu_note_context_switch(int cpu)
+{
+	rcu_sched_qs(cpu);
+	rcu_preempt_note_context_switch();
+}
+EXPORT_SYMBOL_GPL(rcu_note_context_switch);
+
 /*
  * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc().
  * Also disable irqs to avoid confusion due to interrupt handlers
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index dd4aea8..0837d63 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -124,6 +124,7 @@  void rcu_note_context_switch(int cpu)
 	rcu_sched_qs(cpu);
 	rcu_preempt_note_context_switch(cpu);
 }
+EXPORT_SYMBOL_GPL(rcu_note_context_switch);
 
 #ifdef CONFIG_NO_HZ
 DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {