From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966722AbcIVSa2 (ORCPT ); Thu, 22 Sep 2016 14:30:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58564 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966694AbcIVSaX (ORCPT ); Thu, 22 Sep 2016 14:30:23 -0400 Date: Thu, 22 Sep 2016 11:30:20 -0700 From: "Paul E. McKenney" To: Mikulas Patocka Cc: hpa@zytor.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, torvalds@linux-foundation.org, mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, linux-kernel@vger.kernel.org, oleg@redhat.com, linux-tip-commits@vger.kernel.org Subject: Re: [tip:sched/core] sched/core: Avoid _cond_resched() for PREEMPT=y Reply-To: paulmck@linux.vnet.ibm.com References: 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-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16092218-0004-0000-0000-000010729103 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005804; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00760311; UDB=6.00361667; IPR=6.00534831; BA=6.00004748; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012750; XFM=3.00000011; UTC=2016-09-22 18:30:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16092218-0005-0000-0000-000079212B00 Message-Id: <20160922183020.GP14933@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-22_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609220323 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 22, 2016 at 02:25:01PM -0400, Mikulas Patocka wrote: > I've found a document that says that cond_resched() is needed on > preemptible kernels to mark RCU quiescent states: > > https://lwn.net/Articles/603252/ > > Paul, is cond_resched() still needed on current RCU implementation? Or not? It can be if you loop in the kernel for a very long time. But cond_resched_rcu_qs() is instead needed in cases where there is only one runnable non-idle non-nohz task on a given CPU. Thanx, Paul > Mikulas > > > > On Thu, 22 Sep 2016, tip-bot for Peter Zijlstra wrote: > > > Commit-ID: 35a773a07926a22bf19d77ee00024522279c4e68 > > Gitweb: http://git.kernel.org/tip/35a773a07926a22bf19d77ee00024522279c4e68 > > Author: Peter Zijlstra > > AuthorDate: Mon, 19 Sep 2016 12:57:53 +0200 > > Committer: Ingo Molnar > > CommitDate: Thu, 22 Sep 2016 14:53:46 +0200 > > > > sched/core: Avoid _cond_resched() for PREEMPT=y > > > > On fully preemptible kernels _cond_resched() is pointless, so avoid > > emitting any code for it. > > > > Signed-off-by: Peter Zijlstra (Intel) > > Cc: Linus Torvalds > > Cc: Mikulas Patocka > > Cc: Oleg Nesterov > > Cc: Peter Zijlstra > > Cc: Thomas Gleixner > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Ingo Molnar > > --- > > include/linux/sched.h | 4 ++++ > > kernel/sched/core.c | 2 ++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index f00ee8e..b99fcd1 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -3209,7 +3209,11 @@ static inline int signal_pending_state(long state, struct task_struct *p) > > * cond_resched_lock() will drop the spinlock before scheduling, > > * cond_resched_softirq() will enable bhs before scheduling. > > */ > > +#ifndef CONFIG_PREEMPT > > extern int _cond_resched(void); > > +#else > > +static inline int _cond_resched(void) { return 0; } > > +#endif > > > > #define cond_resched() ({ \ > > ___might_sleep(__FILE__, __LINE__, 0); \ > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index b2ec53c..d7babcc 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -4883,6 +4883,7 @@ SYSCALL_DEFINE0(sched_yield) > > return 0; > > } > > > > +#ifndef CONFIG_PREEMPT > > int __sched _cond_resched(void) > > { > > if (should_resched(0)) { > > @@ -4892,6 +4893,7 @@ int __sched _cond_resched(void) > > return 0; > > } > > EXPORT_SYMBOL(_cond_resched); > > +#endif > > > > /* > > * __cond_resched_lock() - if a reschedule is pending, drop the given lock, > > >