Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761545Ab3EBWbT (ORCPT ); Thu, 2 May 2013 18:31:19 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:35762 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961Ab3EBWbP (ORCPT ); Thu, 2 May 2013 18:31:15 -0400 Date: Thu, 2 May 2013 15:31:07 -0700 From: "Paul E. McKenney" To: Julian Anastasov Cc: Peter Zijlstra , Simon Horman , Eric Dumazet , Ingo Molnar , lvs-devel@vger.kernel.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Pablo Neira Ayuso , Dipankar Sarma Subject: Re: [PATCH v2 1/2] sched: Add cond_resched_rcu_lock() helper Message-ID: <20130502223107.GB3780@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20130501091012.GB28253@dyad.programming.kicks-ass.net> <20130501155501.GB7521@dyad.programming.kicks-ass.net> <20130502072623.GE7521@dyad.programming.kicks-ass.net> <20130502173257.GX3780@linux.vnet.ibm.com> <20130502193409.GA3780@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050222-3620-0000-0000-0000024F23BD Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2547 Lines: 75 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 as you noticed. Does it > > > answer your question or I'm missing something? > > > > PREEMPT_ACTIVE's value is usually 0x10000000. Did it change > > since 3.9? If not, rcu_sleep_check(preempt_offset & PREEMPT_ACTIVE) > > is the same as rcu_sleep_check(0). > > Yes, the different platforms use different bit, > that is why I mentioned about my failed attempt at > changing hardirq.h. PREEMPT_ACTIVE is always != 0. > > But I don't understand what do you mean by > 'preempt_offset & PREEMPT_ACTIVE' being always 0. > It is always 0 for cond_resched(), cond_resched_lock() > and cond_resched_softirq(), not for cond_resched_rcu(): > > (PREEMPT_ACTIVE | PREEMPT_RCU_OFFSET) & PREEMPT_ACTIVE > should give PREEMPT_ACTIVE, not 0. We have 2 cases in > rcu_sleep_check() for the if: > > 1. !(PREEMPT_ACTIVE) => FALSE for cond_resched_rcu > 2. !(0) => TRUE for other cond_resched_* macros > > On x86 the code is: > > __might_sleep: > pushl %ebp # > testl $268435456, %ecx #, preempt_offset > ... > jne .L240 #, > // rcu_lock_map checked when PREEMPT_ACTIVE is missing > .L240: > // rcu_bh_lock_map checked OK, apologies -- I was looking at the calls to __might_sleep() in 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? > +#else > +#define PREEMPT_RCU_OFFSET PREEMPT_CHECK_OFFSET > +#endif > + > +extern int __cond_resched_rcu(void); > + > +#define cond_resched_rcu() ({ \ > + __might_sleep(__FILE__, __LINE__, PREEMPT_ACTIVE | \ > + PREEMPT_RCU_OFFSET); \ > + __cond_resched_rcu(); \ > +}) > + For the rest, I clearly need to revisit when more alert, because right now I am not seeing the connection to preemptible RCU's rcu_read_lock() implementation. Thanx, Paul -- 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/