Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36481540rwd; Tue, 11 Jul 2023 01:20:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsS9XTXkibcB/8AFwTSjj6fYbbtUalAHahSivDbyC+o6VjSFxmjvugLA/rBDIQu2IcJHel X-Received: by 2002:a17:906:b307:b0:992:4c42:581c with SMTP id n7-20020a170906b30700b009924c42581cmr12800713ejz.62.1689063601568; Tue, 11 Jul 2023 01:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689063601; cv=none; d=google.com; s=arc-20160816; b=JL791redbKyMnmC9O3vZ0vrf3317RSCJXmDG/s0yrRSPxI+3Iyj/gnMlk/qwb9WjJO sQ3WK6XfhN+aUnmbjA8QpCYQqyyE1eoKffdg9Pzg67jU1k3spp4yDRWkjCbYHMbvxh/6 dgjxrOtcJZyVw0APtp7vM2/FMWG7Du4yKM7WkiEHzVkm2yIiWWd0Lq4FF4uosV5/xGu+ aYPp4yBPQAG4Ntq6yhICSLXDmfYPA2L8HzldSGjA5I85D06qUBzri6Rkrtl/7A5KvtBC NbXr0s9R8NcNbX2ezxbQlHBluxL5Lic38LTR7Y+qauO5/wzNB5tG/Ae0sK55eBUyDnce 7BOQ== 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=XtqhhCxrscYtAF+o0y3E3eFRGgnUA7fzd0enBwWepxU=; fh=lYqMUOXGDfK5By6LGHoOufbi64DJ6W1DKbYals9yhTc=; b=i1ArbISQtuyr6QIBlWvIpBdbadvGsCHnkTj63nZhmu9VTqJqeoGSeu8e4As1+JPjRQ x5RDnS8zqO9+sl98YHjL6t1URosgEcDnZkYGexQi/CuXJg853H1a0iVpg+pv2L47oH0/ +TUAQ1i+lwsrW+4U5Lq+75IYFeoJum3Tdo4SfzUDqDoLOuEpoGadtYVdsXc+3jvNxUVL OYx87HjkrE5FuAjo7qQlvJpu3o8PpxqBos9wQcUivYS1Nmg3HGoXekKOrhx7MtgkmwO7 D3Yuo0x7krlIP4R69g9i3xWePpLe0fJt6iCLBNi49vNuqB80MAbFh6YyT2cfajJzEWSN DjsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=MQgQgqxo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p24-20020a1709060e9800b00992acf279afsi1357528ejf.928.2023.07.11.01.19.38; Tue, 11 Jul 2023 01:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=MQgQgqxo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbjGKHmw (ORCPT + 99 others); Tue, 11 Jul 2023 03:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbjGKHmv (ORCPT ); Tue, 11 Jul 2023 03:42:51 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69FCB1A2; Tue, 11 Jul 2023 00:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=XtqhhCxrscYtAF+o0y3E3eFRGgnUA7fzd0enBwWepxU=; b=MQgQgqxoay5mhCv5KD37I/giKm MWeK1ixJjh5CZPTJHP841zcuEHc00GrF5vNJQK4pNI+WMP33z7lk0uQpXB+DedAwcQBT1CuAnjFUF Q/mCkvAMNBM9PdshGsOnToHAnYa7L0OagLT56mhJmmhk1NQbbUvumljxCV2rhWHPdySD8LFcczGxm zJaYHUUff3h/73uoamrGoclf36wn0pfv4ea/8/Rv4E0z75LEyOE1LfNjgoXi3mfn1FNmfzjwzDnKa L0lMGc+fk5xhPVu17MSotNCoPMNQ9/yd07Gx9I6I6FlAmRzeLKAd+C4BDOSdlSMnGbhXW9uFMv4My ahaxyyTQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qJ813-002IBT-0B; Tue, 11 Jul 2023 07:42:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 0279B30014A; Tue, 11 Jul 2023 09:42:31 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DCB9B240EBDBA; Tue, 11 Jul 2023 09:42:31 +0200 (CEST) Date: Tue, 11 Jul 2023 09:42:31 +0200 From: Peter Zijlstra To: Kazuki Hashimoto Cc: "Rafael J. Wysocki" , Daniel Lezcano , Ingo Molnar , Len Brown , Pavel Machek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Hector Martin Subject: Re: [PATCH 1/2] cpuidle: Don't pass any values to cpuidle_not_available Message-ID: <20230711074231.GD3062772@hirez.programming.kicks-ass.net> References: <20230711-cpuidle-v1-0-f391224b3140@gmail.com> <20230711-cpuidle-v1-1-f391224b3140@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230711-cpuidle-v1-1-f391224b3140@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2023 at 02:54:21PM +0900, Kazuki Hashimoto wrote: > There's no reason to pass any values to cpuidle_not_available() as the > function works standalone. Since we're planning to use the function in > other places, make it so to avoid code duplication. > > Signed-off-by: Kazuki Hashimoto > --- > drivers/cpuidle/cpuidle.c | 6 ++++-- > include/linux/cpuidle.h | 6 ++---- > kernel/sched/idle.c | 2 +- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c > index 737a026ef58a..c9ba51e0fa38 100644 > --- a/drivers/cpuidle/cpuidle.c > +++ b/drivers/cpuidle/cpuidle.c > @@ -49,9 +49,11 @@ void disable_cpuidle(void) > off = 1; > } > > -bool cpuidle_not_available(struct cpuidle_driver *drv, > - struct cpuidle_device *dev) > +bool cpuidle_not_available(void) > { > + struct cpuidle_device *dev = cpuidle_get_device(); > + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); > + > return off || !initialized || !drv || !dev || !dev->enabled; > } It appears to me these are a lot of conditions to check *every* time we go idle -- especially since they hardly, if ever, change. Can't cpuidle track all this in a single global variable, preferably as a static_key ?