Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Paul E. McKenney
On Mon, May 14, 2018 at 05:35:55PM -0700, Joel Fernandes wrote:
> On Mon, May 14, 2018 at 10:22:05AM -0700, Paul E. McKenney wrote:
> > On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> > > On Sun, 13 May 2018 20:15:35 -0700
> > > "Joel Fernandes (Google)"  wrote:
> > > 
> > > > Recently we had a discussion about cond_resched unconditionally
> > > > recording a voluntary context switch [1].
> > > > 
> > > > Lets add a comment clarifying that how this API is to be used.
> > > > 
> > > > [1] 
> > > > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > > > 
> > > > Signed-off-by: Joel Fernandes (Google) 
> > > > ---
> > > >  include/linux/rcupdate.h | 11 ---
> > > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > > index 743226176350..a9881007ece6 100644
> > > > --- a/include/linux/rcupdate.h
> > > > +++ b/include/linux/rcupdate.h
> > > > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > > > } while (0)
> > > >  
> > > >  /*
> > > > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > > > - * macro rather than an inline function to avoid #include hell.
> > > > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > > > benefit.
> > > > + *
> > > > + * This is called even in situations where a context switch didn't 
> > > > really
> > > > + * happen even though it was requested. The caller uses it to indicate
> > > > + * traversal of an RCU-tasks quiescent state. This is a macro rather 
> > > > than an
> > > > + * inline function to avoid #include hell.
> > > 
> > > I don't know. I just don't like the wording. It sounds too much like
> > > it was written by someone that was confused for it being called when a
> > > context switch didn't occur ;-)
> 
> True :)
> 
> > > 
> > > What about something more like:
> > > 
> > > /*
> > >  * This is called to denote a RCU-task quiescent state. It is placed at
> > >  * voluntary preemption points, as RCU-task critical sections may not
> > >  * perform voluntary preemption or scheduling calls. It does not matter
> > >  * if the task is scheduled out or not, just that a voluntary preemption
> > >  * may be done.
> > >  */
> > 
> > s/RCU-task/RCU-tasks/ and I am good with this.
> 
> Ok. I like Steve's comment better too.
> 
> Btw, I see you just posted a change of the macro name from
> rcu_note_voluntary_context_switch_lite to rcu_tasks_qs which actually in
> itself is much more descriptive. Considering this, I feel the new name is
> quite self-documenting in itself. So I am more inclined to drop this patch in
> any series reposting, but let me know if you feel otherwise.

I agree, but let's see what other people think.

Thanx, Paul



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Paul E. McKenney
On Mon, May 14, 2018 at 05:35:55PM -0700, Joel Fernandes wrote:
> On Mon, May 14, 2018 at 10:22:05AM -0700, Paul E. McKenney wrote:
> > On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> > > On Sun, 13 May 2018 20:15:35 -0700
> > > "Joel Fernandes (Google)"  wrote:
> > > 
> > > > Recently we had a discussion about cond_resched unconditionally
> > > > recording a voluntary context switch [1].
> > > > 
> > > > Lets add a comment clarifying that how this API is to be used.
> > > > 
> > > > [1] 
> > > > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > > > 
> > > > Signed-off-by: Joel Fernandes (Google) 
> > > > ---
> > > >  include/linux/rcupdate.h | 11 ---
> > > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > > index 743226176350..a9881007ece6 100644
> > > > --- a/include/linux/rcupdate.h
> > > > +++ b/include/linux/rcupdate.h
> > > > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > > > } while (0)
> > > >  
> > > >  /*
> > > > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > > > - * macro rather than an inline function to avoid #include hell.
> > > > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > > > benefit.
> > > > + *
> > > > + * This is called even in situations where a context switch didn't 
> > > > really
> > > > + * happen even though it was requested. The caller uses it to indicate
> > > > + * traversal of an RCU-tasks quiescent state. This is a macro rather 
> > > > than an
> > > > + * inline function to avoid #include hell.
> > > 
> > > I don't know. I just don't like the wording. It sounds too much like
> > > it was written by someone that was confused for it being called when a
> > > context switch didn't occur ;-)
> 
> True :)
> 
> > > 
> > > What about something more like:
> > > 
> > > /*
> > >  * This is called to denote a RCU-task quiescent state. It is placed at
> > >  * voluntary preemption points, as RCU-task critical sections may not
> > >  * perform voluntary preemption or scheduling calls. It does not matter
> > >  * if the task is scheduled out or not, just that a voluntary preemption
> > >  * may be done.
> > >  */
> > 
> > s/RCU-task/RCU-tasks/ and I am good with this.
> 
> Ok. I like Steve's comment better too.
> 
> Btw, I see you just posted a change of the macro name from
> rcu_note_voluntary_context_switch_lite to rcu_tasks_qs which actually in
> itself is much more descriptive. Considering this, I feel the new name is
> quite self-documenting in itself. So I am more inclined to drop this patch in
> any series reposting, but let me know if you feel otherwise.

