Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1760709pxu; Tue, 24 Nov 2020 08:18:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjdCUVGy4ulH3+zV5yQmFmvBqeKuUvL7oODBmFeIjsIBUKbBp0nneMApwM7K2ak+E93lGz X-Received: by 2002:a05:6402:b28:: with SMTP id bo8mr4778720edb.57.1606234702485; Tue, 24 Nov 2020 08:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606234702; cv=none; d=google.com; s=arc-20160816; b=AILyOsWQZDwa9RGyxjlcPeZNj5JBquFbAoKGduHxz75VmHrywZGlhlufZwP/LtNNtC g54hUgg4OkVOTFVVwlb2uxHhBYMO4+G2r/E3SB8B7bxHWn83DpePijz/HRHpjKql/svj mPa3aDdrrkM6LKSORvO/+oIHeSpmbOGD9J1Hhs8z7+/XD6KwuN0AYSkKqca/Ki2L47AM uziwsNBawif8jURV89N43qSL2IPfvawfwlqSqhxsliIpAGKbKlOmzXvpFdug7HPI5BZ8 MsfZFO9BNXCFnAnog6pPcGHSSeZ3PCc9JpNzBPiVP81KGUSgQy1WMWQIewFqJmtJfbzP Sv3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/1kCWnd3feKEZ2BNY0EBqrEBKNfPzZjxoqXEKQGIzvM=; b=eWarts2B8Es6TtQHKlPVQUWuuhUzbdwjdt4sZaHz3lkMnUoQ+41TM+oI7XtKtlawc5 xoLJNv/4v2dXCcxc7HhHwKTnVSdeqhMhJW+PkDkV/GdKNpeMUcKgG9TOtGdQdtm0VF9k WNcXy1detFKtm9cz3ouPpYRxT2OE9Y3aVhtfVdVA1CUrrEOsx71i9W5ITX9QZMi3Q0jF 9s0i9j6nBiZgsMi3CmDqyxIG08KBzhQXPUkyOgiDyt1eJFpbuvvhr79w9oc10vAhZZtH R7qmuDR7RBU32/TjY3L3VHCIc0XqyikZkjunSOJ8uATLl5hLkCBbWg/PY7ImJzYfirsl 1IkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=U6Ify2qu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si8447845edz.265.2020.11.24.08.17.59; Tue, 24 Nov 2020 08:18:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=U6Ify2qu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390143AbgKXQOk (ORCPT + 99 others); Tue, 24 Nov 2020 11:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389424AbgKXQOj (ORCPT ); Tue, 24 Nov 2020 11:14:39 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE435C0613D6 for ; Tue, 24 Nov 2020 08:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/1kCWnd3feKEZ2BNY0EBqrEBKNfPzZjxoqXEKQGIzvM=; b=U6Ify2qunErItlzQIuaLuG1RGm 2J8nOfxIjjQVT2MvNXuSaqYWI5Ot6CbunbyaGKRhLdzrv9+GQpMyzdihjo079ocKcXpzJlfycdVN0 Oa13yi9a20EQCbZ2PrAbDrTgRf2KjUYQMP9wb5bMsV/ARG1af0tMx3SgDUBkWyLn6rqTwQOnG+fL0 2Evqo6udgxpOjViHAz/93arflja2DIkfySSUnWmAPcRJuUp/AcfA0jv68q/n+puhnmaAd1j3wKSXQ n4o2f1KSvcq2XU34v5vAYfGeET6W0s5jrBEB+VprcFytc9hsxUTt/6oL2DFdHgxXliZdEcPY8gYg4 r36epBdA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1khawj-0001gk-3k; Tue, 24 Nov 2020 16:13:38 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C5EBB3012DF; Tue, 24 Nov 2020 17:13:35 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id AFA1B201ABB33; Tue, 24 Nov 2020 17:13:35 +0100 (CET) Date: Tue, 24 Nov 2020 17:13:35 +0100 From: Peter Zijlstra To: "Joel Fernandes (Google)" Cc: Nishanth Aravamudan , Julien Desfossez , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, dfaggioli@suse.com, pjt@google.com, rostedt@goodmis.org, derkling@google.com, benbjiang@tencent.com, Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , jsbarnes@google.com, chris.hyser@oracle.com, Ben Segall , Josh Don , Hao Luo , Tom Lendacky , Aubrey Li , "Paul E. McKenney" , Tim Chen Subject: Re: [PATCH -tip 19/32] entry/idle: Enter and exit kernel protection during idle entry and exit Message-ID: <20201124161335.GB3021@hirez.programming.kicks-ass.net> References: <20201117232003.3580179-1-joel@joelfernandes.org> <20201117232003.3580179-20-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117232003.3580179-20-joel@joelfernandes.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 06:19:49PM -0500, Joel Fernandes (Google) wrote: > Add a generic_idle_{enter,exit} helper function to enter and exit kernel > protection when entering and exiting idle, respectively. > > While at it, remove a stale RCU comment. > > Reviewed-by: Alexandre Chartre > Tested-by: Julien Desfossez > Signed-off-by: Joel Fernandes (Google) > --- > include/linux/entry-common.h | 18 ++++++++++++++++++ > kernel/sched/idle.c | 11 ++++++----- > 2 files changed, 24 insertions(+), 5 deletions(-) > > diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h > index 022e1f114157..8f34ae625f83 100644 > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h > @@ -454,4 +454,22 @@ static inline bool entry_kernel_protected(void) > return IS_ENABLED(CONFIG_SCHED_CORE) && sched_core_kernel_protected() > && _TIF_UNSAFE_RET != 0; > } > + > +/** > + * generic_idle_enter - General tasks to perform during idle entry. > + */ > +static inline void generic_idle_enter(void) > +{ > + /* Entering idle ends the protected kernel region. */ > + sched_core_unsafe_exit(); > +} > + > +/** > + * generic_idle_exit - General tasks to perform during idle exit. > + */ > +static inline void generic_idle_exit(void) > +{ > + /* Exiting idle (re)starts the protected kernel region. */ > + sched_core_unsafe_enter(); > +} > #endif That naming is terrible.. > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > index 8bdb214eb78f..ee4f91396c31 100644 > --- a/kernel/sched/idle.c > +++ b/kernel/sched/idle.c > @@ -8,6 +8,7 @@ > */ > #include "sched.h" > > +#include > #include > > /* Linker adds these: start and end of __cpuidle functions */ > @@ -54,6 +55,7 @@ __setup("hlt", cpu_idle_nopoll_setup); > > static noinline int __cpuidle cpu_idle_poll(void) > { > + generic_idle_enter(); > trace_cpu_idle(0, smp_processor_id()); > stop_critical_timings(); > rcu_idle_enter(); > @@ -66,6 +68,7 @@ static noinline int __cpuidle cpu_idle_poll(void) > rcu_idle_exit(); > start_critical_timings(); > trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); > + generic_idle_exit(); > > return 1; > } > @@ -156,11 +159,7 @@ static void cpuidle_idle_call(void) > return; > } > > - /* > - * The RCU framework needs to be told that we are entering an idle > - * section, so no more rcu read side critical sections and one more > - * step to the grace period > - */ > + generic_idle_enter(); > > if (cpuidle_not_available(drv, dev)) { > tick_nohz_idle_stop_tick(); > @@ -225,6 +224,8 @@ static void cpuidle_idle_call(void) > */ > if (WARN_ON_ONCE(irqs_disabled())) > local_irq_enable(); > + > + generic_idle_exit(); > } I'm confused.. arch_cpu_idle_{enter,exit}() weren't conveniently placed for you?