From patchwork Wed Nov 23 20:13:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Pan X-Patchwork-Id: 9444235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 616BE60778 for ; Wed, 23 Nov 2016 20:15:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 658BD27CAF for ; Wed, 23 Nov 2016 20:15:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59F8C27D5D; Wed, 23 Nov 2016 20:15:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 846DE27CE7 for ; Wed, 23 Nov 2016 20:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936078AbcKWUP1 (ORCPT ); Wed, 23 Nov 2016 15:15:27 -0500 Received: from mga06.intel.com ([134.134.136.31]:25546 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935958AbcKWUPY (ORCPT ); Wed, 23 Nov 2016 15:15:24 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 23 Nov 2016 12:14:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,539,1473145200"; d="scan'208";a="904868344" Received: from icelake.jf.intel.com ([10.7.199.162]) by orsmga003.jf.intel.com with ESMTP; 23 Nov 2016 12:14:59 -0800 From: Jacob Pan To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , LKML , Linux PM , Rafael Wysocki Cc: Arjan van de Ven , Srinivas Pandruvada , Len Brown , Eduardo Valentin , Zhang Rui , Petr Mladek , Sebastian Andrzej Siewior , Jacob Pan Subject: [PATCH v3 3/3] thermal/powerclamp: stop sched tick in forced idle Date: Wed, 23 Nov 2016 12:13:10 -0800 Message-Id: <1479931990-11732-4-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479931990-11732-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1479931990-11732-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the introduction of play_idle(), idle injection kthread can go through the normal idle task processing to get correct accounting and turn off scheduler tick when possible. Hrtimer is used to wake up since timeout is most likely to occur during idle injection. Signed-off-by: Jacob Pan --- drivers/thermal/intel_powerclamp.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c index 745fcec..68dd963 100644 --- a/drivers/thermal/intel_powerclamp.c +++ b/drivers/thermal/intel_powerclamp.c @@ -93,7 +93,6 @@ struct powerclamp_worker_data { struct kthread_worker *worker; struct kthread_work balancing_work; struct kthread_delayed_work idle_injection_work; - struct timer_list wakeup_timer; unsigned int cpu; unsigned int count; unsigned int guard; @@ -278,11 +277,6 @@ static u64 pkg_state_counter(void) return count; } -static void noop_timer(unsigned long foo) -{ - /* empty... just the fact that we get the interrupt wakes us up */ -} - static unsigned int get_compensation(int ratio) { unsigned int comp = 0; @@ -432,7 +426,6 @@ static void clamp_balancing_func(struct kthread_work *work) static void clamp_idle_injection_func(struct kthread_work *work) { struct powerclamp_worker_data *w_data; - unsigned long target_jiffies; w_data = container_of(work, struct powerclamp_worker_data, idle_injection_work.work); @@ -453,31 +446,7 @@ static void clamp_idle_injection_func(struct kthread_work *work) if (should_skip) goto balance; - target_jiffies = jiffies + w_data->duration_jiffies; - mod_timer(&w_data->wakeup_timer, target_jiffies); - if (unlikely(local_softirq_pending())) - goto balance; - /* - * stop tick sched during idle time, interrupts are still - * allowed. thus jiffies are updated properly. - */ - preempt_disable(); - /* mwait until target jiffies is reached */ - while (time_before(jiffies, target_jiffies)) { - unsigned long ecx = 1; - unsigned long eax = target_mwait; - - /* - * REVISIT: may call enter_idle() to notify drivers who - * can save power during cpu idle. same for exit_idle() - */ - local_touch_nmi(); - stop_critical_timings(); - mwait_idle_with_hints(eax, ecx); - start_critical_timings(); - atomic_inc(&idle_wakeup_counter); - } - preempt_enable(); + play_idle(jiffies_to_msecs(w_data->duration_jiffies)); balance: if (clamping && w_data->clamping && cpu_online(w_data->cpu)) @@ -540,7 +509,6 @@ static void start_power_clamp_worker(unsigned long cpu) w_data->cpu = cpu; w_data->clamping = true; set_bit(cpu, cpu_clamping_mask); - setup_timer(&w_data->wakeup_timer, noop_timer, 0); sched_setscheduler(worker->task, SCHED_FIFO, &sparam); kthread_init_work(&w_data->balancing_work, clamp_balancing_func); kthread_init_delayed_work(&w_data->idle_injection_work, @@ -572,7 +540,6 @@ static void stop_power_clamp_worker(unsigned long cpu) * a big deal. The balancing work is fast and destroy kthread * will wait for it. */ - del_timer_sync(&w_data->wakeup_timer); clear_bit(w_data->cpu, cpu_clamping_mask); kthread_destroy_worker(w_data->worker);