From patchwork Sat Apr 28 03:28:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 8297 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 559A023E47 for ; Sat, 28 Apr 2012 03:29:23 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id F143EA180B3 for ; Sat, 28 Apr 2012 03:29:22 +0000 (UTC) Received: by iage36 with SMTP id e36so2563405iag.11 for ; Fri, 27 Apr 2012 20:29:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-spamscore:x-bigfish:x-forefront-antispam-report:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-originatororg:x-gm-message-state; bh=Tu7tClVJ2/oA5cqvnfL6mc8YcDa6j05nnaungBnHmRk=; b=WpoJRJQUxKG7aTC3ucvobtAJEJ7qqEtxyd0JAOSgB0XsI1udM75HTnOHpDhzAZtW9Y hPyOGi9l3/Xsxis0IKSmVq1VPKbwz+Mmm/oaz5T3H+kwCEQrwT2y2TEkWBmpHLGNN3B1 8X5QAvhJtYxNgMiVZbwspD+pSkUY/rEndih2KAe6JVROCAVeYYgPlfXQymm/MUgCVNhQ 8y/c4TAM4UkQ4kDdReWZNhxj3Ben05C7zu6zmsnWKdqRrhSlpovWnPp/ga7W3gKK/hQn a1bVT8Fpbsom46/UnXOzjbRQuPEftjrv37E1DI2vZ6by26+ccqoFQp4QiHtRWO3pUSW6 5suA== Received: by 10.50.193.199 with SMTP id hq7mr4516388igc.49.1335583762349; Fri, 27 Apr 2012 20:29:22 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp67122ibt; Fri, 27 Apr 2012 20:29:21 -0700 (PDT) Received: by 10.68.217.227 with SMTP id pb3mr7949778pbc.138.1335583760892; Fri, 27 Apr 2012 20:29:20 -0700 (PDT) Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe002.messaging.microsoft.com. [216.32.180.12]) by mx.google.com with ESMTPS id t9si8670938pbj.312.2012.04.27.20.29.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Apr 2012 20:29:20 -0700 (PDT) Received-SPF: neutral (google.com: 216.32.180.12 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) client-ip=216.32.180.12; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.180.12 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) smtp.mail=B20223@freescale.com Received: from mail31-va3-R.bigfish.com (10.7.14.235) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.23; Sat, 28 Apr 2012 03:29:16 +0000 Received: from mail31-va3 (localhost [127.0.0.1]) by mail31-va3-R.bigfish.com (Postfix) with ESMTP id 268503004AB; Sat, 28 Apr 2012 03:29:16 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839hd24he5bh) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail31-va3 (localhost.localdomain [127.0.0.1]) by mail31-va3 (MessageSwitch) id 1335583754423348_18693; Sat, 28 Apr 2012 03:29:14 +0000 (UTC) Received: from VA3EHSMHS015.bigfish.com (unknown [10.7.14.253]) by mail31-va3.bigfish.com (Postfix) with ESMTP id 56766220083; Sat, 28 Apr 2012 03:29:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS015.bigfish.com (10.7.99.25) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 28 Apr 2012 03:29:14 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.355.3; Fri, 27 Apr 2012 22:29:16 -0500 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id q3S3T8g1028456; Fri, 27 Apr 2012 22:29:09 -0500 (CDT) From: Richard Zhao To: , CC: , , , , , , Richard Zhao Subject: [RESEND PATCH 1/2] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Date: Sat, 28 Apr 2012 11:28:42 +0800 Message-ID: <1335583723-18915-1-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Gm-Message-State: ALoCoQlI8yJ4AE3u8rwEJD9ru+TDk5E9qjj/f4/vSQ8mZG/VbKRLlU7U51hFYyF8/BSKG5fAiVkk If CONFIG_SMP, cpufreq skips loops_per_jiffy update, because different arch has different per-cpu loops_per_jiffy definition. Signed-off-by: Richard Zhao Acked-by: Russell King --- arch/arm/kernel/smp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index addbbe8..33af711 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -604,3 +605,56 @@ int setup_profiling_timer(unsigned int multiplier) { return -EINVAL; } + +#ifdef CONFIG_CPU_FREQ + +static DEFINE_PER_CPU(unsigned long, l_p_j_ref); +static DEFINE_PER_CPU(unsigned long, l_p_j_ref_freq); +static unsigned long global_l_p_j_ref; +static unsigned long global_l_p_j_ref_freq; + +static int cpufreq_callback(struct notifier_block *nb, + unsigned long val, void *data) +{ + struct cpufreq_freqs *freq = data; + int cpu = freq->cpu; + + if (freq->flags & CPUFREQ_CONST_LOOPS) + return NOTIFY_OK; + + if (!per_cpu(l_p_j_ref, cpu)) { + per_cpu(l_p_j_ref, cpu) = + per_cpu(cpu_data, cpu).loops_per_jiffy; + per_cpu(l_p_j_ref_freq, cpu) = freq->old; + if (!global_l_p_j_ref) { + global_l_p_j_ref = loops_per_jiffy; + global_l_p_j_ref_freq = freq->old; + } + } + + if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || + (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || + (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { + loops_per_jiffy = cpufreq_scale(global_l_p_j_ref, + global_l_p_j_ref_freq, + freq->new); + per_cpu(cpu_data, cpu).loops_per_jiffy = + cpufreq_scale(per_cpu(l_p_j_ref, cpu), + per_cpu(l_p_j_ref_freq, cpu), + freq->new); + } + return NOTIFY_OK; +} + +static struct notifier_block cpufreq_notifier = { + .notifier_call = cpufreq_callback, +}; + +static int __init register_cpufreq_notifier(void) +{ + return cpufreq_register_notifier(&cpufreq_notifier, + CPUFREQ_TRANSITION_NOTIFIER); +} +core_initcall(register_cpufreq_notifier); + +#endif