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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEF66C43461 for ; Tue, 15 Sep 2020 13:51:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DBF420738 for ; Tue, 15 Sep 2020 13:51:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kWSUr2pv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbgIONtq (ORCPT ); Tue, 15 Sep 2020 09:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgIONsb (ORCPT ); Tue, 15 Sep 2020 09:48:31 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B21CC061353 for ; Tue, 15 Sep 2020 06:21:10 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id w3so1001666uad.12 for ; Tue, 15 Sep 2020 06:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w/kdF94weVvZODB/AUs9f/NpmbxAQ75av/THK7S+FHo=; b=kWSUr2pvfEBqdC0GJbcTw32LfLwQVJZ4Jurp7+Fl5teucDdSALr+lDkQJlg3AWmuxH UHZRqZXxupGczvxbeJNyUoGu4lv3BgI0hU42Nqa9idhTcSYHE7EF9CsCouvsOGLyAWbJ 8BEwsRb9CjVil+Tzxz4mUya2EKWBH83lNdynQTFEvCtP94fOHwP552sMh89jskhaLXjV A4xlOKV9VcFOi4aGbgHfqXeQOpDVRm4xZQfOWpOrLcgdtwpLBMXkKWIECKruXWFQiu7j InN/xHzez2Q6xUALABBVn/FSLk5/6FtEy2Gje8nnPGCsdyff3do/3J8CBALMPbtLzdaG WXTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w/kdF94weVvZODB/AUs9f/NpmbxAQ75av/THK7S+FHo=; b=N/QpVjo2bGSonvmgOZ6gVQBj+9JU4MZD+Skxd+sPJ8vx5oOKT8xqOa8ncCJ8k3N+th fsMEo/bpjaxZrzlqVdMlZAHWmyFXbD7bzCZfsd838mXWVO1VovVYVDMW/D/uxvDFTZrh pfkSFiZqWNdYLqZ/p2ZQVJHpX1MNy3IDOOvjC5YQAKeLQR1UgzkYJ80g6zgblb7uhYHs nki4Q2U7XctHNU2PLyUeprVLicKH+tOG6DqI+oQ7QJGQIaI5B01wJkPbxymOcNzMOHzz opNJ2vp40fxzDIsAxcQYpHQrAZnJ21ibxe/Li+uphDkYtr6A3SIBo1e8nVv0Rbmt8A3M k5PQ== X-Gm-Message-State: AOAM532wnigjQ+dwH4KDANoLFBQ4ijPF36URU5dnN1PFUxk+j/1p9OoU pbhHbJkvAicHt1R13ae+hD4bgbaOq53/VBlhxvNT/A== X-Google-Smtp-Source: ABdhPJw2tkkqzsTAYQBMAkSwdJ4a+/HWDG22i9K7BnBMNlT8KvEg3SRWxdng0aXuWW9caPvNIEDB06eAO3j9mhggOfk= X-Received: by 2002:ab0:130a:: with SMTP id g10mr10012968uae.100.1600176064842; Tue, 15 Sep 2020 06:21:04 -0700 (PDT) MIME-Version: 1.0 References: <20200915103157.345404192@infradead.org> <20200915103806.411374792@infradead.org> In-Reply-To: <20200915103806.411374792@infradead.org> From: Ulf Hansson Date: Tue, 15 Sep 2020 15:20:27 +0200 Message-ID: Subject: Re: [RFC][PATCH 3/4] cpuidle: Allow cpuidle drivers to take over RCU-idle To: Peter Zijlstra Cc: "Rafael J. Wysocki" , Borislav Petkov , x86@kernel.org, Tony Luck , Len Brown , Daniel Lezcano , Linux Kernel Mailing List , ACPI Devel Maling List , Linux PM , "Paul E. McKenney" , Thomas Gleixner , Naresh Kamboju Content-Type: text/plain; charset="UTF-8" Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Tue, 15 Sep 2020 at 12:44, Peter Zijlstra wrote: > > Some drivers have to do significant work, some of which relies on RCU > still being active. Instead of using RCU_NONIDLE in the drivers and > flipping RCU back on, allow drivers to take over RCU-idle duty. > > Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/cpuidle/cpuidle.c | 15 ++++++++++----- > include/linux/cpuidle.h | 1 + > 2 files changed, 11 insertions(+), 5 deletions(-) > > --- a/drivers/cpuidle/cpuidle.c > +++ b/drivers/cpuidle/cpuidle.c > @@ -138,6 +138,7 @@ static void enter_s2idle_proper(struct c > struct cpuidle_device *dev, int index) > { > ktime_t time_start, time_end; > + struct cpuidle_state *target_state = &drv->states[index]; > > time_start = ns_to_ktime(local_clock()); > > @@ -153,8 +154,9 @@ static void enter_s2idle_proper(struct c > * suspended is generally unsafe. > */ > stop_critical_timings(); > - rcu_idle_enter(); > - drv->states[index].enter_s2idle(dev, drv, index); > + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) > + rcu_idle_enter(); > + target_state->enter_s2idle(dev, drv, index); > if (WARN_ON_ONCE(!irqs_disabled())) > local_irq_disable(); > /* > @@ -162,7 +164,8 @@ static void enter_s2idle_proper(struct c > * first CPU executing it calls functions containing RCU read-side > * critical sections, so tell RCU about that. > */ > - rcu_idle_exit(); > + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) > + rcu_idle_exit(); > tick_unfreeze(); > start_critical_timings(); > > @@ -239,9 +242,11 @@ int cpuidle_enter_state(struct cpuidle_d > time_start = ns_to_ktime(local_clock()); > > stop_critical_timings(); > - rcu_idle_enter(); > + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) > + rcu_idle_enter(); > entered_state = target_state->enter(dev, drv, index); > - rcu_idle_exit(); > + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) > + rcu_idle_exit(); > start_critical_timings(); > > sched_clock_idle_wakeup_event(); > --- a/include/linux/cpuidle.h > +++ b/include/linux/cpuidle.h > @@ -82,6 +82,7 @@ struct cpuidle_state { > #define CPUIDLE_FLAG_UNUSABLE BIT(3) /* avoid using this state */ > #define CPUIDLE_FLAG_OFF BIT(4) /* disable this state by default */ > #define CPUIDLE_FLAG_TLB_FLUSHED BIT(5) /* idle-state flushes TLBs */ > +#define CPUIDLE_FLAG_RCU_IDLE BIT(6) /* idle-state takes care of RCU */ > > struct cpuidle_device_kobj; > struct cpuidle_state_kobj; > >