From patchwork Tue Feb 23 01:22:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Muckle X-Patchwork-Id: 8385931 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 854D39F1D4 for ; Tue, 23 Feb 2016 01:25:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6E71204D1 for ; Tue, 23 Feb 2016 01:25:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A68D520675 for ; Tue, 23 Feb 2016 01:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756812AbcBWBW6 (ORCPT ); Mon, 22 Feb 2016 20:22:58 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:33069 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756802AbcBWBW4 (ORCPT ); Mon, 22 Feb 2016 20:22:56 -0500 Received: by mail-pf0-f173.google.com with SMTP id q63so102051216pfb.0 for ; Mon, 22 Feb 2016 17:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0fdSsN+i60Di+rKju9vsB7mEeCr4/Ii+miQs9Zr2XDw=; b=bULAeU+x4W7v8XewVkjVtHfkShRD9z4R0PNBct0Z0SahBEDmqFdiE1srIbYL3EXMr/ LfbleC01lc4hO1yRh6QmdqCNz3COYPPpebE6bhkqRDNUhIjHNjZrP5xhzS6ddA3Pi2Ro ynepB870D0FPJSzImyTVYNfGXUUm2WGG5G9Lw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0fdSsN+i60Di+rKju9vsB7mEeCr4/Ii+miQs9Zr2XDw=; b=QqLTdMc4xMyJkrsj8EznAbYOI5/GnsfMVg8KbnLyObn1FfX5uJELSBIeV3bLc+fscB rF+UPbq/aF7FoPy6JKDJ63Ms4a9JjwIrd2PjlOAVJAgu61x8B7XhPGJe/spAHnbYAGHw ep+SJ0C2qtmS2Nq16x6atf7NIev+mFqOasdx1IfZEyZfFu3azXP5wjfTHxDgB2FCxZWY WgdvKGMrmQ5byw34bbltxbDid9DgsFTvJfRRb7FlM/HCSXaR2iKcdDIqQXfttpNsRZtf CYf+6EYYNAyqTBv9RzKoIzDllTqnvuUzmmwnDE1Q4J/AgABVJEJCiLEAlIIVHp350Qpg WL7g== X-Gm-Message-State: AG10YORuCW43sX/kcO1baZB0Pk8nR6buEzlvU4WvNJDwND6GVIdVdgNcUJOQCALdCnhAszbc X-Received: by 10.98.68.212 with SMTP id m81mr42281240pfi.135.1456190575588; Mon, 22 Feb 2016 17:22:55 -0800 (PST) Received: from graphite.smuckle.net (cpe-75-80-155-7.san.res.rr.com. [75.80.155.7]) by smtp.gmail.com with ESMTPSA id t29sm39626789pfi.8.2016.02.22.17.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 17:22:54 -0800 (PST) From: Steve Muckle X-Google-Original-From: Steve Muckle To: Peter Zijlstra , Ingo Molnar , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Patrick Bellasi , Michael Turquette , Viresh Kumar Subject: [RFCv7 PATCH 02/10] cpufreq: introduce cpufreq_driver_is_slow Date: Mon, 22 Feb 2016 17:22:42 -0800 Message-Id: <1456190570-4475-3-git-send-email-smuckle@linaro.org> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1456190570-4475-1-git-send-email-smuckle@linaro.org> References: <1456190570-4475-1-git-send-email-smuckle@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Michael Turquette Some architectures and platforms perform CPU frequency transitions through a non-blocking method, while some might block or sleep. Even when frequency transitions do not block or sleep they may be very slow. This distinction is important when trying to change frequency from a non-interruptible context in a scheduler hot path. Describe this distinction with a cpufreq driver flag, CPUFREQ_DRIVER_FAST. The default is to not have this flag set, thus erring on the side of caution. cpufreq_driver_is_slow() is also introduced in this patch. Setting the above flag will allow this function to return false. [smuckle@linaro.org: change flag/API to include drivers that are too slow for scheduler hot paths, in addition to those that block/sleep] Cc: Rafael J. Wysocki Cc: Viresh Kumar Signed-off-by: Michael Turquette Signed-off-by: Steve Muckle --- drivers/cpufreq/cpufreq.c | 6 ++++++ include/linux/cpufreq.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e979ec7..88e63ca 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -154,6 +154,12 @@ bool have_governor_per_policy(void) } EXPORT_SYMBOL_GPL(have_governor_per_policy); +bool cpufreq_driver_is_slow(void) +{ + return !(cpufreq_driver->flags & CPUFREQ_DRIVER_FAST); +} +EXPORT_SYMBOL_GPL(cpufreq_driver_is_slow); + struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) { if (have_governor_per_policy()) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 88a4215..93e1c1c 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -160,6 +160,7 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu); bool have_governor_per_policy(void); +bool cpufreq_driver_is_slow(void); struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); #else static inline unsigned int cpufreq_get(unsigned int cpu) @@ -316,6 +317,14 @@ struct cpufreq_driver { */ #define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5) +/* + * Indicates that it is safe to call cpufreq_driver_target from + * non-interruptable context in scheduler hot paths. Drivers must + * opt-in to this flag, as the safe default is that they might sleep + * or be too slow for hot path use. + */ +#define CPUFREQ_DRIVER_FAST (1 << 6) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);