I agree, but let's see what other people think.

Thanx, Paul



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Joel Fernandes
On Mon, May 14, 2018 at 10:22:05AM -0700, Paul E. McKenney wrote:
> On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> > On Sun, 13 May 2018 20:15:35 -0700
> > "Joel Fernandes (Google)"  wrote:
> > 
> > > Recently we had a discussion about cond_resched unconditionally
> > > recording a voluntary context switch [1].
> > > 
> > > Lets add a comment clarifying that how this API is to be used.
> > > 
> > > [1] 
> > > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > > 
> > > Signed-off-by: Joel Fernandes (Google) 
> > > ---
> > >  include/linux/rcupdate.h | 11 ---
> > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > index 743226176350..a9881007ece6 100644
> > > --- a/include/linux/rcupdate.h
> > > +++ b/include/linux/rcupdate.h
> > > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > >   } while (0)
> > >  
> > >  /*
> > > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > > - * macro rather than an inline function to avoid #include hell.
> > > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > > benefit.
> > > + *
> > > + * This is called even in situations where a context switch didn't really
> > > + * happen even though it was requested. The caller uses it to indicate
> > > + * traversal of an RCU-tasks quiescent state. This is a macro rather 
> > > than an
> > > + * inline function to avoid #include hell.
> > 
> > I don't know. I just don't like the wording. It sounds too much like
> > it was written by someone that was confused for it being called when a
> > context switch didn't occur ;-)

True :)

> > 
> > What about something more like:
> > 
> > /*
> >  * This is called to denote a RCU-task quiescent state. It is placed at
> >  * voluntary preemption points, as RCU-task critical sections may not
> >  * perform voluntary preemption or scheduling calls. It does not matter
> >  * if the task is scheduled out or not, just that a voluntary preemption
> >  * may be done.
> >  */
> 
> s/RCU-task/RCU-tasks/ and I am good with this.

Ok. I like Steve's comment better too.

Btw, I see you just posted a change of the macro name from
rcu_note_voluntary_context_switch_lite to rcu_tasks_qs which actually in
itself is much more descriptive. Considering this, I feel the new name is
quite self-documenting in itself. So I am more inclined to drop this patch in
any series reposting, but let me know if you feel otherwise.

thanks,

- Joel



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Joel Fernandes
On Mon, May 14, 2018 at 10:22:05AM -0700, Paul E. McKenney wrote:
> On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> > On Sun, 13 May 2018 20:15:35 -0700
> > "Joel Fernandes (Google)"  wrote:
> > 
> > > Recently we had a discussion about cond_resched unconditionally
> > > recording a voluntary context switch [1].
> > > 
> > > Lets add a comment clarifying that how this API is to be used.
> > > 
> > > [1] 
> > > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > > 
> > > Signed-off-by: Joel Fernandes (Google) 
> > > ---
> > >  include/linux/rcupdate.h | 11 ---
> > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > index 743226176350..a9881007ece6 100644
> > > --- a/include/linux/rcupdate.h
> > > +++ b/include/linux/rcupdate.h
> > > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > >   } while (0)
> > >  
> > >  /*
> > > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > > - * macro rather than an inline function to avoid #include hell.
> > > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > > benefit.
> > > + *
> > > + * This is called even in situations where a context switch didn't really
> > > + * happen even though it was requested. The caller uses it to indicate
> > > + * traversal of an RCU-tasks quiescent state. This is a macro rather 
> > > than an
> > > + * inline function to avoid #include hell.
> > 
> > I don't know. I just don't like the wording. It sounds too much like
> > it was written by someone that was confused for it being called when a
> > context switch didn't occur ;-)

True :)

> > 
> > What about something more like:
> > 
> > /*
> >  * This is called to denote a RCU-task quiescent state. It is placed at
> >  * voluntary preemption points, as RCU-task critical sections may not
> >  * perform voluntary preemption or scheduling calls. It does not matter
> >  * if the task is scheduled out or not, just that a voluntary preemption
> >  * may be done.
> >  */
> 
> s/RCU-task/RCU-tasks/ and I am good with this.

