From patchwork Mon Jul 22 04:32:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2831019 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 13FEF9F9CC for ; Mon, 22 Jul 2013 04:32:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0912A20136 for ; Mon, 22 Jul 2013 04:32:40 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EBAC20134 for ; Mon, 22 Jul 2013 04:32:38 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V17nT-0007Z3-8W; Mon, 22 Jul 2013 04:32:31 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V17nQ-0005U9-QA; Mon, 22 Jul 2013 04:32:28 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V17nN-0005Td-HD for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2013 04:32:26 +0000 Received: by mail-wg0-f47.google.com with SMTP id j13so643183wgh.14 for ; Sun, 21 Jul 2013 21:32:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=yOd/pXiu5LWuw3JHFzY4J0MrQa9fEn23rODM477GxYU=; b=NyBnF8oe6CLiw4ikOPawNpfPPD2on79l9tizheLU0q+mwa4aWnDkcUzQLMriniNwMN wer9V3oCcG/6Lui3a6QQ7LA/JsBkXbeNgpz+wExmw0j5/9uIzzzc8p0inDcgZ6rfI7DE HfJg5eaenokVRoix/DOCecxwZz9moPoDLNT3d0QE3vv/fYhPDaaGopr8gdNMA/JSZgtk AON5I3pi/MOFWkovu2nXUjzB3Zy/PLHj7GvdoT0FWwfQazlRYG/UFOqPwdQMUBXQ0pJh B2QcIxT0odYnWxZSDKZCpRn5MADrmXZsK1r7OLVGx5MRugaTAYkFeHImxWUgSDsfSz5Y dxzg== X-Received: by 10.180.109.9 with SMTP id ho9mr7081781wib.43.1374467523461; Sun, 21 Jul 2013 21:32:03 -0700 (PDT) Received: from [192.168.1.150] (AToulouse-654-1-321-186.w86-199.abo.wanadoo.fr. [86.199.208.186]) by mx.google.com with ESMTPSA id j20sm37898706wie.7.2013.07.21.21.32.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Jul 2013 21:32:02 -0700 (PDT) Message-ID: <51ECB5C1.600@linaro.org> Date: Mon, 22 Jul 2013 06:32:01 +0200 From: Daniel Lezcano User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Joseph Lo Subject: Re: [PATCH] ARM: tegra: cpuidle: use CPUIDLE_FLAG_TIMER_STOP flag References: <1372152228-16199-1-git-send-email-josephl@nvidia.com> <51E439BC.9030608@wwwdotorg.org> <1373973447.8538.80.camel@jlo-ubuntu-64.nvidia.com> <51E5A438.10004@wwwdotorg.org> <1374056130.10997.16.camel@jlo-ubuntu-64.nvidia.com> <51E6FF0B.5000708@wwwdotorg.org> <1374145726.5610.73.camel@jlo-ubuntu-64.nvidia.com> <51E7E27B.9090605@linaro.org> <1374218064.24607.1.camel@jlo-ubuntu-64.nvidia.com> <51E91A72.6070708@linaro.org> <1374462916.15946.14.camel@jlo-ubuntu-64.nvidia.com> <51ECB223.5000002@linaro.org> <1374467085.15946.16.camel@jlo-ubuntu-64.nvidia.com> In-Reply-To: <1374467085.15946.16.camel@jlo-ubuntu-64.nvidia.com> X-Gm-Message-State: ALoCoQm6ytbhh514WC5sgTMOxzvQCErPmollUqV9cYhhFstFw9GlB/BjWgWOMOL+m/b5mzPLUH1g X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130722_003225_806760_4669B328 X-CRM114-Status: GOOD ( 31.39 ) X-Spam-Score: -2.6 (--) Cc: "linux-tegra@vger.kernel.org" , Peter De Schrijver , "linux-arm-kernel@lists.infradead.org" , Stephen Warren X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/22/2013 06:24 AM, Joseph Lo wrote: > On Mon, 2013-07-22 at 12:16 +0800, Daniel Lezcano wrote: >> On 07/22/2013 05:15 AM, Joseph Lo wrote: >>> On Fri, 2013-07-19 at 18:52 +0800, Daniel Lezcano wrote: >>>> On 07/19/2013 09:14 AM, Joseph Lo wrote: >>>>> On Thu, 2013-07-18 at 20:41 +0800, Daniel Lezcano wrote: >>>>>> On 07/18/2013 01:08 PM, Joseph Lo wrote: >>>>>>> On Thu, 2013-07-18 at 04:31 +0800, Stephen Warren wrote: >>>>>>>> On 07/17/2013 04:15 AM, Joseph Lo wrote: >>>>>>>>> On Wed, 2013-07-17 at 03:51 +0800, Stephen Warren wrote: >>>>>>>>>> On 07/16/2013 05:17 AM, Joseph Lo wrote: >>>>>>>>>>> On Tue, 2013-07-16 at 02:04 +0800, Stephen Warren wrote: >>>>>>>>>>>> On 06/25/2013 03:23 AM, Joseph Lo wrote: >>>>>>>>>>>>> Use the CPUIDLE_FLAG_TIMER_STOP and let the cpuidle framework >>>>>>>>>>>>> to handle the CLOCK_EVT_NOTIFY_BROADCAST_ENTER/EXIT when entering >>>>>>>>>>>>> this state. >>>>>>>> ... [ discussion of issues with Joesph's patches applied] >>>>>>>>> > [...] >>>> >>>> Ok, so the problem occurs with the CPUIDLE_FLAG_TIMER_STOP flag only on >>>> tegra114, right ? >>>> >>>> Sorry, I am a bit lost :) >>>> >>> Here are the issues that happen after apply CPUIDLE_FLAG_TIMER_STOP. >>> 1) Tegra114/30 >>> The warning message at kernel/time/tick-broadcast.c:667 >>> tick_broadcast_oneshot_control could be triggered when doing CPU hot >>> plug stress test. >> >> With the fix for tick-broadcast.c [1] ? > Yes. > >> >>> 2) Tegra20 >>> The system is easy to stick or become lag. >>> The CPU hot plug is easy to cause system stick too. >>> >>> The fix I suggested in another mail looks can fix all the issues above. >>> I verified it again today on 3 different Tegra SoC platforms. >> >> Not sure your patch fixes the problem. >> >> I am wondering if there isn't a underlaying problem which surface with >> the flag. Does the attached patch changes something ? From 5d4f611244834662d3ac077af4e8e6ef4bb1ed8a Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Tue, 9 Apr 2013 12:03:28 +0200 Subject: [PATCH 11/36] cpuidle: add hotplug support to initialize the timer broadcast Commit 89878baa73f0f1c679355006bd8632e5d78f96c2 introduced the flag CPUIDLE_FLAG_TIMER_STOP where we specify a specific idle state stops the local timer. Commit a06df062a189a8d5588babb8bf0bb78672497798 introduced the initialization of the timer broadcast framework depending of the flag presence. If a system is booted with some cpus offline, by setting for example, maxcpus=1 in the kernel command line, and then they are set online, the timer broadcast won't be setup automatically. Fix this by adding the cpu hotplug notifier and enable/disable the timer broadcast automatically. So no need to handle that at the arch specific driver level like eg. intel_idle does. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/driver.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) Index: cpuidle-next/drivers/cpuidle/driver.c =================================================================== --- cpuidle-next.orig/drivers/cpuidle/driver.c +++ cpuidle-next/drivers/cpuidle/driver.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -147,6 +148,48 @@ static void cpuidle_setup_broadcast_time } /** + * cpuidle_hotplug_notify: notifier callback when a cpu is onlined/offlined + * @n: the notifier block + * @action: an unsigned long giving the event related to the notification + * @hcpu: a void pointer but used as the cpu number which the event is related + * + * The kernel can boot with some cpus offline, we have to init the timer + * broadcast for these cpus when they are onlined. Also we have to disable + * the timer broadcast when the cpu is down. + * + * Returns NOTIFY_OK + */ +static int cpuidle_hotplug_notify(struct notifier_block *n, + unsigned long action, void *hcpu) +{ + int cpu = (unsigned long)hcpu; + struct cpuidle_driver *drv; + + drv = __cpuidle_get_cpu_driver(cpu); + if (!drv || !drv->bctimer) + goto out; + + switch (action & 0xf) { + case CPU_ONLINE: + smp_call_function_single(cpu, cpuidle_setup_broadcast_timer, + (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, + 1); + break; + case CPU_DEAD: + smp_call_function_single(cpu, cpuidle_setup_broadcast_timer, + (void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, + 1); + break; + } +out: + return NOTIFY_OK; +} + +static struct notifier_block cpuidle_hotplug_notifier = { + .notifier_call = cpuidle_hotplug_notify, +}; + +/** * __cpuidle_driver_init - initialize the driver's internal data * @drv: a valid pointer to a struct cpuidle_driver * @@ -262,6 +305,9 @@ int cpuidle_register_driver(struct cpuid ret = __cpuidle_register_driver(drv); spin_unlock(&cpuidle_driver_lock); + if (!ret) + ret = register_cpu_notifier(&cpuidle_hotplug_notifier); + return ret; } EXPORT_SYMBOL_GPL(cpuidle_register_driver); @@ -276,6 +322,8 @@ EXPORT_SYMBOL_GPL(cpuidle_register_drive */ void cpuidle_unregister_driver(struct cpuidle_driver *drv) { + unregister_cpu_notifier(&cpuidle_hotplug_notifier); + spin_lock(&cpuidle_driver_lock); __cpuidle_unregister_driver(drv); spin_unlock(&cpuidle_driver_lock);