Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-04 Thread Paul E. McKenney
On Sat, May 04, 2013 at 10:23:31AM +0300, Julian Anastasov wrote: > > Hello, > > On Fri, 3 May 2013, Paul E. McKenney wrote: > > > static inline int cond_resched_rcu(void) > > { > > #if defined(CONFIG_DEBUG_ATOMIC_SLEEP) || !defined(CONFIG_PREEMPT_RCU) > > rcu_read_unlock(); > > co

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-04 Thread Julian Anastasov
Hello, On Fri, 3 May 2013, Paul E. McKenney wrote: > static inline int cond_resched_rcu(void) > { > #if defined(CONFIG_DEBUG_ATOMIC_SLEEP) || !defined(CONFIG_PREEMPT_RCU) > rcu_read_unlock(); > cond_resched(); > rcu_read_lock(); > #endif > } > > This adds absolutely no

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Peter Zijlstra
> This happens in only two cases: > > 1.CONFIG_PREEMPT_RCU=n kernels. But in this case, rcu_read_unlock() > and rcu_read_lock() are free, at least for CONFIG_PROVE_LOCKING=n > kernels. And if you have CONFIG_PROVE_LOCKING=y, any contribution > from rcu_read_unlock() and rcu

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Julian Anastasov
Hello, On Fri, 3 May 2013, Paul E. McKenney wrote: > OK, after getting some sleep, I might have located the root cause of > my confusion yesterday. > > The key point is that I don't understand why we cannot get the effect > we are looking for with the following in sched.h (or wherever):

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Paul E. McKenney
On Fri, May 03, 2013 at 07:04:47PM +0200, Peter Zijlstra wrote: > > The key point is that I don't understand why we cannot get the effect > > we are looking for with the following in sched.h (or wherever): > > > > static inline int cond_resched_rcu(void) > > { > > #if defined(CONFIG_DEBUG_ATOMIC_S

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Peter Zijlstra
> The key point is that I don't understand why we cannot get the effect > we are looking for with the following in sched.h (or wherever): > > static inline int cond_resched_rcu(void) > { > #if defined(CONFIG_DEBUG_ATOMIC_SLEEP) || !defined(CONFIG_PREEMPT_RCU) > rcu_read_unlock(); > con

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Paul E. McKenney
On Fri, May 03, 2013 at 10:52:36AM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 2 May 2013, Paul E. McKenney wrote: > > > mainline, and missed the one that you added. Revisiting that, a > > question: > > > > > +#ifdef CONFIG_PREEMPT_RCU > > > +#define PREEMPT_RCU_OFFSET 1 >

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-03 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Paul E. McKenney wrote: > mainline, and missed the one that you added. Revisiting that, a > question: > > > +#ifdef CONFIG_PREEMPT_RCU > > +#define PREEMPT_RCU_OFFSET 1 > > Does this really want to be "1" instead of PREEMPT_OFFSET? In this case

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Paul E. McKenney
On Thu, May 02, 2013 at 11:19:12PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 2 May 2013, Paul E. McKenney wrote: > > > > Only the new cond_resched_rcu() macro provides > > > PREEMPT_ACTIVE flag to skip the rcu_preempt_sleep_check() > > > call. The old macros provide locked=0

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Paul E. McKenney wrote: > > Only the new cond_resched_rcu() macro provides > > PREEMPT_ACTIVE flag to skip the rcu_preempt_sleep_check() > > call. The old macros provide locked=0 as you noticed. Does it > > answer your question or I'm missing something? >

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Paul E. McKenney
On Thu, May 02, 2013 at 09:55:54PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 2 May 2013, Paul E. McKenney wrote: > > > On Thu, May 02, 2013 at 06:54:05PM +0300, Julian Anastasov wrote: > > > > > > I tested the following patch in 2 variants, > > > TINY_RCU and CONFIG_TREE_PRE

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Julian Anastasov wrote: > Note that I'm testing on some 9-year old > UP system, i.e. 1 CPU. Now I enabled SMP to test CONFIG_TREE_RCU > and the results are same. I think, it should be just like > the TINY_RCU in terms of these debuggings (non-preempt). Ex

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Paul E. McKenney wrote: > On Thu, May 02, 2013 at 06:54:05PM +0300, Julian Anastasov wrote: > > > > I tested the following patch in 2 variants, > > TINY_RCU and CONFIG_TREE_PREEMPT_RCU. I see the > > Could you please also try CONFIG_TREE_RCU? Not

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Paul E. McKenney
On Thu, May 02, 2013 at 06:54:05PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 2 May 2013, Peter Zijlstra wrote: > > > On Wed, May 01, 2013 at 09:22:08PM +0300, Julian Anastasov wrote: > > > > +extern int __cond_resched_rcu(void); > > > > + > > > > +#define cond_resched_rcu() ({

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Peter Zijlstra wrote: > On Wed, May 01, 2013 at 09:22:08PM +0300, Julian Anastasov wrote: > > > +extern int __cond_resched_rcu(void); > > > + > > > +#define cond_resched_rcu() ({\ > > > + __might_sleep(__FILE__, __LINE__, 0); \ > > > >

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Julian Anastasov
Hello, On Thu, 2 May 2013, Peter Zijlstra wrote: > On Wed, May 01, 2013 at 09:22:08PM +0300, Julian Anastasov wrote: > > > +extern int __cond_resched_rcu(void); > > > + > > > +#define cond_resched_rcu() ({\ > > > + __might_sleep(__FILE__, __LINE__, 0); \ > > > >

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Peter Zijlstra
On Wed, May 01, 2013 at 07:32:58AM -0700, Paul E. McKenney wrote: > Here is how to detect this: > > static void inline cond_resched_rcu_lock(void) > { > rcu_read_unlock(); > WARN_ON_ONCE(rcu_read_lock_held()); > #ifndef CONFIG_PREEMPT_RCU >

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-02 Thread Peter Zijlstra
On Wed, May 01, 2013 at 09:22:08PM +0300, Julian Anastasov wrote: > > +extern int __cond_resched_rcu(void); > > + > > +#define cond_resched_rcu() ({ \ > > + __might_sleep(__FILE__, __LINE__, 0); \ > > I see your goal. But digging into __might_sleep() > I see that rcu

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Paul E. McKenney
On Wed, May 01, 2013 at 09:22:08PM +0300, Julian Anastasov wrote: > > Hello, > > On Wed, 1 May 2013, Peter Zijlstra wrote: > > > On Wed, May 01, 2013 at 05:22:05PM +0300, Julian Anastasov wrote: > > > > > 2. Same without need_resched because cond_resched already > > > performs the same ch

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Julian Anastasov
Hello, On Wed, 1 May 2013, Peter Zijlstra wrote: > On Wed, May 01, 2013 at 05:22:05PM +0300, Julian Anastasov wrote: > > > 2. Same without need_resched because cond_resched already > > performs the same checks: > > > > static void inline cond_resched_rcu_lock(void) > > { > > #ifndef CO

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Paul E. McKenney
On Wed, May 01, 2013 at 06:57:49PM +0200, Peter Zijlstra wrote: > On Wed, May 01, 2013 at 09:02:18AM -0700, Paul E. McKenney wrote: > > My guess would be for the case where sched_preempt_enable_no_resched() > > is followed some time later by cond_resched(). > > I might hope not.. preempt_enable_no

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Peter Zijlstra
On Wed, May 01, 2013 at 09:02:18AM -0700, Paul E. McKenney wrote: > My guess would be for the case where sched_preempt_enable_no_resched() > is followed some time later by cond_resched(). I might hope not.. preempt_enable_no_resched() is nasty and you're likely to be hit with a frozen fish of sort

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Paul E. McKenney
On Wed, May 01, 2013 at 08:29:55AM -0700, Eric Dumazet wrote: > On Wed, 2013-05-01 at 17:17 +0200, Peter Zijlstra wrote: > > On Wed, May 01, 2013 at 05:46:37AM -0700, Paul E. McKenney wrote: > > > > > If the only goal is to allow preemption, and if long grace periods are > > > not a concern, then

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Peter Zijlstra
On Wed, May 01, 2013 at 08:29:55AM -0700, Eric Dumazet wrote: > On Wed, 2013-05-01 at 17:17 +0200, Peter Zijlstra wrote: > > On Wed, May 01, 2013 at 05:46:37AM -0700, Paul E. McKenney wrote: > > > > > If the only goal is to allow preemption, and if long grace periods are > > > not a concern, then

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Peter Zijlstra
On Wed, May 01, 2013 at 05:22:05PM +0300, Julian Anastasov wrote: > > static void inline cond_resched_rcu_lock(void) > > { > > #ifdef CONFIG_PREEMPT_RCU > > You mean '#ifndef' here, right? But in the non-preempt > case is using the need_resched() needed? rcu_read_unlock > and rcu_read_lock

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Eric Dumazet
On Wed, 2013-05-01 at 17:17 +0200, Peter Zijlstra wrote: > On Wed, May 01, 2013 at 05:46:37AM -0700, Paul E. McKenney wrote: > > > If the only goal is to allow preemption, and if long grace periods are > > not a concern, then this alternate approach would work fine as well. > > Hmm.. if that were

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Peter Zijlstra
On Wed, May 01, 2013 at 05:46:37AM -0700, Paul E. McKenney wrote: > If the only goal is to allow preemption, and if long grace periods are > not a concern, then this alternate approach would work fine as well. Hmm.. if that were the goal I'd like it to have a different name; cond_resched*() has a

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Paul E. McKenney
On Wed, May 01, 2013 at 05:46:37AM -0700, Paul E. McKenney wrote: > On Wed, May 01, 2013 at 11:10:12AM +0200, Peter Zijlstra wrote: > > On Tue, Apr 30, 2013 at 10:52:38AM +0300, Julian Anastasov wrote: > > > > > > Hello, > > > > > > On Tue, 30 Apr 2013, Simon Horman wrote: > > > > > > > > > +s

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Julian Anastasov
Hello, On Wed, 1 May 2013, Peter Zijlstra wrote: > On Tue, Apr 30, 2013 at 10:52:38AM +0300, Julian Anastasov wrote: > > > > Hello, > > > > On Tue, 30 Apr 2013, Simon Horman wrote: > > > > > Thanks, to clarify, just this: > > > > > > static void inline cond_resched_rcu_lock(void)

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Paul E. McKenney
On Wed, May 01, 2013 at 11:10:12AM +0200, Peter Zijlstra wrote: > On Tue, Apr 30, 2013 at 10:52:38AM +0300, Julian Anastasov wrote: > > > > Hello, > > > > On Tue, 30 Apr 2013, Simon Horman wrote: > > > > > > > +static void inline cond_resched_rcu_lock(void) > > > > > +{ > > > > > + if (n

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-05-01 Thread Peter Zijlstra
On Tue, Apr 30, 2013 at 10:52:38AM +0300, Julian Anastasov wrote: > > Hello, > > On Tue, 30 Apr 2013, Simon Horman wrote: > > > > > +static void inline cond_resched_rcu_lock(void) > > > > +{ > > > > + if (need_resched()) { > > > > > > Ops, it should be without above need_resched.

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-04-30 Thread Julian Anastasov
Hello, On Tue, 30 Apr 2013, Simon Horman wrote: > > > +static void inline cond_resched_rcu_lock(void) > > > +{ > > > + if (need_resched()) { > > > > Ops, it should be without above need_resched. > > Thanks, to clarify, just this: > > static void inline cond_resched_rcu_lock(void)

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-04-30 Thread Simon Horman
On Tue, Apr 30, 2013 at 10:12:38AM +0300, Julian Anastasov wrote: > > Hello, > > On Tue, 30 Apr 2013, Simon Horman wrote: > > > This is intended for use in loops which read data protected by RCU and may > > have a large number of iterations. Such an example is dumping the list of > > conn

Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-04-30 Thread Julian Anastasov
Hello, On Tue, 30 Apr 2013, Simon Horman wrote: > This is intended for use in loops which read data protected by RCU and may > have a large number of iterations. Such an example is dumping the list of > connections known to IPVS: ip_vs_conn_array() and ip_vs_conn_seq_next(). > > The ca

[PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper

2013-04-29 Thread Simon Horman
This is intended for use in loops which read data protected by RCU and may have a large number of iterations. Such an example is dumping the list of connections known to IPVS: ip_vs_conn_array() and ip_vs_conn_seq_next(). The call to cond_resched() is guarded by #ifndef CONFIG_PREEMPT_RCU as in t