Ok. I like Steve's comment better too.

Btw, I see you just posted a change of the macro name from
rcu_note_voluntary_context_switch_lite to rcu_tasks_qs which actually in
itself is much more descriptive. Considering this, I feel the new name is
quite self-documenting in itself. So I am more inclined to drop this patch in
any series reposting, but let me know if you feel otherwise.

thanks,

- Joel



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Paul E. McKenney
On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> On Sun, 13 May 2018 20:15:35 -0700
> "Joel Fernandes (Google)"  wrote:
> 
> > Recently we had a discussion about cond_resched unconditionally
> > recording a voluntary context switch [1].
> > 
> > Lets add a comment clarifying that how this API is to be used.
> > 
> > [1] 
> > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > 
> > Signed-off-by: Joel Fernandes (Google) 
> > ---
> >  include/linux/rcupdate.h | 11 ---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > index 743226176350..a9881007ece6 100644
> > --- a/include/linux/rcupdate.h
> > +++ b/include/linux/rcupdate.h
> > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > } while (0)
> >  
> >  /*
> > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > - * macro rather than an inline function to avoid #include hell.
> > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > benefit.
> > + *
> > + * This is called even in situations where a context switch didn't really
> > + * happen even though it was requested. The caller uses it to indicate
> > + * traversal of an RCU-tasks quiescent state. This is a macro rather than 
> > an
> > + * inline function to avoid #include hell.
> 
> I don't know. I just don't like the wording. It sounds too much like
> it was written by someone that was confused for it being called when a
> context switch didn't occur ;-)
> 
> What about something more like:
> 
> /*
>  * This is called to denote a RCU-task quiescent state. It is placed at
>  * voluntary preemption points, as RCU-task critical sections may not
>  * perform voluntary preemption or scheduling calls. It does not matter
>  * if the task is scheduled out or not, just that a voluntary preemption
>  * may be done.
>  */

s/RCU-task/RCU-tasks/ and I am good with this.

Thanx, Paul

> >   */
> >  #ifdef CONFIG_TASKS_RCU
> >  #define rcu_note_voluntary_context_switch_lite(t) \
> > @@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
> >  #endif /* #else #ifdef CONFIG_TASKS_RCU */
> >  
> >  /**
> > - * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
> > + * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
> > + * The quiescent state report is made even if cond_resched() did nothing.
> 
> Same thing here.
> 
>  * The quiescent state report does not depend on cond_resched() scheduling.
> 
> -- Steve
> 
> 
> >   *
> >   * This macro resembles cond_resched(), except that it is defined to
> >   * report potential quiescent states to RCU-tasks even if the 
> > cond_resched()
> 



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Paul E. McKenney
On Mon, May 14, 2018 at 10:54:54AM -0400, Steven Rostedt wrote:
> On Sun, 13 May 2018 20:15:35 -0700
> "Joel Fernandes (Google)"  wrote:
> 
> > Recently we had a discussion about cond_resched unconditionally
> > recording a voluntary context switch [1].
> > 
> > Lets add a comment clarifying that how this API is to be used.
> > 
> > [1] 
> > https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> > 
> > Signed-off-by: Joel Fernandes (Google) 
> > ---
> >  include/linux/rcupdate.h | 11 ---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > index 743226176350..a9881007ece6 100644
> > --- a/include/linux/rcupdate.h
> > +++ b/include/linux/rcupdate.h
> > @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
> > } while (0)
> >  
> >  /*
> > - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> > - * macro rather than an inline function to avoid #include hell.
> > + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> > benefit.
> > + *
> > + * This is called even in situations where a context switch didn't really
> > + * happen even though it was requested. The caller uses it to indicate
> > + * traversal of an RCU-tasks quiescent state. This is a macro rather than 
> > an
> > + * inline function to avoid #include hell.
> 
> I don't know. I just don't like the wording. It sounds too much like
> it was written by someone that was confused for it being called when a
> context switch didn't occur ;-)
> 
> What about something more like:
> 
> /*
>  * This is called to denote a RCU-task quiescent state. It is placed at
>  * voluntary preemption points, as RCU-task critical sections may not
>  * perform voluntary preemption or scheduling calls. It does not matter
>  * if the task is scheduled out or not, just that a voluntary preemption
>  * may be done.
>  */

