Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6933650imu; Thu, 31 Jan 2019 02:04:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN4dU5sL538Zev7gscnydphvW1CorFTCL2p/4fnjvlIgoFEGAtVbWIb6PWSazh25n2jWp3fb X-Received: by 2002:a62:c711:: with SMTP id w17mr34445045pfg.50.1548929055904; Thu, 31 Jan 2019 02:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548929055; cv=none; d=google.com; s=arc-20160816; b=bqZSrXms1THQEVLNLzOAK+5pM2EJ98OX6P1YUnfjhOlx5WP2NqqlfOWvto2fxZzIO3 vEmsfLk/10BlnfS5pg4bxwAiFNImkCGfdfsxJsHyy0e1EUt/O8FZNZ6dGGwzpFlxm+Sr sckTzgwb2BToXdpiNfZloLY9FaWhh0/RQ2X6wM5GQmT0LpxjfukFz85BcKvw+1vSLHUU 7ezeOG2gqJKpnDmdFUQxtaAEKM3nHIYiI1ABMQWuUar3WEJV0a5GwedHce0u/NscHq6t iwaQvL1N8/uRPx0DHfNbM05DuI993IkR0I2eXdYBSHyOXl2Ks0uSIU/6CxIpWelItgut 7DrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=PHT1EMf0HMi7CqErngK2FHpkAf8OS6d9/B/7LNThXEA=; b=TNSNYR+sqWmAUXBfn0WaCBywBdjJmgAECaqPOVRfoFvbWhZL0hJ7+Ms1Lxsfmn9OLV IRst21wKrAX6zaLUy9qHkvus1zTLw6WJMKCyUKUuRPBnBBRHs4izTaUm00Dskd4Jgsb/ NInX0yad5kJrZsvRpy7XtGDOEMmDiV5BdUH7XZcoSyo0B7/8S4J0wKYr7GoP0+0bYNrq I1pBMobch3gWWUBfmlZYmrt4gjOTPokQnptD1uots2aQlRxQzjkfIG8/C4xXfr92aCnG 7cu/THuO0LhcEelhHtC1F5fuJQWMRyxTus5vMGUSuMFS4eml4KRdhkeg+xAnbJAX35lx Erfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a34si3465013pgb.458.2019.01.31.02.04.00; Thu, 31 Jan 2019 02:04:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731867AbfAaKCY (ORCPT + 99 others); Thu, 31 Jan 2019 05:02:24 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:45591 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729509AbfAaKCY (ORCPT ); Thu, 31 Jan 2019 05:02:24 -0500 Received: by mail-ot1-f65.google.com with SMTP id 32so2253841ota.12; Thu, 31 Jan 2019 02:02:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PHT1EMf0HMi7CqErngK2FHpkAf8OS6d9/B/7LNThXEA=; b=Jrd4C7k7DRI20aNhQnwr0jHW0FUUQ/zDJQIvLBApp3QO2as9Btmbb3OJfFBKRWpiJ1 UwBWn8rnYbys8ioNLJ80tZ1IhR+L7P9EAaFeZlSaNv0cUKN5G3ZNFBYgMpAcqjcBbn3q wwLHDv1gD12kGNqwSa3+nvCboygSof9HR0izzR/SBtf+v5cvikyB6wHBmmagbE9BoGru 8Y7CDQH97BP5t4LZXF55YUBppGx9HVzJ20H+iPR7lOnUYxQUwIDdigIi/F0StqPgioMD lxkSgxiltGjgvFv+APwJF9ai+fGMChbsh0AqmYBrKG08KTOdVFbWjXW3N4zvPFdl1GxZ tAhg== X-Gm-Message-State: AJcUukeXwRtf4WuHBGcZpoIqNxPkywYMJdw/wkjHf6CTgx14NLgyQF/p UO+PoP0hNFi/N33rzhoDQD4mginfIVatgKjkJMg= X-Received: by 2002:a9d:5f06:: with SMTP id f6mr26238397oti.258.1548928943246; Thu, 31 Jan 2019 02:02:23 -0800 (PST) MIME-Version: 1.0 References: <20190131015139.126890-1-mka@chromium.org> In-Reply-To: <20190131015139.126890-1-mka@chromium.org> From: "Rafael J. Wysocki" Date: Thu, 31 Jan 2019 11:02:12 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: Record stats when fast switching is enabled To: Matthias Kaehlcke Cc: "Rafael J . Wysocki" , Viresh Kumar , Linux PM , Linux Kernel Mailing List , Douglas Anderson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 2:51 AM Matthias Kaehlcke wrote: > > When fast switching is enabled currently no cpufreq stats are > recorded and the corresponding sysfs attributes appear empty (see > also commit 1aefc75b2449 ("cpufreq: stats: Make the stats code > non-modular")). > > Record the stats after a successful fast switch and re-enable access > through sysfs when fast switching is enabled. Since > cpufreq_stats_update() can now be called in interrupt context (during > a fast switch) disable local IRQs while holding the stats spinlock. > > Signed-off-by: Matthias Kaehlcke > --- > The change is so simple that I wonder if I'm missing some important > reason why the stats can't/shouldn't be updated during/after a fast > switch ... > > I would expect that holding the stats spinlock briefly in > cpufreq_stats_update() shouldn't be a problem. In theory it would > also be an option to have a per stats lock, though it seems overkill > from my (possibly ignorant) point of view. > --- > drivers/cpufreq/cpufreq.c | 8 +++++++- > drivers/cpufreq/cpufreq_stats.c | 11 +++-------- > 2 files changed, 10 insertions(+), 9 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index e35a886e00bcf..63aadb0bbddfe 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1857,9 +1857,15 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); > unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, > unsigned int target_freq) > { > + unsigned int freq; > + > target_freq = clamp_val(target_freq, policy->min, policy->max); > > - return cpufreq_driver->fast_switch(policy, target_freq); > + freq = cpufreq_driver->fast_switch(policy, target_freq); > + if (freq) > + cpufreq_stats_record_transition(policy, freq); No extra locking in the fast switch path, pretty please. This runs in the scheduler context and it adds enough overhead in there already. > + > + return freq; > } > EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch);