From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754622AbaEIBhV (ORCPT ); Thu, 8 May 2014 21:37:21 -0400 Received: from mail-qc0-f172.google.com ([209.85.216.172]:59598 "EHLO mail-qc0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751924AbaEIBhT (ORCPT ); Thu, 8 May 2014 21:37:19 -0400 Date: Thu, 8 May 2014 21:37:15 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux cc: Doug Anderson , Viresh Kumar , "Rafael J. Wysocki" , Will Deacon , John Stultz , David Riley , "olof@lixom.net" , Sonny Rao , Richard Zhao , Santosh Shilimkar , Shawn Guo , Stephen Boyd , Marc Zyngier , Stephen Warren , Paul Gortmaker , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] ARM: Don't ever downscale loops_per_jiffy in SMP systems In-Reply-To: <20140508205223.GI3693@n2100.arm.linux.org.uk> Message-ID: References: <1399504982-31181-1-git-send-email-dianders@chromium.org> <20140508192209.GH3693@n2100.arm.linux.org.uk> <20140508205223.GI3693@n2100.arm.linux.org.uk> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 May 2014, Russell King - ARM Linux wrote: > If you're in a preempt or SMP environment, provide a timer for udelay(). > IF you're in an environment with IRQs which can take a long time, use > a timer for udelay(). If you're in an environment where the CPU clock > can change unexpectedly, use a timer for udelay(). Longer delays are normally not a problem. If they are, then simply disabling IRQs may solve it if absolutely required. With much shorter delays than expected this is another story. What about the following: diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 7c4fada440..10030cc5a0 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -682,6 +682,15 @@ static int cpufreq_callback(struct notifier_block *nb, cpufreq_scale(per_cpu(l_p_j_ref, cpu), per_cpu(l_p_j_ref_freq, cpu), freq->new); + /* + * Another CPU might have called udelay() just before LPJ + * and a shared CPU clock is increased. That other CPU still + * looping on the old LPJ value would return significantly + * sooner than expected. The actual fix is to provide a + * timer based udelay() implementation instead. + */ + if (freq->old < freq->new) + pr_warn_once("*** udelay() on SMP is racy and may be much shorter than expected ***\n"); } return NOTIFY_OK; } Nicolas