s/RCU-task/RCU-tasks/ and I am good with this.

Thanx, Paul

> >   */
> >  #ifdef CONFIG_TASKS_RCU
> >  #define rcu_note_voluntary_context_switch_lite(t) \
> > @@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
> >  #endif /* #else #ifdef CONFIG_TASKS_RCU */
> >  
> >  /**
> > - * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
> > + * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
> > + * The quiescent state report is made even if cond_resched() did nothing.
> 
> Same thing here.
> 
>  * The quiescent state report does not depend on cond_resched() scheduling.
> 
> -- Steve
> 
> 
> >   *
> >   * This macro resembles cond_resched(), except that it is defined to
> >   * report potential quiescent states to RCU-tasks even if the 
> > cond_resched()
> 



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Steven Rostedt
On Sun, 13 May 2018 20:15:35 -0700
"Joel Fernandes (Google)"  wrote:

> Recently we had a discussion about cond_resched unconditionally
> recording a voluntary context switch [1].
> 
> Lets add a comment clarifying that how this API is to be used.
> 
> [1] 
> https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> 
> Signed-off-by: Joel Fernandes (Google) 
> ---
>  include/linux/rcupdate.h | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 743226176350..a9881007ece6 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
>   } while (0)
>  
>  /*
> - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> - * macro rather than an inline function to avoid #include hell.
> + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> benefit.
> + *
> + * This is called even in situations where a context switch didn't really
> + * happen even though it was requested. The caller uses it to indicate
> + * traversal of an RCU-tasks quiescent state. This is a macro rather than an
> + * inline function to avoid #include hell.

I don't know. I just don't like the wording. It sounds too much like
it was written by someone that was confused for it being called when a
context switch didn't occur ;-)

What about something more like:

/*
 * This is called to denote a RCU-task quiescent state. It is placed at
 * voluntary preemption points, as RCU-task critical sections may not
 * perform voluntary preemption or scheduling calls. It does not matter
 * if the task is scheduled out or not, just that a voluntary preemption
 * may be done.
 */

>   */
>  #ifdef CONFIG_TASKS_RCU
>  #define rcu_note_voluntary_context_switch_lite(t) \
> @@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
>  #endif /* #else #ifdef CONFIG_TASKS_RCU */
>  
>  /**
> - * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
> + * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
> + * The quiescent state report is made even if cond_resched() did nothing.

Same thing here.

 * The quiescent state report does not depend on cond_resched() scheduling.

-- Steve


>   *
>   * This macro resembles cond_resched(), except that it is defined to
>   * report potential quiescent states to RCU-tasks even if the cond_resched()



Re: [PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-14 Thread Steven Rostedt
On Sun, 13 May 2018 20:15:35 -0700
"Joel Fernandes (Google)"  wrote:

> Recently we had a discussion about cond_resched unconditionally
> recording a voluntary context switch [1].
> 
> Lets add a comment clarifying that how this API is to be used.
> 
> [1] 
> https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com
> 
> Signed-off-by: Joel Fernandes (Google) 
> ---
>  include/linux/rcupdate.h | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 743226176350..a9881007ece6 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
>   } while (0)
>  
>  /*
> - * Note a voluntary context switch for RCU-tasks benefit.  This is a
> - * macro rather than an inline function to avoid #include hell.
> + * Note an attempt to perform a voluntary context switch for RCU-tasks 
> benefit.
> + *
> + * This is called even in situations where a context switch didn't really
> + * happen even though it was requested. The caller uses it to indicate
> + * traversal of an RCU-tasks quiescent state. This is a macro rather than an
> + * inline function to avoid #include hell.

I don't know. I just don't like the wording. It sounds too much like
it was written by someone that was confused for it being called when a
context switch didn't occur ;-)

What about something more like:

/*
 * This is called to denote a RCU-task quiescent state. It is placed at
 * voluntary preemption points, as RCU-task critical sections may not
 * perform voluntary preemption or scheduling calls. It does not matter
 * if the task is scheduled out or not, just that a voluntary preemption
 * may be done.
 */

