Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1842753pxu; Tue, 24 Nov 2020 10:09:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu1WsiiVUtgoKRDzUTfObqvBtssL7wpRhS2EMKFy2Qgv97bD+/6FKHramsY+78Ih6z+pHz X-Received: by 2002:aa7:de01:: with SMTP id h1mr5089583edv.269.1606241342704; Tue, 24 Nov 2020 10:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606241342; cv=none; d=google.com; s=arc-20160816; b=ma91gHF0D7U/BW4dxcOLBXaUAN/+Kk+RojLkQ0I6rBE5VLGh+e24obtaJTVXIGXI3k AKv3tQxZN1NDTLqwuHppvPJ806C2pzWjBJLhNFuQVA+Jh1Z9iyaGCavaDR/uiaVTU3mH AqkvLk2GiJDbiah8iFHTIwADCIcZ/v8lEH6pyMrM7Pb8Mi5kC8LryS/e1Wix5lWCoju4 cgMrGS6+zTxGRVRHbkrACE8Ny0fDIKdXsc9bwNStBing6LiVj41nxKmSnNBtGTP58uLR 7QK+bNXAsz0/ESkOyO6xw9AHGpwGQnnsqRKprkyWlXJzOekgrv07KtuC0w6yoHYRvSWz EeEg== 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=nWFv04C1aAnXjvsHTOHLO2Kr4hkB813nT+onDe8MWFw=; b=C0Zp/4POmelrjaKxBb0Zfg2GEjDaG69Y8SuD8QTP7UEZASmmvEEe4eollIgJyR3xnB FSWhZZ8WS5S9Xd/4Bpv3mrQ+2RA6wiNooiaCSva4U87kqmfW247QmbR4bYzNX8uqoTGr zfiCdBMRlma09sn/i5T4Pq/4CQPHZqW05+0cNFyy78gEzCKZyiHf9AtnJWqpNaKExg1Q QFuBrLPbbz08U8s84yqU85QMxYOjrBtj3WQi9McEQCNOrWeruMWLbZMyTaGY6qZTs5x/ ygX30WldWY2ckGv0wcN+JjKB2i+UC2D4vJ7d/lWY5IwQkcNF4MdbFl+STXye78QUsw6l 4vjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=MRahNLdp; 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 m1si9842660ejj.517.2020.11.24.10.08.37; Tue, 24 Nov 2020 10:09:02 -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=@joelfernandes.org header.s=google header.b=MRahNLdp; 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 S2404105AbgKXSDq (ORCPT + 99 others); Tue, 24 Nov 2020 13:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403801AbgKXSDq (ORCPT ); Tue, 24 Nov 2020 13:03:46 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47A4AC0613D6 for ; Tue, 24 Nov 2020 10:03:46 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id ek7so11052302qvb.6 for ; Tue, 24 Nov 2020 10:03:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nWFv04C1aAnXjvsHTOHLO2Kr4hkB813nT+onDe8MWFw=; b=MRahNLdp5B6MkRwnkpsjvZLI2HqXqUCyH+f0qWb8eezThEJH0D3+nw+bmJrz3s6Jmw siBwHcmr/3gS3u3KmZqy/v74V/k0i8yy9n2XNJiGl+eWZislwPwWHZbMRuE1Wr/VoBiO PaKAprpmdDoSxZ+O0CoEUrVVYU9+pkr0SYDQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nWFv04C1aAnXjvsHTOHLO2Kr4hkB813nT+onDe8MWFw=; b=W2zRuhfJYW6AcMLJliOsgEOhzuKxzBxM9HU1yWttpRUiKXoTuSKUT8rB6eFxIQKyEc GT5GvTJ3ILo8guedT4+KZ6XTzoOBKYMTp+q2fUm6jRPO/qaaMGf1VprmIsa4zvKCf3ij FN3lbM+etoEPVhRKspadYnP7T6PR25sHHHf09ERbIy7NGqSUOJ4EqBhSygjrLWALHRFa 8TXzYXpPNXsia7yF5LYPI9fjDO8rueELSJeCr/uUhtwJLhORaoqgHLCTXuC5iZ2PnSMf TlUOn2Kx2+cwlYoyvWqgwhvzDpgENnVTXeSb6zhK72VxAp05WyXeRmOd6Zq/AzktU8sd XaXA== X-Gm-Message-State: AOAM53144yuTxwpbUA1S7xa+vW6hHnqlB0zvAsYWBCkvMyW8plzeUtsz Z/6lQ4IsMtmRYe3YyBowR4MZHw== X-Received: by 2002:a0c:b351:: with SMTP id a17mr5850839qvf.7.1606241025070; Tue, 24 Nov 2020 10:03:45 -0800 (PST) Received: from localhost ([2620:15c:6:411:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id q34sm15454703qtq.45.2020.11.24.10.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 10:03:44 -0800 (PST) Date: Tue, 24 Nov 2020 13:03:43 -0500 From: Joel Fernandes To: Peter Zijlstra 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: <20201124180343.GF1021337@google.com> References: <20201117232003.3580179-1-joel@joelfernandes.org> <20201117232003.3580179-20-joel@joelfernandes.org> <20201124161335.GB3021@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124161335.GB3021@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 24, 2020 at 05:13:35PM +0100, Peter Zijlstra wrote: > 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.. Yeah sorry :-\. The naming I chose was to be aligned with the CONFIG_GENERIC_ENTRY naming. I am open to ideas on that. > > 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? The way this patch series works, it does not depend on arch code as much as possible. Since there are other arch that may need this patchset such as ARM, it may be better to keep it in the generic entry code. Thoughts? thanks, - Joel