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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 95BAFC06517 for ; Thu, 4 Jul 2019 11:14:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 780A22189E for ; Thu, 4 Jul 2019 11:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfGDLOR (ORCPT ); Thu, 4 Jul 2019 07:14:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45160 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbfGDLOR (ORCPT ); Thu, 4 Jul 2019 07:14:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AAF9C057F3B; Thu, 4 Jul 2019 11:14:10 +0000 (UTC) Received: from amt.cnet (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288AB1001B16; Thu, 4 Jul 2019 11:14:08 +0000 (UTC) Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 363A110516E; Thu, 4 Jul 2019 08:13:46 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id x64BDfL3001599; Thu, 4 Jul 2019 08:13:41 -0300 Date: Thu, 4 Jul 2019 08:13:41 -0300 From: Marcelo Tosatti To: Joao Martins Cc: kvm-devel , Paolo Bonzini , Radim Krcmar , Andrea Arcangeli , "Rafael J. Wysocki" , Peter Zijlstra , Wanpeng Li , Konrad Rzeszutek Wilk , Raslan KarimAllah , Boris Ostrovsky , Ankur Arora , Christian Borntraeger , linux-pm@vger.kernel.org Subject: Re: [patch 1/5] add cpuidle-haltpoll driver Message-ID: <20190704111341.GA1249@amt.cnet> References: <20190703235124.783034907@amt.cnet> <20190703235828.340866829@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Jul 2019 11:14:17 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jul 04, 2019 at 10:16:47AM +0100, Joao Martins wrote: > On 7/4/19 12:51 AM, Marcelo Tosatti wrote: > > +++ linux-2.6-newcpuidle.git/drivers/cpuidle/cpuidle-haltpoll.c > > @@ -0,0 +1,69 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * cpuidle driver for haltpoll governor. > > + * > > + * Copyright 2019 Red Hat, Inc. and/or its affiliates. > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2. See > > + * the COPYING file in the top-level directory. > > + * > > + * Authors: Marcelo Tosatti > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +static int default_enter_idle(struct cpuidle_device *dev, > > + struct cpuidle_driver *drv, int index) > > +{ > > + if (current_clr_polling_and_test()) { > > + local_irq_enable(); > > + return index; > > + } > > + default_idle(); > > + return index; > > +} > > + > > +static struct cpuidle_driver haltpoll_driver = { > > + .name = "haltpoll", > > + .owner = THIS_MODULE, > > + .states = { > > + { /* entry 0 is for polling */ }, > > + { > > + .enter = default_enter_idle, > > + .exit_latency = 1, > > + .target_residency = 1, > > + .power_usage = -1, > > + .name = "haltpoll idle", > > + .desc = "default architecture idle", > > + }, > > + }, > > + .safe_state_index = 0, > > + .state_count = 2, > > +}; > > + > > +static int __init haltpoll_init(void) > > +{ > > + struct cpuidle_driver *drv = &haltpoll_driver; > > + > > + cpuidle_poll_state_init(drv); > > + > > + if (!kvm_para_available()) > > + return 0; > > + > > Isn't this meant to return -ENODEV value if the module is meant to not load? Well, the cpuidle drivers return an error only if registration fails. > Also this check should probably be placed before initializing the poll state, > provided poll state isn't used anyways if you're not a kvm guest. Poll state init is only local variable initialization, it does not have any external effect.