>   */
>  #ifdef CONFIG_TASKS_RCU
>  #define rcu_note_voluntary_context_switch_lite(t) \
> @@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
>  #endif /* #else #ifdef CONFIG_TASKS_RCU */
>  
>  /**
> - * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
> + * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
> + * The quiescent state report is made even if cond_resched() did nothing.

Same thing here.

 * The quiescent state report does not depend on cond_resched() scheduling.

-- Steve


>   *
>   * This macro resembles cond_resched(), except that it is defined to
>   * report potential quiescent states to RCU-tasks even if the cond_resched()



[PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-13 Thread Joel Fernandes (Google)
Recently we had a discussion about cond_resched unconditionally
recording a voluntary context switch [1].

Lets add a comment clarifying that how this API is to be used.

[1] 
https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com

Signed-off-by: Joel Fernandes (Google) 
---
 include/linux/rcupdate.h | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 743226176350..a9881007ece6 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
} while (0)
 
 /*
- * Note a voluntary context switch for RCU-tasks benefit.  This is a
- * macro rather than an inline function to avoid #include hell.
+ * Note an attempt to perform a voluntary context switch for RCU-tasks benefit.
+ *
+ * This is called even in situations where a context switch didn't really
+ * happen even though it was requested. The caller uses it to indicate
+ * traversal of an RCU-tasks quiescent state. This is a macro rather than an
+ * inline function to avoid #include hell.
  */
 #ifdef CONFIG_TASKS_RCU
 #define rcu_note_voluntary_context_switch_lite(t) \
@@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
 #endif /* #else #ifdef CONFIG_TASKS_RCU */
 
 /**
- * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
+ * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
+ * The quiescent state report is made even if cond_resched() did nothing.
  *
  * This macro resembles cond_resched(), except that it is defined to
  * report potential quiescent states to RCU-tasks even if the cond_resched()
-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH RFC 2/8] rcu: Clarify usage of cond_resched for tasks-RCU

2018-05-13 Thread Joel Fernandes (Google)
Recently we had a discussion about cond_resched unconditionally
recording a voluntary context switch [1].

Lets add a comment clarifying that how this API is to be used.

[1] 
https://lkml.kernel.org/r/1526027434-21237-1-git-send-email-byungchul.p...@lge.com

Signed-off-by: Joel Fernandes (Google) 
---
 include/linux/rcupdate.h | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 743226176350..a9881007ece6 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -159,8 +159,12 @@ static inline void rcu_init_nohz(void) { }
} while (0)
 
 /*
- * Note a voluntary context switch for RCU-tasks benefit.  This is a
- * macro rather than an inline function to avoid #include hell.
+ * Note an attempt to perform a voluntary context switch for RCU-tasks benefit.
+ *
+ * This is called even in situations where a context switch didn't really
+ * happen even though it was requested. The caller uses it to indicate
+ * traversal of an RCU-tasks quiescent state. This is a macro rather than an
+ * inline function to avoid #include hell.
  */
 #ifdef CONFIG_TASKS_RCU
 #define rcu_note_voluntary_context_switch_lite(t) \
@@ -187,7 +191,8 @@ static inline void exit_tasks_rcu_finish(void) { }
 #endif /* #else #ifdef CONFIG_TASKS_RCU */
 
 /**
- * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
+ * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU.
+ * The quiescent state report is made even if cond_resched() did nothing.
  *
  * This macro resembles cond_resched(), except that it is defined to
  * report potential quiescent states to RCU-tasks even if the cond_resched()
-- 
2.17.0.441.gb46fe60e1d-goog