Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1116291imm; Thu, 31 May 2018 15:52:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWA9daWBQAksDBdjm/UnWg1Q0wX64y9FCr/b9yt2XiF/VswEATNmH6FuQmIsngxnFaOqhT X-Received: by 2002:a62:249b:: with SMTP id k27-v6mr8475052pfk.143.1527807179036; Thu, 31 May 2018 15:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527807179; cv=none; d=google.com; s=arc-20160816; b=wCEakOFaKeRbjsqarEIRceekmx+g83Bk1d697Uf45vd3AsAPgpN029XyyOPLdP1I7z 9E2Pl/ZfDqWu9MDwwxIYVHXPkyx7ZJtQB3oSGs76UreLwvGcExhqOMkofd7TR3sRlffO nI3fIzQhSd3g0eqa3xApnqSrvSJMN0lIf6lLSzGbdziNmqNiBD21DlcD9etmrgJ9RYPa Rf5VJQL4Pc28pYipWDaEdD+aTYT50u4Nsnh/1L+GEC3T8OOQkcFKeaoORi/2LaB1G415 IDHVIbD55Krvm97Dp2Ar/AJvse7iVDIiXaY2HmQuD6rl3BFkzaLFT5Ab9//zyztvpBMO UAFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7QHX8vSgaJnrx+ClcaiZKNlnc9exTTiXQkEWwfdYwUk=; b=GWorD03ItG77VzyT2nYoIgD9PmsT9odwRPftLrvxm8K9AhZtDUfCAyWeUgsRGcizIe h/7VgiN1N3RA9Pt3l136CNuMLu7izavdedbuEfDPuOOgxj9nnzQ8HqxiBaTxUYuQAszc IJ7g5Nz3ga0AbRIvan5fJHtJdL1lJftIkDKaYSkXU4ClcoJ9dYK+kUiuaISkJm31VjVs SpspOkrg+nvc6w3gwFNoOKegjDOo+9NhSyahAEdtEuO2J1e5UBN1cvgdYfIN6HwtlGgF TDviHXXD1bSKV436bb1Db76711V1KWOEdZqzOiiX+fAMiE8wLPnSULQj8sauVvZ0XrJx wXAw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20-v6si15069653pgn.464.2018.05.31.15.52.44; Thu, 31 May 2018 15:52:59 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751348AbeEaWv6 (ORCPT + 99 others); Thu, 31 May 2018 18:51:58 -0400 Received: from mga14.intel.com ([192.55.52.115]:6569 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbeEaWvx (ORCPT ); Thu, 31 May 2018 18:51:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 15:51:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,464,1520924400"; d="scan'208";a="233413424" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2018 15:51:52 -0700 From: Srinivas Pandruvada To: lenb@kernel.org, rjw@rjwysocki.net, peterz@infradead.org, mgorman@techsingularity.net Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, juri.lelli@redhat.com, viresh.kumar@linaro.org, Srinivas Pandruvada Subject: [RFC/RFT] [PATCH v3 2/4] cpufreq: intel_pstate: HWP boost performance on IO wakeup Date: Thu, 31 May 2018 15:51:41 -0700 Message-Id: <20180531225143.34270-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180531225143.34270-1-srinivas.pandruvada@linux.intel.com> References: <20180531225143.34270-1-srinivas.pandruvada@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change uses SCHED_CPUFREQ_IOWAIT flag to boost HWP performance. Since SCHED_CPUFREQ_IOWAIT flag is set frequently, we don't start boosting steps unless we see two consecutive flags in two ticks. This avoids boosting due to IO because of regular system activities. To avoid synchronization issues, the actual processing of the flag is done on the local CPU callback. Signed-off-by: Srinivas Pandruvada --- drivers/cpufreq/intel_pstate.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 80bf61ae4b1f..2a14756d958e 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -223,6 +223,8 @@ struct global_params { * operation * @hwp_req_cached: Cached value of the last HWP Request MSR * @hwp_cap_cached: Cached value of the last HWP Capabilities MSR + * @last_io_update: Last time when IO wake flag was set + * @sched_flags: Store scheduler flags for possible cross CPU update * @hwp_boost_min: Last HWP boosted min performance * * This structure stores per CPU instance data for all CPUs. @@ -258,6 +260,8 @@ struct cpudata { s16 epp_saved; u64 hwp_req_cached; u64 hwp_cap_cached; + u64 last_io_update; + unsigned int sched_flags; int hwp_boost_min; }; @@ -1460,9 +1464,44 @@ static inline void intel_pstate_hwp_boost_down(struct cpudata *cpu) cpu->last_update = cpu->sample.time; } +static inline void intel_pstate_update_util_hwp_local(struct cpudata *cpu, + u64 time) +{ + cpu->sample.time = time; + + if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { + bool do_io = false; + + cpu->sched_flags = 0; + /* + * Set iowait_boost flag and update time. Since IO WAIT flag + * is set all the time, we can't just conclude that there is + * some IO bound activity is scheduled on this CPU with just + * one occurrence. If we receive at least two in two + * consecutive ticks, then we treat as boost candidate. + */ + if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) + do_io = true; + + cpu->last_io_update = time; + + if (do_io) + intel_pstate_hwp_boost_up(cpu); + + } else { + intel_pstate_hwp_boost_down(cpu); + } +} + static inline void intel_pstate_update_util_hwp(struct update_util_data *data, u64 time, unsigned int flags) { + struct cpudata *cpu = container_of(data, struct cpudata, update_util); + + cpu->sched_flags |= flags; + + if (smp_processor_id() == cpu->cpu) + intel_pstate_update_util_hwp_local(cpu, time); } static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu) -- 2.13.6