From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83D59C61D92 for ; Tue, 21 Nov 2023 01:01:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 012926B0392; Mon, 20 Nov 2023 20:01:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F04646B03AB; Mon, 20 Nov 2023 20:01:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1A7A6B03AF; Mon, 20 Nov 2023 20:01:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D35656B0392 for ; Mon, 20 Nov 2023 20:01:07 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ADC10140AB8 for ; Tue, 21 Nov 2023 01:01:07 +0000 (UTC) X-FDA: 81480157374.03.AD0B183 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf25.hostedemail.com (Postfix) with ESMTP id 0049DA001B for ; Tue, 21 Nov 2023 01:01:04 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=daSGM7So; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of "SRS0=TAUs=HC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=TAUs=HC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700528465; a=rsa-sha256; cv=none; b=EXCz5stG7SbzSLeSD4680aTOFfrPCAEKqJ/nfkoRmuEUvFz8hkkS7PscmSRMqG+HjrR5az CEwvmPqV6QBAf92yfeQOhpO/guuePzWkC1IAEDdNhWvK2MC4nePILOK2XX5q5MScTY3p51 pTn7YlmVRmnnnQin44uU+Nly4o6GSb8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=daSGM7So; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of "SRS0=TAUs=HC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=TAUs=HC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700528465; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=giXW2mAVLYNZ/+TJrHB/Qqnah8n3LLn5kugO0cqreD0=; b=OE3RXjdhSe3MJ3nRCnE15tlGc0/n54lhd0R6TKss1406Mex5GNqCVg6TvuKTwZpViA6g8y 3xcLAPfWA+pbC0ejqBnyi1OFi2E1HUgN6k6VgBkA+a7tkzijlDQ7aIPKy1E0dBZvW109iX ohbu/Q9yhkhwebTOKP1/geNrZRmQ6As= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A3BFDCE181B; Tue, 21 Nov 2023 01:01:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D70F2C433C8; Tue, 21 Nov 2023 01:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700528460; bh=eFuGQ34wGE9sgrcqAbpQQH2cWyCk63YT2cso4pX9XSM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=daSGM7Soy9XlDP5Fe0btjSlPrxR1IBF9mwLgUIao/L6A9JP7pa336eFCFwY95Zo1x xhlkNjdhvgM4AyXhuzNfrM4YCWv20+I5dnQUeGNFLrDVJJDfB+kDODmLkSy+2mesU2 lg8s8HzEUczfgx8OfkgL/Y0YhEk0jPi5ndqt9EvsovVzVIsvDT9fBEGJpqN4oHZD5v jU8jbyisBPvdWoxqnZXrD+S/hgzKwyKM+sjERNzwH6llrbUgCxvg+Fryk+1WqZO0Lf KF2F+YeZ5nOV7Q18piwe05DzkT8jGuvZrsO3XfszF47ujR+oFSPbku9dYH+xlM/+bI 1gQwvLtem26Aw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 72F13CE1390; Mon, 20 Nov 2023 17:01:00 -0800 (PST) Date: Mon, 20 Nov 2023 17:01:00 -0800 From: "Paul E. McKenney" To: Ankur Arora Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, jgross@suse.com, andrew.cooper3@citrix.com, mingo@kernel.org, bristot@kernel.org, mathieu.desnoyers@efficios.com, geert@linux-m68k.org, glaubitz@physik.fu-berlin.de, anton.ivanov@cambridgegreys.com, mattst88@gmail.com, krypton@ulrich-teichert.org, rostedt@goodmis.org, David.Laight@aculab.com, richard@nod.at, mjguzik@gmail.com, Frederic Weisbecker Subject: Re: [RFC PATCH 59/86] treewide: rcu: remove cond_resched() Message-ID: Reply-To: paulmck@kernel.org References: <20231107215742.363031-1-ankur.a.arora@oracle.com> <20231107230822.371443-1-ankur.a.arora@oracle.com> <20231107230822.371443-3-ankur.a.arora@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231107230822.371443-3-ankur.a.arora@oracle.com> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0049DA001B X-Stat-Signature: gbq6w1zsooxjodsfnpsibumawcg678a7 X-HE-Tag: 1700528464-62353 X-HE-Meta: U2FsdGVkX19Bkv4GOrUdq/c35PlePN6osficqW+cwng1iKZeVRqwdRjk6xM3a99hdD2rwHGGlf82u0PtM4I08KpKYjQsGWEO7iEoEPB7BPBliVwdErhTKYbwegXBQOD4PsUa4IzBcauTZokk7G81q430h27WZrlnJhHwIqHcXMkbATvERJpzAvhT2+KPLz8YuKB1sWejQpmOsQo0i5pCDaSlMK0kn62R5SfWkq5rtGCeApGgne21B0Eu6z0UoG62HuipBkzLYela2FIU4woh9ldzLeBt4D1y4Lnk5+VLam3QRtuMXlCCtzmKGGOr9UwVcg28Co2TScBpQmqHwrC6UM5gUblEoMCeFNcssaIhuj/Iw+GnCzc2ENfq1QG4GOqomoYMilzYqurE1OQRQK3eD/8ZoM3kn1/5N1kjA857bX4emdNpYEZEkvhAHSkltAbxzdGVn4Ih40bQwOXMtck+e6aCJJiNtPVGIBBbML3/R3x8Sd4vNesc/4DZ28upvOuuil8ADfvqgrqLzNImbduriq5WGYNKAa2jN2PkTZVYGBccfar8Wk0eO37o5B8uKEcfoggWTyFtVm3HOveHNLnx3exZaSY74/VrlnaLZJgaZ906wTk/r4c3Q0lWChxjJ+kLh3QVq2647Hl90xqH9rmKeilwZLEJ/RrSlY8rLitpArPIRmqo4CmyIEtWKALP6MLJxwI+Qj1LDw5gqvdf/65pMKC6a4kp7dgLuYjpy3esDUNxcNCuXFJAKhoSoc7vgdYaOUyFf3Z1PKMX/ZxUx1ShcNPlJ0QuhGwO80C0o/56epW9jkvoijd7O90wASafMY4qqvVW8aCUB13XbJnV8hyTsYapPLYlrAZZS+kw1dtB0TUzGzsKknQIst79D+qieu8VdSpSsUzD/3bebGctW57HOTkwrfakIA7sXTrunoP9PQ0XM30nDOiywB90/kXy+0B9w3HZrXfDJjvjulOrxSZ fFNUi88r xc+2iyrmjzKjj5lEcrS8PhJIpFBRm/yAMAnEr1AvezmzyrQf6xmdFjH9gXZmfqPhMSL5os6ihPYY0OCrbXJc7w9pzI/eCDLpSp9dMurauzjh7d8m4ANK62Uu6xQPQHGj4/3aBXBC+IuYUhUtNvYR7rEkVncdYMDLPC8EPjoEEkpGVTclZgiBJZn2xxC9O17crvv09OPNyc2sDfk6JEinn8wvEN+8jfykAw2L99vBmNX3dxH4R37uCb9CJiCnysO+DvHBGq9pT9v/0Byj64zPmJ07i+YJafs2RXFJQIRtJxu61LLt4DKMgDkCXR/TOT4uRvgYBTlElRaGIUwXyATJzv8VhPFuwK/OePJw5pXMwtYqbuBOk145/1SrlQZ7db01onUjTJwp7TIWhgqbEyJTAB1QN0jEIigRC+cIJMYVPisLgcE9NZgGo5U1yEHvgPyvLrJyldc3BT5sLFz5O4T1uoGtcugGrYk+QJ65ks47B3x9bV/mcTsWR/kRdqzjKRT2jPG/nPcKcLI5rEM/0i31BetRK4QLFEbaXc300NqGWicvssjRrlyNRD5aodAG1BXanZVs1CTdIWSw4FZEcQPKeKRU0GGzzMgjsUCMKAAHABP5ZAfu54A4Akk93TrKJ+ov9FVR0yUujhBUiUBOqa/KlzcThuMeIUVFXUFGXwvwToHC5CXHRPVCnA7p/0TEBpOQPphSWPADNz7rsoAh0TUTucdsbpVfBcCngCA5WX1mIsh1qdrI8ZWlTMGrpwybl+PQGIqCZuH69fw07T5xTPXTIS1cC8K6oUa/mGG24sU9DdXIg4IMgSEc50scEaA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Nov 07, 2023 at 03:07:55PM -0800, Ankur Arora wrote: > All the cond_resched() calls in the RCU interfaces here are to > drive preemption once it has reported a potentially quiescent > state, or to exit the grace period. With PREEMPTION=y that should > happen implicitly. > > So we can remove these. > > [1] https://lore.kernel.org/lkml/20231107215742.363031-1-ankur.a.arora@oracle.com/ > > Cc: "Paul E. McKenney" > Cc: Frederic Weisbecker > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Juri Lelli > Cc: Vincent Guittot > Signed-off-by: Ankur Arora > --- > include/linux/rcupdate.h | 6 ++---- > include/linux/sched.h | 7 ++++++- > kernel/hung_task.c | 6 +++--- > kernel/rcu/tasks.h | 5 +---- > 4 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 7246ee602b0b..58f8c7faaa52 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -238,14 +238,12 @@ static inline bool rcu_trace_implies_rcu_gp(void) { return true; } > /** > * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU > * > - * This macro resembles cond_resched(), except that it is defined to > - * report potential quiescent states to RCU-tasks even if the cond_resched() > - * machinery were to be shut off, as some advocate for PREEMPTION kernels. > + * This macro resembles cond_resched(), in that it reports potential > + * quiescent states to RCU-tasks. > */ > #define cond_resched_tasks_rcu_qs() \ > do { \ > rcu_tasks_qs(current, false); \ > - cond_resched(); \ I am a bit nervous about dropping the cond_resched() in a few cases, for example, the call from rcu_tasks_trace_pregp_step() only momentarily enables interrupts. This should be OK given a scheduling-clock interrupt, except that nohz_full CPUs don't necessarily have these. At least not unless RCU happens to be in a grace period at the time. > } while (0) > > /* > diff --git a/include/linux/sched.h b/include/linux/sched.h > index 199f8f7211f2..bae6eed534dd 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -2145,7 +2145,12 @@ static inline void cond_resched_rcu(void) > { > #if defined(CONFIG_DEBUG_ATOMIC_SLEEP) || !defined(CONFIG_PREEMPT_RCU) > rcu_read_unlock(); > - cond_resched(); > + > + /* > + * Might reschedule here as we exit the RCU read-side > + * critical section. > + */ > + > rcu_read_lock(); And here I am wondering if some of my nervousness about increased grace-period latency due to removing cond_resched() might be addressed by making preempt_enable() take over the help-RCU functionality currently being provided by cond_resched()... > #endif > } > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index 9a24574988d2..4bdfad08a2e8 100644 > --- a/kernel/hung_task.c > +++ b/kernel/hung_task.c > @@ -153,8 +153,8 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) > * To avoid extending the RCU grace period for an unbounded amount of time, > * periodically exit the critical section and enter a new one. > * > - * For preemptible RCU it is sufficient to call rcu_read_unlock in order > - * to exit the grace period. For classic RCU, a reschedule is required. > + * Under a preemptive kernel, or with preemptible RCU, it is sufficient to > + * call rcu_read_unlock in order to exit the grace period. > */ > static bool rcu_lock_break(struct task_struct *g, struct task_struct *t) > { > @@ -163,7 +163,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t) > get_task_struct(g); > get_task_struct(t); > rcu_read_unlock(); > - cond_resched(); > + > rcu_read_lock(); > can_cont = pid_alive(g) && pid_alive(t); > put_task_struct(t); > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h > index 8d65f7d576a3..fa1d9aa31b36 100644 > --- a/kernel/rcu/tasks.h > +++ b/kernel/rcu/tasks.h > @@ -541,7 +541,6 @@ static void rcu_tasks_invoke_cbs(struct rcu_tasks *rtp, struct rcu_tasks_percpu > local_bh_disable(); > rhp->func(rhp); > local_bh_enable(); > - cond_resched(); ...and by local_bh_enable(). Thanx, Paul > } > raw_spin_lock_irqsave_rcu_node(rtpcp, flags); > rcu_segcblist_add_len(&rtpcp->cblist, -len); > @@ -974,10 +973,8 @@ static void check_all_holdout_tasks(struct list_head *hop, > { > struct task_struct *t, *t1; > > - list_for_each_entry_safe(t, t1, hop, rcu_tasks_holdout_list) { > + list_for_each_entry_safe(t, t1, hop, rcu_tasks_holdout_list) > check_holdout_task(t, needreport, firstreport); > - cond_resched(); > - } > } > > /* Finish off the Tasks-RCU grace period. */ > -- > 2.31.1 >