From patchwork Thu Oct 15 14:44:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 286785 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 4641FC433DF for ; Thu, 15 Oct 2020 14:44:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF151212CC for ; Thu, 15 Oct 2020 14:44:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vlBsPkdy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388795AbgJOOon (ORCPT ); Thu, 15 Oct 2020 10:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388790AbgJOOom (ORCPT ); Thu, 15 Oct 2020 10:44:42 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF36C0613D2 for ; Thu, 15 Oct 2020 07:44:42 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id h7so3835781wre.4 for ; Thu, 15 Oct 2020 07:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=soOA4oYAhoT9qwZTBOd2JvR9jvEOzaqFrTAOBqyp4f0=; b=vlBsPkdyH8oejvdNlnl86nagXsrdmsxHvUCaJM+QjEw8FPG0xv3b17ZWs2bM2xAUR4 vYBnXKnwfopyoMFCSfhME1KQGNKrdXSOv5N2AMthdQ7vCzdbI1DzgNho+6EEqmEaDNZF Z6nEw/JKGtDxDSvxRTA15F3OGOKlWgyPSg7KncoKfy38zZj/PtUER8UYermCLrShyiHK FfzgU+NKrN8D+pgmzW4iKfWeeLOywlzqz7PnYJ4XlAe+HY0nzNP+LZvPJH8aSI1n5RHy y5OKgFI6R6lHjXzlnSA0tbu5fRw9Eo1dF45crxpcUNleW0CzS38ZDy+4NYPzEAkGp45S 5+QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=soOA4oYAhoT9qwZTBOd2JvR9jvEOzaqFrTAOBqyp4f0=; b=HJUuY3DLdAh7SBd2+Jpd67bUkUeS2363ua4Fk7aCM6l/+w8LelzqEP6L3zmr35ejjS JPLUV0D2434DQV1v9r6vlwF1qicpZProg3zuYzCtfnQgs++ldkL4HQurobTZzK2pp35e ljWK+mX74iVqcq553828STD506SlTHR1fSJOJMdvNFFmXugPz2/ByvfNm00PGBMDLqlr j+27UhlBRG3tnzNQAL3Cx3brEQtG+ckYeJVDmc0A05rBguGxi1B5epLFelRSzWw4V3LU cT7rT03ihJSA0nciDs0/MFMEVe8pCPyxdCZIdXRRG82xiyNXr8MjnNOUa/Jz/JqFzoHF DxeA== X-Gm-Message-State: AOAM532nuqZaEaoDJdkL0ccPpw5cDM/ZTD4cyLLAgX2IdFFvDOKo67ju bMX+mSXm2ZcLe2aBBnhPUBO0vbnrYCDm5A== X-Google-Smtp-Source: ABdhPJzBmoNj4CR7eehnW501dpYjt5vXWvCzTXToYHQs64VPdWP4Kl1AqPrwgqU27sJO9yY17hw0ww== X-Received: by 2002:a5d:6a43:: with SMTP id t3mr4911757wrw.426.1602773081012; Thu, 15 Oct 2020 07:44:41 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-134-136.adsl.proxad.net. [82.252.134.136]) by smtp.gmail.com with ESMTPSA id 40sm5053800wrc.46.2020.10.15.07.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 07:44:40 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ilina@codeaurora.org Subject: [PATCH 1/5] cpuidle: Remove pointless stub Date: Thu, 15 Oct 2020 16:44:27 +0200 Message-Id: <20201015144431.9979-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpuidle.h header is declaring functions with an empty stub when cpuidle is not enabled. However these functions are only called from the governors which depends on cpuidle. In other words, when the function is called it is when cpuidle is enabled, there is no situation when it is called with cpuidle disabled. Remove the pointless stub. Signed-off-by: Daniel Lezcano --- include/linux/cpuidle.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 6175c77bf25e..74fdcc6106b1 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -270,13 +270,8 @@ struct cpuidle_governor { void (*reflect) (struct cpuidle_device *dev, int index); }; -#ifdef CONFIG_CPU_IDLE extern int cpuidle_register_governor(struct cpuidle_governor *gov); extern s64 cpuidle_governor_latency_req(unsigned int cpu); -#else -static inline int cpuidle_register_governor(struct cpuidle_governor *gov) -{return 0;} -#endif #define __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, \ idx, \ From patchwork Thu Oct 15 14:44:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 317774 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp558039ilm; Thu, 15 Oct 2020 07:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8bsG0wlSsSrZ0GSdy6l9y0q7PZrflVw19GgJ5z4mS4EgljEqlbg/az6JgRw1prdpaN73y X-Received: by 2002:a50:b023:: with SMTP id i32mr4573657edd.357.1602773088441; Thu, 15 Oct 2020 07:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602773088; cv=none; d=google.com; s=arc-20160816; b=u59N9fWL7cW34QdhCn5YY/cIKHB16Aa4Iyj9JmFf+efKEhhjgob2C62pa26wxQkoBm tBcCAYBY7L8k4AcNI0He13QekycSXS117ZKOT3b7rjE/882ZxTc9yNPy7RLwoU7IGUWg m0fQu1C3oGHVaLYGYBs+nSh2jiZuWa/lmsvQt6TRBvFr8KU/9B78vSIr567C4Jamm7G1 gYUW9ccAbTRgQXNkRcXRaU0VGPPj/xhhG4y6oNBwDc7quhaxbs8kVESH4P1LgmOgpfQB Ft+d6ntWNE8wFhBxnXmwWjj8cUH9k+DYtoqe02eqeKxVewnItcXgupsjdSYwj8O5F1jC 9FyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=VIIJ4RMYqLNortz9z9aAlCcePVhZmZgs6l1LmiLsOiE=; b=pUCBI2HovTKlU0G/EaEvTQ+DIGFbO1cL+POs/PgN5frGnIFTB+32qGbDOXAv1PxTht cj/7csn/SOoz7tkw/kTFjyzr88muPXKibhI67AGdlfe2SpCTpl9vOm3O0nkNhP71/Xz8 AFVOOpDhY2/Rk3q8zhmbMFw0RChsOuZvvTbNSR0u8gU89hmzwiS7AF8uBUowZkgVGeT/ MliMwzvLJfop7vqOkTboQBFwO7jRujTWjrKg3s4WjEiELpE3SToBGbgCCfD6tbD+gO74 wsdMrddoyn8TKzE9xUjxsbzdy2MYqWetCwG4aVxmxm4rGWk2Fo2htnn20vzwVt/XIn88 VM/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uCfxLmur; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x101si2284980ede.61.2020.10.15.07.44.48; Thu, 15 Oct 2020 07:44:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=uCfxLmur; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388854AbgJOOor (ORCPT + 9 others); Thu, 15 Oct 2020 10:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388817AbgJOOoo (ORCPT ); Thu, 15 Oct 2020 10:44:44 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C399DC0613D2 for ; Thu, 15 Oct 2020 07:44:43 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id h5so3816187wrv.7 for ; Thu, 15 Oct 2020 07:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VIIJ4RMYqLNortz9z9aAlCcePVhZmZgs6l1LmiLsOiE=; b=uCfxLmurrBez2qGjMmn+ptUQYi+av2FATs0l5HzikkwlhbibvL4PEvj+m1Qx1MG3l4 7zLgOcsguYhB65Vsmk240KVdyW+sDF9dbVpNCSg8v3phQgNdt1RWjdgYTvzyGoLYcyeJ C7Dm4+wyFTUU+WF+n6BAYd5G6nRqNSQbZdS7ktdPWe2/PnHXdNXY/ULRQwsU5kJOugAS NJ8jgLJpBCMzmataXfkb1Q8qLMT1GfPF3Jpm7fEDRG3JgPEPDdWu7bzXLaQLOrttI9RN RG2s23NUx5+1Qsp0kT41e5L6O1RxTKuv8iMF8dKi7AaTvy0DmFksKEA/iX2CPfZJWXvU Ho2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VIIJ4RMYqLNortz9z9aAlCcePVhZmZgs6l1LmiLsOiE=; b=Q6R+adlDZPuEGcHZnIm4MrJrJqPMiVdzdaN6JvF+idoL2OXE77tnzs8gx/pOIyyrK2 dt4KAtnl9JMr78fZpa59aYHvbN0ysl50i1+0ckuekXpj5bF3i/pTYwsSPOCmoxzqWLRq YQAqXa4xn66T1UB7AW+jQnvS7heRr2YcLXlMqGSHwEjbHUlSzDmQ4yrqxqzCxYc2iS9j Qo/9OlY+GJSjerMtEijZmjV/+a0QGmfKcX2wQ9eRgS+xky/Jie1eQn+1Rq3i0sY25kse Z0l21qyLf7XyhEIhFdpidkvHdC6hAblH8q+BSe61WpKnrz2AT1s0f7BJvoyZ9N/3MlEg S+kA== X-Gm-Message-State: AOAM5338FqEwMD9HFHw0ONL9e12ekzC9nNuATBUFEGby4MHndv83vPVn 4G3DyU+/8FHolG/JYAdau0TEuQ== X-Received: by 2002:adf:eb41:: with SMTP id u1mr4567937wrn.94.1602773082353; Thu, 15 Oct 2020 07:44:42 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-134-136.adsl.proxad.net. [82.252.134.136]) by smtp.gmail.com with ESMTPSA id 40sm5053800wrc.46.2020.10.15.07.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 07:44:41 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ilina@codeaurora.org Subject: [PATCH 2/5] cpuidle: governor: Encapsulate the cpuidle on/off switch Date: Thu, 15 Oct 2020 16:44:28 +0200 Message-Id: <20201015144431.9979-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201015144431.9979-1-daniel.lezcano@linaro.org> References: <20201015144431.9979-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The next patch will introduce the ability to unregister a governor which will share part of the register function code. Instead of duplicating, let's encapuslate the common parts into functions, so they can be called from different places. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/governor.c | 39 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index 29acaf48e575..d46ab8ec2dd7 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -39,6 +39,27 @@ struct cpuidle_governor *cpuidle_find_governor(const char *str) return NULL; } +static void cpuidle_switch_off(void) +{ + struct cpuidle_device *dev; + + cpuidle_uninstall_idle_handler(); + + if (cpuidle_curr_governor) { + list_for_each_entry(dev, &cpuidle_detected_devices, device_list) + cpuidle_disable_device(dev); + } +} + +static void cpuidle_switch_on(void) +{ + struct cpuidle_device *dev; + + list_for_each_entry(dev, &cpuidle_detected_devices, device_list) + cpuidle_enable_device(dev); + cpuidle_install_idle_handler(); +} + /** * cpuidle_switch_governor - changes the governor * @gov: the new target governor @@ -46,29 +67,19 @@ struct cpuidle_governor *cpuidle_find_governor(const char *str) */ int cpuidle_switch_governor(struct cpuidle_governor *gov) { - struct cpuidle_device *dev; - if (!gov) return -EINVAL; if (gov == cpuidle_curr_governor) return 0; - cpuidle_uninstall_idle_handler(); - - if (cpuidle_curr_governor) { - list_for_each_entry(dev, &cpuidle_detected_devices, device_list) - cpuidle_disable_device(dev); - } + cpuidle_switch_off(); cpuidle_curr_governor = gov; - if (gov) { - list_for_each_entry(dev, &cpuidle_detected_devices, device_list) - cpuidle_enable_device(dev); - cpuidle_install_idle_handler(); - printk(KERN_INFO "cpuidle: using governor %s\n", gov->name); - } + cpuidle_switch_on(); + + printk(KERN_INFO "cpuidle: using governor %s\n", gov->name); return 0; } From patchwork Thu Oct 15 14:44:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 286784 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 3EE7EC433E7 for ; Thu, 15 Oct 2020 14:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6D95212CC for ; Thu, 15 Oct 2020 14:44:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M1Qi00Fp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388873AbgJOOor (ORCPT ); Thu, 15 Oct 2020 10:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388837AbgJOOop (ORCPT ); Thu, 15 Oct 2020 10:44:45 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E624DC0613D4 for ; Thu, 15 Oct 2020 07:44:44 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id b127so3982009wmb.3 for ; Thu, 15 Oct 2020 07:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5JUoyfVqtjpZjkNlfJCWbI+WQsPddcI5ptqn4dRqnS4=; b=M1Qi00FprtY5xYwcerjaZE+WMKOs7sLUXXC6fFbubPpcPA+BWUxbUd9xBQHd3/HcKE V+ozmSlOesz53OdnecMn8+bIb+7IYVU0q2Gs5jaU2eB8n5bTm1KrZzQbDPfHZQpJ0ObR 8Lb8SC5H7xz8cqqLc2zWKkhCnHtIqFPQp/7Remaws17XOPVeZ6G/VzOfzyKE1ThjQnfr udQlNxSufReO1qiRy5vMpt6YgJDGlKngHAcggVP7SPFfjfRruRE5j+x53h/aDOrLvGWT 72/zvDcsy5Bmgk5bPz/pq/Q8zkIsdQndA6JLmCvMCbm/FJux+tPGPkj9HgR8p4ElAarQ EwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5JUoyfVqtjpZjkNlfJCWbI+WQsPddcI5ptqn4dRqnS4=; b=EWg1Jt0+UyP8KfIna2HTqlZulj7bQwmv9u8E3GQ7J4QoeW8p5jwzs+B+SSTDSazGgz C2aKj+Gi6fBV227tZX9vrpF9vVYO3+Rv3z4APBoldKs2CRMzI73Y2fl2OwUcL7vNYAZP Llox58n3hzpltFnXsAXedvMuZRV1Hoebdaw6C+NntaV6AByv7Bdv1ltFEcKirTtZT//9 xAq/1ERWhSOYORfXPwmFjmuWc1AXIFw1qE7CMWIPGtd7gPTq4hQOuUxnCoYbxF66dvB/ 0d5te+Ov08yt+Rr5kqTyYk/79l9JjgQ6RXZUFTe3h/7vGZvaOhGcneIqcX3YqaSjTfYE GJhQ== X-Gm-Message-State: AOAM533EUyd6SM6CvBa2WBYnSqsXAjXOAXZiZ0XxqOL750OASydJwVZR NrrYEaqdLc2ZwUSgCjAIMmGgnQ== X-Google-Smtp-Source: ABdhPJxMGwzaSWU0D+nse992DXxVycFwXzLw7Fz4JN4lJ70ITxImMfBOaK72fwCoAe5Fekxfl608mA== X-Received: by 2002:a1c:bd0a:: with SMTP id n10mr4378021wmf.177.1602773083506; Thu, 15 Oct 2020 07:44:43 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-134-136.adsl.proxad.net. [82.252.134.136]) by smtp.gmail.com with ESMTPSA id 40sm5053800wrc.46.2020.10.15.07.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 07:44:42 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ilina@codeaurora.org Subject: [PATCH 3/5] cpuidle: governor: Make possible to unregister a governor Date: Thu, 15 Oct 2020 16:44:29 +0200 Message-Id: <20201015144431.9979-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201015144431.9979-1-daniel.lezcano@linaro.org> References: <20201015144431.9979-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch allows to unregister a governor. If the unregistered governor is the current one, it will be replaced by the governor with the highest rating. If it is the last governor, the cpuidle framework will be switched off. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/governor.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/cpuidle.h | 1 + 2 files changed, 38 insertions(+) diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index d46ab8ec2dd7..6ec27ef096f5 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -84,6 +84,43 @@ int cpuidle_switch_governor(struct cpuidle_governor *gov) return 0; } +/** + * cpuidle_unregister_governor - unregister a governor + * @gov: a pointer to a cpuidle governor structure + * + * Unregister the governor specified in parameter. If it is the + * current one, replace by another one in the list with the highest + * rating. If it is the last one, then switch off cpuidle. + */ +void cpuidle_unregister_governor(struct cpuidle_governor *gov) +{ + int rating = 0; + struct cpuidle_governor *new_gov = NULL; + + mutex_lock(&cpuidle_lock); + + list_del(&gov->governor_list); + + /* + * The governor is currently in use, switch to the one with + * the best rating. + */ + if (cpuidle_curr_governor == gov) { + + list_for_each_entry(gov, &cpuidle_governors, governor_list) { + if (gov->rating > rating) + new_gov = gov; + } + + if (new_gov) + cpuidle_switch_governor(new_gov); + else + cpuidle_switch_off(); + } + + mutex_unlock(&cpuidle_lock); +} + /** * cpuidle_register_governor - registers a governor * @gov: the governor diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 74fdcc6106b1..457e0786b4f9 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -271,6 +271,7 @@ struct cpuidle_governor { }; extern int cpuidle_register_governor(struct cpuidle_governor *gov); +extern void cpuidle_unregister_governor(struct cpuidle_governor *gov); extern s64 cpuidle_governor_latency_req(unsigned int cpu); #define __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, \ From patchwork Thu Oct 15 14:44:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 286783 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 A2A43C433DF for ; Thu, 15 Oct 2020 14:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F8C421D7F for ; Thu, 15 Oct 2020 14:45:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ImcZK/AR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388862AbgJOOor (ORCPT ); Thu, 15 Oct 2020 10:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388847AbgJOOor (ORCPT ); Thu, 15 Oct 2020 10:44:47 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F20C0613D6 for ; Thu, 15 Oct 2020 07:44:46 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id n6so3772258wrm.13 for ; Thu, 15 Oct 2020 07:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ns1m02lPSeh1tASLMlG6AU/degRmJ6UjKHjGB53b4n0=; b=ImcZK/ARIbT0i2dvRMtgGG1LbPKKa0EY0UfHjZ0tLJaYMylqk+PF13oLbny4hJBQDd CX5wqqnjlLEGNbFT5L/JIAHUxak4XiyoUwWz+13okIJQvXpW8p1doR1a3Iq2KFEuxH0f jIYYsEG4jzLCFd1jwlntJiW5Nro0SFcb61gx5pHpDvVyXvBJKAI9r+9L/On/zOw+z/GS yU67f4q9DwVgUFzifjU4kFFM39y7QjsNiGTW5JnjlUOasAvxTP99J3xJq6ylyruzOnqu G21fReacEZCUbgSr8XM4NDXWv65zXsTMSiLNnk1B1tleuDoWtYqGrKKD/8PTSiy5NODe rgdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ns1m02lPSeh1tASLMlG6AU/degRmJ6UjKHjGB53b4n0=; b=A3Jsz8HNX77Bz7jTqh31+7JfaLfhZsKDMfO6iAUamB4Pxqb5ajxR/7OHgE5kBtXFQW pE/xJ5y1Wz+c5mk5KZyCr3M2Y+YLfND7ldCggBK3NZ9XI20RL8yICIcn3tMzayLxAKGc Jdm7UV9Vb05boqlpMQiIBpkvKEFTUoOynWT3wNQBj0S+jT3R7PUy8ppex355iOm63KoC zl/3+Uoek+ROrk1wi8VhrDy6hGF8AqNJVuyac3O85y0AN6wtk2WY8BwzNEg9TB6QDh4G ttvPd8IpD09o9eUsIlq5R+N2KZ1sWM9nJeDtnfMRpxLAAc7zotc/YAr4sS6hWUNQRr/E ixXg== X-Gm-Message-State: AOAM532OKatU81Y09M9XNgBA8AJPTSYp43QGRfW5rD3jnTXARfxtdL5d HGVs4L0tkvhpTOvvYd/TudxqSg== X-Google-Smtp-Source: ABdhPJwB1QuSwWGogwylyajeyd69XloX/G8jxuUJoAwxApFMv3mghUJjPBmy4MPv54zYfFZ5OVKm8A== X-Received: by 2002:adf:c3cd:: with SMTP id d13mr4694475wrg.15.1602773084737; Thu, 15 Oct 2020 07:44:44 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-134-136.adsl.proxad.net. [82.252.134.136]) by smtp.gmail.com with ESMTPSA id 40sm5053800wrc.46.2020.10.15.07.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 07:44:44 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ilina@codeaurora.org Subject: [PATCH 4/5] cpuidle: governor: Export the needed symbols Date: Thu, 15 Oct 2020 16:44:30 +0200 Message-Id: <20201015144431.9979-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201015144431.9979-1-daniel.lezcano@linaro.org> References: <20201015144431.9979-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In the next patch, the governors will be converted to modules. Export the symbols of the different functions used by the governors. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/governor.c | 3 +++ include/linux/tick.h | 2 ++ kernel/sched/core.c | 1 + kernel/time/tick-sched.c | 9 +++++++++ 4 files changed, 15 insertions(+) diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index 6ec27ef096f5..2791fe352f51 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -120,6 +120,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov) mutex_unlock(&cpuidle_lock); } +EXPORT_SYMBOL(cpuidle_unregister_governor); /** * cpuidle_register_governor - registers a governor @@ -150,6 +151,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov) return ret; } +EXPORT_SYMBOL(cpuidle_register_governor); /** * cpuidle_governor_latency_req - Compute a latency constraint for CPU @@ -166,3 +168,4 @@ s64 cpuidle_governor_latency_req(unsigned int cpu) return (s64)device_req * NSEC_PER_USEC; } +EXPORT_SYMBOL(cpuidle_governor_latency_req); diff --git a/include/linux/tick.h b/include/linux/tick.h index 7340613c7eff..8349ba050b9c 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -124,6 +124,7 @@ enum tick_dep_bits { #ifdef CONFIG_NO_HZ_COMMON extern bool tick_nohz_enabled; +extern bool tick_nohz_is_enabled(void); extern bool tick_nohz_tick_stopped(void); extern bool tick_nohz_tick_stopped_cpu(int cpu); extern void tick_nohz_idle_stop_tick(void); @@ -149,6 +150,7 @@ static inline void tick_nohz_idle_stop_tick_protected(void) #else /* !CONFIG_NO_HZ_COMMON */ #define tick_nohz_enabled (0) +static inline int tick_nohz_is_enabled(void) { return 0 }; static inline int tick_nohz_tick_stopped(void) { return 0; } static inline int tick_nohz_tick_stopped_cpu(int cpu) { return 0; } static inline void tick_nohz_idle_stop_tick(void) { } diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2d95dc3f4644..ceba61bb364d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3838,6 +3838,7 @@ unsigned long nr_iowait_cpu(int cpu) { return atomic_read(&cpu_rq(cpu)->nr_iowait); } +EXPORT_SYMBOL_GPL(nr_iowait_cpu); /* * IO-wait accounting, and how its mostly bollocks (on SMP). diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index f0199a4ba1ad..537716124d46 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -500,12 +500,19 @@ static int __init setup_tick_nohz(char *str) __setup("nohz=", setup_tick_nohz); +bool tick_nohz_is_enabled(void) +{ + return tick_nohz_enabled; +} +EXPORT_SYMBOL_GPL(tick_nohz_is_enabled); + bool tick_nohz_tick_stopped(void) { struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched); return ts->tick_stopped; } +EXPORT_SYMBOL_GPL(tick_nohz_tick_stopped); bool tick_nohz_tick_stopped_cpu(int cpu) { @@ -1066,6 +1073,7 @@ bool tick_nohz_idle_got_tick(void) } return false; } +EXPORT_SYMBOL_GPL(tick_nohz_idle_got_tick); /** * tick_nohz_get_next_hrtimer - return the next expiration time for the hrtimer @@ -1117,6 +1125,7 @@ ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) return ktime_sub(next_event, now); } +EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length); /** * tick_nohz_get_idle_calls_cpu - return the current idle calls counter value From patchwork Thu Oct 15 14:44:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 317776 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp558153ilm; Thu, 15 Oct 2020 07:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlytDxnk44j3q+RxNlwVUET4l9iSSssMpwpGKajLbuyTOjMe8SHtRxxjxkdXmUme/3BUvz X-Received: by 2002:a17:906:489b:: with SMTP id v27mr4993849ejq.315.1602773098483; Thu, 15 Oct 2020 07:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602773098; cv=none; d=google.com; s=arc-20160816; b=VRQ+oIwOhe7JCrgfKUtGLTQWzJRAe/XrsbSwr5TjbuQk8QNVZ198iE+Gi82LAKXhjP JTeaE/2v8sT2VpM6g1rLkWE96EjfhtM2n4P/esjEkgYVNrdRRlmehmXJ/wkIzg5vm/YG rgkQfyVbOVTU+smrTuASvvi6cmvmvZ0u7XlZTjP5AKVbFxYyE91XSduQl7DmZSAfnkGv FXsVvuxxWo8csAwHePdCVxnXmCeXb/6vipncz6u37trIXJUpsNXcXrlTBfkm3/qZKKW/ UZtQ9yggYxIocRNU+bh/9+puHyHKnU33FMp09HhTTTdLEJ00QtDf047cq9lK04krPSvF yXBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=MntIS5hG5qKkJHF3dkjVLX64GnAHUT4P3HeNpPTIdo0=; b=a3aG1/yzltOi0RNsMFXS0cCWAognTO0i45g+ZszS30SBWrw/vJhI521X8W43sCEFCj LlvrLs3qGOi9msiokznyMyGcRquFxbEGOtVdvK94iysIcBlPD2lW50HpWhpu8CeU/cEU dm66yaA8nJ5/+NI/RuB0XDAHTcOoTOvVxjxuDqUcUMRgHBUGCu6j8iSX7/E9kKHqU7CD RiHYwPnndkDBxGhmd+IaXxwecl+4N2+cv+LZPeaYzHsk0+1vaaNmXeu0BgXZzkrgq3rG 9DFqoq7u66DbBfqGaJZYjPSHmaApRKBbRdjVdsj8ZRqw18QvQ7jbKltnyoFhjNcfOAB+ oLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Gr9Mau/X"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si576160edk.163.2020.10.15.07.44.58; Thu, 15 Oct 2020 07:44:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b="Gr9Mau/X"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388837AbgJOOos (ORCPT + 9 others); Thu, 15 Oct 2020 10:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388882AbgJOOos (ORCPT ); Thu, 15 Oct 2020 10:44:48 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADCAEC0613D2 for ; Thu, 15 Oct 2020 07:44:47 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id q5so3996587wmq.0 for ; Thu, 15 Oct 2020 07:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MntIS5hG5qKkJHF3dkjVLX64GnAHUT4P3HeNpPTIdo0=; b=Gr9Mau/Xqu2Exr9oRxron8l1EirbsMrJtvhPHJxxDWRryiywuM/kvWWjRQ95PAtkkB wmxbrBqyLWqMVgLQKWiEWfiy8ojRfHOXSfaOxLarzRwLE4Wsu5KHKNuUJm3vF7WZAVOc Yav6uBclxqyBdl65J0iaDn4SJFrOD/OZkCnXh3F8thhugKVL21q6UV15GdEulgDsdOOb et/xVCy5gUbtz9oX60ikqcEb7TNMWIDm0YuLG+sx8/X2P7pZwWv5x2YKtRDnX+jtLJOT pIkJOKVd5NlgbJ5iqv5LTJSFGw4PkhzzVQbBbFn1SGpLqp/dHMfS+ib/Z2drZsf0IAmv 9EwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MntIS5hG5qKkJHF3dkjVLX64GnAHUT4P3HeNpPTIdo0=; b=YG0YctqdBT4lKgFUhgdzWXn3Vr0GXQBFPx7QVdQeGM1YagvjZJ6lVafkRt28LEYyLI ishTxgLlPGKWObHEYsRRNGv2WMJ8DcU+lKhDoDmbz2Y3DEId+K8yyF9g7IYTdwUvPpGi +yBbUr2X8E+07dfYdh88WifGMXm1/CN0jSc6JLZHOSIWepDwaIciyReiSZoMQk1IhV6r oLiN2gN4mF8cDANtulGE7PMiS9nO8mhsKa7B9rrha2UWV1sHcEJ3pr56/zc5pHZxMQva xZ1tM3J9r5FxZqr4TkcnWHQu/Y9NnM5JlsecHndmwZXUDIuSCJcA2IptwjHGdf6CJ4Do WnfA== X-Gm-Message-State: AOAM5319ZGZFlGo8u6u0ktMyoBIh4k3Mn6hFEhH3xUbzgqAQLAAi/rZL FMcA8LhvZyrV7j9XmuN1Ze7KCA== X-Received: by 2002:a1c:9d87:: with SMTP id g129mr4443850wme.30.1602773086172; Thu, 15 Oct 2020 07:44:46 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-134-136.adsl.proxad.net. [82.252.134.136]) by smtp.gmail.com with ESMTPSA id 40sm5053800wrc.46.2020.10.15.07.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 07:44:45 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ilina@codeaurora.org Subject: [PATCH 5/5] cpuidle: governor: Convert governors to modules Date: Thu, 15 Oct 2020 16:44:31 +0200 Message-Id: <20201015144431.9979-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201015144431.9979-1-daniel.lezcano@linaro.org> References: <20201015144431.9979-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch converts the cpuidle governors into modules. Even if it is not the utmost importance, that will be consistent with the devfreq, the watchdog and the cpufreq governors. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/Kconfig | 8 ++++---- drivers/cpuidle/governors/haltpoll.c | 9 ++++++++- drivers/cpuidle/governors/ladder.c | 12 ++++++++++-- drivers/cpuidle/governors/menu.c | 10 +++++++++- drivers/cpuidle/governors/teo.c | 10 +++++++++- 5 files changed, 40 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index c0aeedd66f02..ff83042edd50 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -19,13 +19,13 @@ config CPU_IDLE_MULTIPLE_DRIVERS bool config CPU_IDLE_GOV_LADDER - bool "Ladder governor (for periodic timer tick)" + tristate "Ladder governor (for periodic timer tick)" config CPU_IDLE_GOV_MENU - bool "Menu governor (for tickless system)" + tristate "Menu governor (for tickless system)" config CPU_IDLE_GOV_TEO - bool "Timer events oriented (TEO) governor (for tickless systems)" + tristate "Timer events oriented (TEO) governor (for tickless systems)" help This governor implements a simplified idle state selection method focused on timer events and does not do any interactivity boosting. @@ -34,7 +34,7 @@ config CPU_IDLE_GOV_TEO to use. Say Y here if you are not happy with the alternatives. config CPU_IDLE_GOV_HALTPOLL - bool "Haltpoll governor (for virtualized systems)" + tristate "Haltpoll governor (for virtualized systems)" depends on KVM_GUEST help This governor implements haltpoll idle state selection, to be diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c index cb2a96eafc02..4756b758c324 100644 --- a/drivers/cpuidle/governors/haltpoll.c +++ b/drivers/cpuidle/governors/haltpoll.c @@ -146,4 +146,11 @@ static int __init init_haltpoll(void) return 0; } -postcore_initcall(init_haltpoll); +static void __exit exit_haltpoll(void) +{ + cpuidle_unregister_governor(&haltpoll_governor); +} + +module_init(init_haltpoll); +module_exit(exit_haltpoll); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index 8e9058c4ea63..78b622b75ce7 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -188,10 +189,17 @@ static int __init init_ladder(void) * governor is better so give it a higher rating than the menu * governor. */ - if (!tick_nohz_enabled) + if (!tick_nohz_is_enabled()) ladder_governor.rating = 25; return cpuidle_register_governor(&ladder_governor); } -postcore_initcall(init_ladder); +static void __exit exit_ladder(void) +{ + cpuidle_unregister_governor(&ladder_governor); +} + +module_init(init_ladder); +module_exit(exit_ladder); +MODULE_LICENSE("GPL"); diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index b0a7ad566081..fc92a5b18a7b 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -571,4 +572,11 @@ static int __init init_menu(void) return cpuidle_register_governor(&menu_governor); } -postcore_initcall(init_menu); +static void __exit exit_menu(void) +{ + cpuidle_unregister_governor(&menu_governor); +} + +module_init(init_menu); +module_exit(exit_menu); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c index 6deaaf5f05b5..d11dab61113c 100644 --- a/drivers/cpuidle/governors/teo.c +++ b/drivers/cpuidle/governors/teo.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -491,4 +492,11 @@ static int __init teo_governor_init(void) return cpuidle_register_governor(&teo_governor); } -postcore_initcall(teo_governor_init); +static void __exit teo_governor_exit(void) +{ + cpuidle_unregister_governor(&teo_governor); +} + +module_init(teo_governor_init); +module_exit(teo_governor_exit); +MODULE_LICENSE("GPL v2");