From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756184AbbGFQxm (ORCPT ); Mon, 6 Jul 2015 12:53:42 -0400 Received: from www.linutronix.de ([62.245.132.108]:56380 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754464AbbGFQxh (ORCPT ); Mon, 6 Jul 2015 12:53:37 -0400 Date: Mon, 6 Jul 2015 18:53:28 +0200 (CEST) From: Thomas Gleixner To: Sudeep Holla cc: LKML , Ingo Molnar , Peter Zijlstra , Preeti U Murthy , Suzuki Poulose , Lorenzo Pieralisi , Catalin Marinas , "Rafael J. Wysocki" Subject: Re: [patch 1/2] tick/broadcast: Prevent deep idle states if no broadcast device available In-Reply-To: <559AAC73.6010105@arm.com> Message-ID: References: <20150705205032.103910828@linutronix.de> <20150705205221.724282507@linutronix.de> <559A9A2B.2030705@arm.com> <559AA256.5040305@arm.com> <559AAC73.6010105@arm.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Jul 2015, Sudeep Holla wrote: > On 06/07/15 17:06, Thomas Gleixner wrote: > 2. After boot I am seeing the below warning: > > ------------[ cut here ]------------ > WARNING: CPU: 1 PID: 0 at kernel/time/hrtimer.c:1247 > __hrtimer_run_queues+0x148/0x150() > Modules linked in: > CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.2.0-rc1 #573 > Hardware name: ARM Juno development board (r0) (DT) > Call trace: > [] dump_backtrace+0x0/0x124 > [] show_stack+0x10/0x1c > [] dump_stack+0x84/0xc8 > [] warn_slowpath_common+0x98/0xd0 > [] warn_slowpath_null+0x14/0x20 > [] __hrtimer_run_queues+0x144/0x150 > [] hrtimer_run_queues+0xb8/0xe8 > [] update_process_times+0x28/0x6c > [] tick_periodic+0x3c/0xb8 > [] tick_handle_periodic+0x28/0x94 > [] arch_timer_handler_phys+0x28/0x38 > [] handle_percpu_devid_irq+0x74/0x9c > [] generic_handle_irq+0x30/0x4c > [] __handle_domain_irq+0x5c/0xac > [] gic_handle_irq+0x30/0x80 Bah. I fear Preeti's hrtimer-broadcast stuff recurses in the hrtimer code. tick_periodic() expire broadcast timer() handle_broadcast() { tick_periodic() expire_other_timer() } warning triggers Crap. Patch below should cure that. Thanks, tglx --- Index: tip/kernel/time/tick-broadcast.c =================================================================== --- tip.orig/kernel/time/tick-broadcast.c +++ tip/kernel/time/tick-broadcast.c @@ -358,18 +358,21 @@ void tick_broadcast_control(enum tick_br tick_broadcast_forced = 1; case TICK_BROADCAST_ON: cpumask_set_cpu(cpu, tick_broadcast_on); - if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) { - /* - * Only shutdown the cpu local device, if the - * broadcast device exists and is in periodic - * mode. The latter check prevents a hickup - * during the switch from periodic to oneshot - * mode. - */ - if (bc != NULL && tick_broadcast_device.mode == - TICKDEV_MODE_PERIODIC) - clockevents_shutdown(dev); - } + + /* + * Only shutdown the cpu local device, if: + * + * - the broadcast device exists + * - the broadcast device is not a hrtimer based one + * - the broadcast device is in periodic mode to + * avoid a hickup during switch to oneshot mode + */ + if (!bc || (bc->features & CLOCK_EVT_FEAT_HRTIMER) || + tick_broadcast_device.mode != TICKDEV_MODE_PERIODIC) + break; + + if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) + clockevents_shutdown(dev); break; case TICK_BROADCAST_OFF: @@ -697,14 +700,18 @@ int __tick_broadcast_oneshot_control(enu * shutdown. */ ret = broadcast_needs_cpu(bc, cpu); + if (ret) + goto out; /* - * If the hrtimer broadcast check tells us that the - * cpu cannot go deep idle, or if the broadcast device - * is in periodic mode, we just return. + * If the broadcast device is in periodic mode, we + * return. */ - if (ret || tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) - goto out; + if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) { + /* If it is a hrtimer based broadcast, return busy */ + if (bc->features & CLOCK_EVT_FEAT_HRTIMER) + ret = -EBUSY; + } if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_oneshot_mask)) { WARN_ON_ONCE(cpumask_test_cpu(cpu, tick_broadcast_pending_mask));